[ANN] ruby2java 0.0.1 Released


#1

ruby2java version 0.0.1 has been released!

The Ruby2Java compiler inspects the runtime definition of classes
to produce a normal-looking Java class. All metaprogrammed methods
are reflected on the Java class, as are runtime modifications to
those methods.

Changes:

0.0.1 / 2009-05-20

  • First experimental version

  • Basic compilation of a Ruby class to a Java class

  • public instance and static methods and public constructors

  • interface implementation

  • package specification

  • basic method annotations

  • http://kenai.com/projects/ruby2java/pages/Home


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

#2

And close on its heels is 0.0.2, which actually specifies the bitescript
dependency! Sigh.

Charles Oliver N. wrote:


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

#3

On Friday 22 May 2009, Charles Oliver N. wrote:

ruby2java version 0.0.1 has been released!

The Ruby2Java compiler inspects the runtime definition of classes
to produce a normal-looking Java class. All metaprogrammed methods
are reflected on the Java class, as are runtime modifications to
those methods.

Will Ruby2Java eventually be used by JRuby to compile ruby scripts to
class
files like jython?

The reason I am asking is that I can get the python stack traces as part
of
the Java stacktrace in Jython, but not (yet) in JRuby.

Lothar


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

#4

On Friday 22 May 2009, Charles Oliver N. wrote:

Will Ruby2Java eventually be used by JRuby to compile ruby scripts to
class files like jython?

The reason I am asking is that I can get the python stack traces as part
of the Java stacktrace in Jython, but not (yet) in JRuby.

Actually you can get Ruby in the Java trace if you have JRuby compile
everything to bytecode up front (-X+C flag) and tell it to produce “raw”
stack traces (-J-Djruby.backtrace.style=raw). The reason you don’t
normally see it is because we have an interpreter and Jython doesn’t.

I use JRuby via the JSR223 Java scripting API. How would I get JRuby to
compile everything to bytecode and provide me with the “raw” stack
traces in
that environment?

I assume I would need to set a Java system property
“jruby.backtrace.style”
to “raw” for the stack traces, but how to tell JRuby to generate class
files
for the ruby scripts?

Ruby2Java is intended to allow easier integration with Java libraries
and frameworks that require a “real” Java class, such as any frameworks
that use annotations or reflection.

  • Charlie

Lothar


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

#5

Lothar Werzinger wrote:

I use JRuby via the JSR223 Java scripting API. How would I get JRuby to
compile everything to bytecode and provide me with the “raw” stack traces in
that environment?

I assume I would need to set a Java system property “jruby.backtrace.style”
to “raw” for the stack traces, but how to tell JRuby to generate class files
for the ruby scripts?

The property for “forced” compilation (-X+C) is
jruby.compile.mode=FORCE, and it will cause any required files to be
compiled before running.

So you could precompile scripts using jrubyc, or require them all in
with “forced” compilation to get the effect you’re looking for (eval’ed
code does not compile even with compile.mode=force).

We’re interested in making this a simpler and possibly default way to
run in the future. Would that be appealing to you?

  • Charlie

To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

#6

Lothar Werzinger wrote:

Will Ruby2Java eventually be used by JRuby to compile ruby scripts to class
files like jython?

The reason I am asking is that I can get the python stack traces as part of
the Java stacktrace in Jython, but not (yet) in JRuby.

Actually you can get Ruby in the Java trace if you have JRuby compile
everything to bytecode up front (-X+C flag) and tell it to produce “raw”
stack traces (-J-Djruby.backtrace.style=raw). The reason you don’t
normally see it is because we have an interpreter and Jython doesn’t.

Ruby2Java is intended to allow easier integration with Java libraries
and frameworks that require a “real” Java class, such as any frameworks
that use annotations or reflection.

  • Charlie

To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

#7

Roger P. wrote:

ruby2java version 0.0.1 has been released!
I assume this is the equivalent of ‘freezing’ a class…but to java
code, is that about right? (i.e. snapshotting its methods -> java)?

To answer my question, yes it is. My suggestion with ruby2java (which
looks sweet, by the way) would be to make possible some kind of autoload
(?)
i.e. “compile this and use the compiled version automatically” so
there’s no manual step. That would be swell.

-=r


#8

Charles Oliver N. wrote:

ruby2java version 0.0.1 has been released!

The Ruby2Java compiler inspects the runtime definition of classes
to produce a normal-looking Java class. All metaprogrammed methods
are reflected on the Java class, as are runtime modifications to
those methods.

I assume this is the equivalent of ‘freezing’ a class…but to java
code, is that about right? (i.e. snapshotting its methods -> java)?
Thanks!
-=r


#9

Hi,

On Sun, May 24, 2009 at 3:53 PM, Charles Oliver N.
removed_email_address@domain.invalid wrote:

The property for “forced” compilation (-X+C) is jruby.compile.mode=FORCE,
and it will cause any required files to be compiled before running.

So you could precompile scripts using jrubyc, or require them all in with
“forced” compilation to get the effect you’re looking for (eval’ed code does
not compile even with compile.mode=force).

We’re interested in making this a simpler and possibly default way to run in
the future. Would that be appealing to you?

I just implemented this script compilation feature to the ongoing
JRuby embed API(http://kenai.com/projects/jruby-embed), and tested by
using testString.rb
(http://kenai.com/projects/jruby-embed/sources/sources/content/test/org/jruby/embed/CompileTest.java?rev=4030a03623df54a7b00255dd9b70373a430f3454).
This “forced” compilation mode is much faster than no compilation, but
not so fast compared with JIT mode. When the script was parsed and
evaluated once, CompileMode.FORCE mode was the fastest. However, after
parsing, when I evaluated the script ten times (I mean, parse once,
eval many times), CompileMode.JIT mode was sometimes the fastest as
in below.

                                      once          10 times

No compilation/No JIT 640 ms 749 ms
CompileMode.JIT 263 ms 425 ms
CompileMode.FORCE 185 ms 435 ms
(JRuby 1.3.0RC2)

Is this an expected result?

-Yoko

  • Charlie

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

#10

Charles Oliver N. wrote:

ruby2java version 0.0.1 has been released!

Another couple of suggestions, just so that you can receive feedback on
ruby2java.
It might be nice to adopt syntax that puts the types closer to the
method signatures themselves, a la something like

typesig String, String
def create_name(fname, lname)
fname + " " + lname
end

http://www.codecommit.com/blog/ruby/adding-type-checking-to-ruby

Or something like that.
You can always override typesig to be a no-op if you’re no on jruby or
what not. This seems more user friendly somehow.

I’d even go as far as to say “it would definitely be nice if duby syntax
happened to parse as valid Ruby syntax” too–it would give duby more of
a shot at being useful to Ruby programmers that way–you could program
in ruby, then optimize to duby when it came time to ramp up for
speed–and it wouldn’t hurt all that much.

Just thinking out loud.
-=r