Forum: JRuby [ANN] ruby2java 0.0.1 Released

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.
Charles Oliver N. (Guest)
on 2009-05-23 03:01
(Received via mailing list)
ruby2java version 0.0.1 has been released!

* <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>

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

    http://xircles.codehaus.org/manage_email
Charles Oliver N. (Guest)
on 2009-05-23 03:26
(Received via mailing list)
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
Lothar Werzinger (Guest)
on 2009-05-23 03:47
(Received via mailing list)
On Friday 22 May 2009, Charles Oliver N. wrote:
> ruby2java version 0.0.1 has been released!
>
> * <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
Charles Oliver N. (Guest)
on 2009-05-23 04:11
(Received via mailing list)
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
Lothar Werzinger (Guest)
on 2009-05-23 04:24
(Received via mailing list)
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
Charles Oliver N. (Guest)
on 2009-05-24 23:53
(Received via mailing list)
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
Roger P. (Guest)
on 2009-05-27 15:57
Charles Oliver N. wrote:
> ruby2java version 0.0.1 has been released!
>
> * <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
Roger P. (Guest)
on 2009-05-31 06:24
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
Yoko H. (Guest)
on 2009-06-02 06:18
(Received via mailing list)
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/sour...).
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
Roger P. (Guest)
on 2009-06-02 08:58
Charles Oliver N. wrote:
> ruby2java version 0.0.1 has been released!
>
> * <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

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

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
This topic is locked and can not be replied to.