# \[ANN\] ruby2java 0.0.1 Released

**URL:** <https://www.ruby-forum.com/t/ann-ruby2java-0-0-1-released/168623>\
**Category:** JRuby\
**Created:** [May 23, 2009, 1:01am UTC](https://www.ruby-forum.com/t/ann-ruby2java-0-0-1-released/168623 "2009-05-23T01:01:05Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![headius](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/7c8e57/32.png) [@headius](https://www.ruby-forum.com/u/headius)\
**Post date:** [May 23, 2009, 1:01am UTC](https://www.ruby-forum.com/t/ann-ruby2java-0-0-1-released/168623/1 "2009-05-23T01:01:05Z")

</div>

ruby2java version 0.0.1 has been released!

- [http://kenai.com/projects/ruby2java/pages/Home](http://kenai.com/projects/ruby2java/pages/Home)

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](http://kenai.com/projects/ruby2java/pages/Home)

* * *

To unsubscribe from this list, please visit:

```
http://xircles.codehaus.org/manage_email

```

---

<div class="post-metadata">

**Author:** ![headius](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/7c8e57/32.png) [@headius](https://www.ruby-forum.com/u/headius)\
**Post date:** [May 23, 2009, 1:26am UTC](https://www.ruby-forum.com/t/ann-ruby2java-0-0-1-released/168623/2 "2009-05-23T01:26:49Z")

</div>

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](http://xircles.codehaus.org/manage_email)

* * *

To unsubscribe from this list, please visit:

```
http://xircles.codehaus.org/manage_email

```

---

<div class="post-metadata">

**Author:** ![headius](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/7c8e57/32.png) [@headius](https://www.ruby-forum.com/u/headius)\
**Post date:** [May 23, 2009, 1:47am UTC](https://www.ruby-forum.com/t/ann-ruby2java-0-0-1-released/168623/3 "2009-05-23T01:47:16Z")

</div>

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

> ruby2java version 0.0.1 has been released!
> 
> - [http://kenai.com/projects/ruby2java/pages/Home](http://kenai.com/projects/ruby2java/pages/Home)
> 
> 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

```

---

<div class="post-metadata">

**Author:** ![headius](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/7c8e57/32.png) [@headius](https://www.ruby-forum.com/u/headius)\
**Post date:** [May 23, 2009, 2:24am UTC](https://www.ruby-forum.com/t/ann-ruby2java-0-0-1-released/168623/4 "2009-05-23T02:24:42Z")

</div>

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

```

---

<div class="post-metadata">

**Author:** ![headius](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/7c8e57/32.png) [@headius](https://www.ruby-forum.com/u/headius)\
**Post date:** [May 24, 2009, 9:53pm UTC](https://www.ruby-forum.com/t/ann-ruby2java-0-0-1-released/168623/5 "2009-05-24T21:53:55Z")

</div>

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

```

---

<div class="post-metadata">

**Author:** ![headius](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/7c8e57/32.png) [@headius](https://www.ruby-forum.com/u/headius)\
**Post date:** [May 23, 2009, 2:11am UTC](https://www.ruby-forum.com/t/ann-ruby2java-0-0-1-released/168623/6 "2009-05-23T02:11:51Z")

</div>

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

```

---

<div class="post-metadata">

**Author:** ![headius](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/7c8e57/32.png) [@headius](https://www.ruby-forum.com/u/headius)\
**Post date:** [May 31, 2009, 4:24am UTC](https://www.ruby-forum.com/t/ann-ruby2java-0-0-1-released/168623/7 "2009-05-31T04:24:34Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![headius](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/7c8e57/32.png) [@headius](https://www.ruby-forum.com/u/headius)\
**Post date:** [May 27, 2009, 1:57pm UTC](https://www.ruby-forum.com/t/ann-ruby2java-0-0-1-released/168623/8 "2009-05-27T13:57:45Z")

</div>

Charles Oliver N. wrote:

> ruby2java version 0.0.1 has been released!
> 
> - [http://kenai.com/projects/ruby2java/pages/Home](http://kenai.com/projects/ruby2java/pages/Home)
> 
> 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

---

<div class="post-metadata">

**Author:** ![headius](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/7c8e57/32.png) [@headius](https://www.ruby-forum.com/u/headius)\
**Post date:** [June 2, 2009, 4:18am UTC](https://www.ruby-forum.com/t/ann-ruby2java-0-0-1-released/168623/9 "2009-06-02T04:18:06Z")

</div>

Hi,

On Sun, May 24, 2009 at 3:53 PM, Charles Oliver N.  
[removed\_email\_address@domain.invalid](mailto: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](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](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](http://xircles.codehaus.org/manage_email)

* * *

To unsubscribe from this list, please visit:

```
http://xircles.codehaus.org/manage_email

```

---

<div class="post-metadata">

**Author:** ![headius](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/7c8e57/32.png) [@headius](https://www.ruby-forum.com/u/headius)\
**Post date:** [June 2, 2009, 6:58am UTC](https://www.ruby-forum.com/t/ann-ruby2java-0-0-1-released/168623/10 "2009-06-02T06:58:13Z")

</div>

Charles Oliver N. wrote:

> ruby2java version 0.0.1 has been released!
> 
> - [http://kenai.com/projects/ruby2java/pages/Home](http://kenai.com/projects/ruby2java/pages/Home)

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

> **[Adding Type Checking to Ruby - Code Commit](http://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
