Forum: JRuby Importing Java packages

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Wes G. (Guest)
on 2009-02-27 17:33
(Received via mailing list)
JRuby 1.1.6

Just a quick verify:

It appears that I can't do:

  import java.lang.*

but only import specific classes, as in import java.lang.System, for
example.

Actually, this is pretty much fine with me, as I'm a "specify down the
class level" kind of guy.

But I just wanted to verify.  Can you ever import an entire namespace
worth of classes with a "*"?

Thanks,
Wes

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
Logan B. (Guest)
on 2009-02-28 02:39
(Received via mailing list)
On Feb 27, 2009, at 8:33 AM, Wes G. wrote:

> JRuby 1.1.6
>
> Just a quick verify:
>
> It appears that I can't do:
>
> import java.lang.*

Have you tried include_class 'java.lang.*'? I remember reading that
this is supported somewhere.

>
> Thanks,
> Wes
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>   http://xircles.codehaus.org/manage_email
>
>


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
Thomas E Enebo (Guest)
on 2009-02-28 17:33
(Received via mailing list)
On Fri, Feb 27, 2009 at 6:38 PM, Logan B. <removed_email_address@domain.invalid>
wrote:
>
> Have you tried include_class 'java.lang.*'? I remember reading that this is
> supported somewhere.

Unless someone added '*' to include_class this is the only code I know
to do this:

module Foo
  include_package 'java.lang'
end

Foo::System.getProperty("ick")

We have talked about collaborating with Jython on providing the right
magic to be able to nicely include packages (there is no standard API
for this in Java), but we not crossed that bridge yet.

One historical issue which keeps getting smaller is loading n classes
of a package takes time (much much much less than in the past).  One
could argue that we could do that lazily, but then we need
const_missing hook (or equiv).  It ends up having some unexpected
complexity.

A second issue is that we can dynamically alter a package by
dynamically including more classes into the runtime at any point in
time.  Note, that this a bigger burden than languages which can
compile and resolve packages at load time/compile time.

These are not insurmountable, but not trivial either.  We also have
never had anyone hack in a patch for us to play with.  Perhaps we will
talk to the Jython guys this month at PyCon and see what we can do...

-Tom


>> Thanks,
>> Wes



--
Blog: http://www.bloglines.com/blog/ThomasEEnebo
Email: removed_email_address@domain.invalid , 
removed_email_address@domain.invalid

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
This topic is locked and can not be replied to.