Peter K Chan wrote:
Well, you could, couldn't you?

The output is a legal Java class files, so you are free to load it up
and use it safely in your Java class. You may need to initialize some
JRuby constructs before you call the method on that class, but how is
this different from any other API? Would you go around and arbitrarily
instantiate any Java objects you find in the class path, without looking
at the Javadoc first?

This isn't entirely true. the methods in the class are not directly callable; they expect you to set up call frames, variable scopes (and you can't know which kind they need from outside), push and pop various elements on the ThreadContext, and so on. Beyond that, there's no way anyone could ever guess or compile Java code that would call most of the methods on the class, since they have names like __file__ and foo_1 and __rescue_47.

The exceptions, however, are that there's three entry-point methods:

- a static main method which spins up a JRuby instance and runs the compiled script - a run method used by the JIT, which expects that all framing/scoping has been done and then runs the script - a load method which does the framing and scoping necessary to call a given script, and then runs the script

But these are pretty limited, and only give you the ability to launch the script as a whole, not call any methods defined within it.

Let me add a specific, technical problem with using custom extension:
consider the JET compiler, which compiles java .class to native code. If
we leverage that to compile JRuby-compiled code, we can have (as far as
I know) the first native compiler for Ruby. I can see it compiling a
foo_bar.class into a foo_bar.obj, which, when
Class.forName("foo/bar.rb"), will load the native code version. If we
require a custom classloader, "foo/bar.rb" cannot be precompiled AOT
[1].

I'd like to see if this is a real limitation; how do you specify the file to compile with this tool? Does the file have to end in .class?

I appreciate your concerns, really. It's unfortunate that so many tools and libraries expect .class, but that's the way it is.

I'm still on the fence.

- Charlie

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

   http://xircles.codehaus.org/manage_email

Reply via email to