Importing Java packages


#1

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

#2

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

#3

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