Re: Trying to get jruby classes/methods into java code. (JRuby applet, OGL)

View: New views
5 Messages — Rating Filter:   Alert me  

Parent Message unknown Re: Trying to get jruby classes/methods into java code. (JRuby applet, OGL)

by Rob . :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I've had the same problem with jrubyc compiled classes that you
mentioned in point (3). Decompiling shows methods like this in the
Java class:

public class MyClass extends AbstractScript {...

 public IRubyObject initialize__5(ThreadContext threadcontext,
                                  IRubyObject irubyobject,
                                  IRubyObject[] irubyobjects, Block
block) {... }

 public IRubyObject method1__6(ThreadContext threadcontext,
                               IRubyObject irubyobject,
                               IRubyObject[] irubyobjects, Block block) {... }


I was expecting:

public class MyClass extends RubyObject {
 public MyClass(Object arg1, Object arg2) {... }

 public Object method1(Object arg1) {... }


-Rob

On Tue, Apr 8, 2008 at 11:54 PM, sikanrong <sikanrong@...> wrote:

>
>  Hey guys. So, I'm not new to Java, and I'm really not new to Ruby, but I'm a
>  complete JRuby beginner somehow :)
>
>  I've read every tutorial and wiki page on the subject, but I keep hitting
>  walls. Here's the deal: I'm trying to get OGL stuff into an Applet using
>  JRuby. I know, I could've picked something easier, but I really think this
>  would be cool if i could finish it! So, I've got the JOGL jars in the
>  appropriate places, and I have a helloworld.rb script that creates exactly
>  what I want in a JFrame. Now I need to take the same functionality and port
>  it to an applet. I also have an applet that's doing what I want in pure
>  Java. What I want to do is define a ruby class which 'implements' the java
>  class GLEventListener, (via 'include'). Then, SOMEHOW, I want to instantiate
>  an object of that class in Java and plug it in to the applet.
>
>  So far, i just can't pull the object out of ruby and get it into java. I've
>  tried everything under the sun, and by that I mean
>
>  1) making a java wrapper for the class I want to wrap in ruby (a-la
>  jrubywiki getting started demo source). Didn't work.
>
>  2) found a GREAT and almost completely un-documented class called
>  JRubyApplet. This failed out too, kindof. It did eval the script properly,
>  but when I tried to create a GLEventListener in ruby (which works fine when
>  just running it in JRuby) i get a 'not visible to class loader' error. Why??
>  It's in the classpath, and if JRubyApplet worked it would be the absolute
>  best way for me to do this
>
>  3) Tried using jrubyc (JRuby compiler). Besides the fact that this didn't
>  work with what I'm trying to do, it is just plain really freaking cool to be
>  able to compile ruby script into Java Byte code. What did work is the
>  compiler. What did NOT work is calling methods or classes defined inside
>  java after importing the class to a Java script. Like, i could compile and
>  import (and even instantiate) an object of ruby.MyRubyWrapper, but then I
>  just get 'symbol not defined' errors when trying to call the methods I
>  defined in ruby. This was especially confusing to me, because in the wiki
>  documentation on the JRuby compiler you (Nutter) said that basically
>  file-level methods and classes were all available to the Java object as java
>  methods. What gives?? HELP!!
>
>  Anyway, if this is Nutter himself, I just met you in Prague! (I was the only
>  one with dreadlocks), What's up dude!!
>
>  --
>  View this message in context: http://www.nabble.com/Trying-to-get-jruby-classes-methods-into-java-code.-%28JRuby-applet%2C-OGL%29-tp16575797p16575797.html
>  Sent from the JRuby - User mailing list archive at Nabble.com.
>
>
>  ---------------------------------------------------------------------
>  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



Re: Trying to get jruby classes/methods into java code. (JRuby applet, OGL)

by Vladimir Sizikov-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Guys,

Even though the jrubyc does compile the .rb biles into class format,
those classes cannot be used outside of JRuby's runtime.

You could still 'require' such files in your JRuby scripts, and they
will be used as if they are *.rb files. But they can't be put into
pure-java application without JRuby support.

Thanks,
  --Vladimir

On Wed, Apr 9, 2008 at 4:09 PM, Rob . <rob.02004@...> wrote:

> I've had the same problem with jrubyc compiled classes that you
>  mentioned in point (3). Decompiling shows methods like this in the
>  Java class:
>
>  public class MyClass extends AbstractScript {...
>
>   public IRubyObject initialize__5(ThreadContext threadcontext,
>                                   IRubyObject irubyobject,
>                                   IRubyObject[] irubyobjects, Block
>  block) {... }
>
>   public IRubyObject method1__6(ThreadContext threadcontext,
>                                IRubyObject irubyobject,
>                                IRubyObject[] irubyobjects, Block block) {... }
>
>
>  I was expecting:
>
>  public class MyClass extends RubyObject {
>   public MyClass(Object arg1, Object arg2) {... }
>
>   public Object method1(Object arg1) {... }
>
>
>  -Rob
>
>
>
>  On Tue, Apr 8, 2008 at 11:54 PM, sikanrong <sikanrong@...> wrote:
>  >
>  >  Hey guys. So, I'm not new to Java, and I'm really not new to Ruby, but I'm a
>  >  complete JRuby beginner somehow :)
>  >
>  >  I've read every tutorial and wiki page on the subject, but I keep hitting
>  >  walls. Here's the deal: I'm trying to get OGL stuff into an Applet using
>  >  JRuby. I know, I could've picked something easier, but I really think this
>  >  would be cool if i could finish it! So, I've got the JOGL jars in the
>  >  appropriate places, and I have a helloworld.rb script that creates exactly
>  >  what I want in a JFrame. Now I need to take the same functionality and port
>  >  it to an applet. I also have an applet that's doing what I want in pure
>  >  Java. What I want to do is define a ruby class which 'implements' the java
>  >  class GLEventListener, (via 'include'). Then, SOMEHOW, I want to instantiate
>  >  an object of that class in Java and plug it in to the applet.
>  >
>  >  So far, i just can't pull the object out of ruby and get it into java. I've
>  >  tried everything under the sun, and by that I mean
>  >
>  >  1) making a java wrapper for the class I want to wrap in ruby (a-la
>  >  jrubywiki getting started demo source). Didn't work.
>  >
>  >  2) found a GREAT and almost completely un-documented class called
>  >  JRubyApplet. This failed out too, kindof. It did eval the script properly,
>  >  but when I tried to create a GLEventListener in ruby (which works fine when
>  >  just running it in JRuby) i get a 'not visible to class loader' error. Why??
>  >  It's in the classpath, and if JRubyApplet worked it would be the absolute
>  >  best way for me to do this
>  >
>  >  3) Tried using jrubyc (JRuby compiler). Besides the fact that this didn't
>  >  work with what I'm trying to do, it is just plain really freaking cool to be
>  >  able to compile ruby script into Java Byte code. What did work is the
>  >  compiler. What did NOT work is calling methods or classes defined inside
>  >  java after importing the class to a Java script. Like, i could compile and
>  >  import (and even instantiate) an object of ruby.MyRubyWrapper, but then I
>  >  just get 'symbol not defined' errors when trying to call the methods I
>  >  defined in ruby. This was especially confusing to me, because in the wiki
>  >  documentation on the JRuby compiler you (Nutter) said that basically
>  >  file-level methods and classes were all available to the Java object as java
>  >  methods. What gives?? HELP!!
>  >
>  >  Anyway, if this is Nutter himself, I just met you in Prague! (I was the only
>  >  one with dreadlocks), What's up dude!!
>  >
>  >  --
>  >  View this message in context: http://www.nabble.com/Trying-to-get-jruby-classes-methods-into-java-code.-%28JRuby-applet%2C-OGL%29-tp16575797p16575797.html
>  >  Sent from the JRuby - User mailing list archive at Nabble.com.
>  >
>  >
>  >  ---------------------------------------------------------------------
>  >  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
>
>
>

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

    http://xircles.codehaus.org/manage_email



Re: Trying to get jruby classes/methods into java code. (JRuby applet, OGL)

by Rob . :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Headius' post about 'Compiler #2', made it sound like this was going
to be possible (http://headius.blogspot.com/2007/09/compiler-is-complete.html):

"Compiler #2 will basically take a Ruby class in a given file (or
multiple Ruby classes, if you so choose) and generate a normal Java
type. This type will look and feel like any other Java class:

    * You can instantiate it with a normal new MyClass(arg1, arg2)
from Java code
    * You can invoke all its methods with normal Java invocations
    * You can extend it with your own Java classes"

Is the JRuby 1.1 compiler not the 'Compiler #2'?

-Rob



On Wed, Apr 9, 2008 at 3:23 PM, Vladimir Sizikov <vsizikov@...> wrote:

> Guys,
>
>  Even though the jrubyc does compile the .rb biles into class format,
>  those classes cannot be used outside of JRuby's runtime.
>
>  You could still 'require' such files in your JRuby scripts, and they
>  will be used as if they are *.rb files. But they can't be put into
>  pure-java application without JRuby support.
>
>  Thanks,
>   --Vladimir
>
>
>
>  On Wed, Apr 9, 2008 at 4:09 PM, Rob . <rob.02004@...> wrote:
>  > I've had the same problem with jrubyc compiled classes that you
>  >  mentioned in point (3). Decompiling shows methods like this in the
>  >  Java class:
>  >
>  >  public class MyClass extends AbstractScript {...
>  >
>  >   public IRubyObject initialize__5(ThreadContext threadcontext,
>  >                                   IRubyObject irubyobject,
>  >                                   IRubyObject[] irubyobjects, Block
>  >  block) {... }
>  >
>  >   public IRubyObject method1__6(ThreadContext threadcontext,
>  >                                IRubyObject irubyobject,
>  >                                IRubyObject[] irubyobjects, Block block) {... }
>  >
>  >
>  >  I was expecting:
>  >
>  >  public class MyClass extends RubyObject {
>  >   public MyClass(Object arg1, Object arg2) {... }
>  >
>  >   public Object method1(Object arg1) {... }
>  >
>  >
>  >  -Rob
>  >
>  >
>  >
>  >  On Tue, Apr 8, 2008 at 11:54 PM, sikanrong <sikanrong@...> wrote:
>  >  >
>  >  >  Hey guys. So, I'm not new to Java, and I'm really not new to Ruby, but I'm a
>  >  >  complete JRuby beginner somehow :)
>  >  >
>  >  >  I've read every tutorial and wiki page on the subject, but I keep hitting
>  >  >  walls. Here's the deal: I'm trying to get OGL stuff into an Applet using
>  >  >  JRuby. I know, I could've picked something easier, but I really think this
>  >  >  would be cool if i could finish it! So, I've got the JOGL jars in the
>  >  >  appropriate places, and I have a helloworld.rb script that creates exactly
>  >  >  what I want in a JFrame. Now I need to take the same functionality and port
>  >  >  it to an applet. I also have an applet that's doing what I want in pure
>  >  >  Java. What I want to do is define a ruby class which 'implements' the java
>  >  >  class GLEventListener, (via 'include'). Then, SOMEHOW, I want to instantiate
>  >  >  an object of that class in Java and plug it in to the applet.
>  >  >
>  >  >  So far, i just can't pull the object out of ruby and get it into java. I've
>  >  >  tried everything under the sun, and by that I mean
>  >  >
>  >  >  1) making a java wrapper for the class I want to wrap in ruby (a-la
>  >  >  jrubywiki getting started demo source). Didn't work.
>  >  >
>  >  >  2) found a GREAT and almost completely un-documented class called
>  >  >  JRubyApplet. This failed out too, kindof. It did eval the script properly,
>  >  >  but when I tried to create a GLEventListener in ruby (which works fine when
>  >  >  just running it in JRuby) i get a 'not visible to class loader' error. Why??
>  >  >  It's in the classpath, and if JRubyApplet worked it would be the absolute
>  >  >  best way for me to do this
>  >  >
>  >  >  3) Tried using jrubyc (JRuby compiler). Besides the fact that this didn't
>  >  >  work with what I'm trying to do, it is just plain really freaking cool to be
>  >  >  able to compile ruby script into Java Byte code. What did work is the
>  >  >  compiler. What did NOT work is calling methods or classes defined inside
>  >  >  java after importing the class to a Java script. Like, i could compile and
>  >  >  import (and even instantiate) an object of ruby.MyRubyWrapper, but then I
>  >  >  just get 'symbol not defined' errors when trying to call the methods I
>  >  >  defined in ruby. This was especially confusing to me, because in the wiki
>  >  >  documentation on the JRuby compiler you (Nutter) said that basically
>  >  >  file-level methods and classes were all available to the Java object as java
>  >  >  methods. What gives?? HELP!!
>  >  >
>  >  >  Anyway, if this is Nutter himself, I just met you in Prague! (I was the only
>  >  >  one with dreadlocks), What's up dude!!
>  >  >
>  >  >  --
>  >  >  View this message in context: http://www.nabble.com/Trying-to-get-jruby-classes-methods-into-java-code.-%28JRuby-applet%2C-OGL%29-tp16575797p16575797.html
>  >  >  Sent from the JRuby - User mailing list archive at Nabble.com.
>  >  >
>  >  >
>  >  >  ---------------------------------------------------------------------
>  >  >  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
>  >
>  >
>  >
>
>  ---------------------------------------------------------------------
>  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



Re: Trying to get jruby classes/methods into java code. (JRuby applet, OGL)

by Charles Oliver Nutter-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Rob . wrote:

> Headius' post about 'Compiler #2', made it sound like this was going
> to be possible (http://headius.blogspot.com/2007/09/compiler-is-complete.html):
>
> "Compiler #2 will basically take a Ruby class in a given file (or
> multiple Ruby classes, if you so choose) and generate a normal Java
> type. This type will look and feel like any other Java class:
>
>     * You can instantiate it with a normal new MyClass(arg1, arg2)
> from Java code
>     * You can invoke all its methods with normal Java invocations
>     * You can extend it with your own Java classes"
>
> Is the JRuby 1.1 compiler not the 'Compiler #2'?

It is not. Compiler #2 will still happen, but it was deferred to after
the 1.1 release since it requires a lot more ingenuity and doesn't
really improve regular Ruby compatibility or performance (1.1 was mostly
focused on finishing Ruby support). But I have been wanting this
capability more and more myself, so this work is probably going to start
soon.

The biggest thing that would help is coming up with some ideas about how
to map Ruby scripts to Java code. For example, it would not be allowed
to have conditional method definitions or method calls in the class
body, except in very specific cases, since we must provide exactly one
complete set of signatures in the Java type.

Other thoughts on this? How should modules map to Java code? Should they
map at all?

What represents packaging?

- Charlie

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

    http://xircles.codehaus.org/manage_email



Re: Trying to get jruby classes/methods into java code. (JRuby applet, OGL)

by Alexandru Popescu ☀ :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Wed, Apr 9, 2008 at 6:57 PM, Charles Oliver Nutter
<charles.nutter@...> wrote:

> Rob . wrote:
>
> > Headius' post about 'Compiler #2', made it sound like this was going
> > to be possible
> (http://headius.blogspot.com/2007/09/compiler-is-complete.html):
> >
> > "Compiler #2 will basically take a Ruby class in a given file (or
> > multiple Ruby classes, if you so choose) and generate a normal Java
> > type. This type will look and feel like any other Java class:
> >
> >    * You can instantiate it with a normal new MyClass(arg1, arg2)
> > from Java code
> >    * You can invoke all its methods with normal Java invocations
> >    * You can extend it with your own Java classes"
> >
> > Is the JRuby 1.1 compiler not the 'Compiler #2'?
> >
>
>  It is not. Compiler #2 will still happen, but it was deferred to after the
> 1.1 release since it requires a lot more ingenuity and doesn't really
> improve regular Ruby compatibility or performance (1.1 was mostly focused on
> finishing Ruby support). But I have been wanting this capability more and
> more myself, so this work is probably going to start soon.
>
>  The biggest thing that would help is coming up with some ideas about how to
> map Ruby scripts to Java code. For example, it would not be allowed to have
> conditional method definitions or method calls in the class body, except in
> very specific cases, since we must provide exactly one complete set of
> signatures in the Java type.
>
>  Other thoughts on this? How should modules map to Java code? Should they
> map at all?
>
>  What represents packaging?
>
>  - Charlie
>

Charlie I think a good start would be if you could formalize the above
list in a separate thread so others have the chance to jump in and
provide their opinions. I would be glad to look into this (and
remember the bits of Ruby I've probably forgot lately).

cheers,

./alex
--
.w( the_mindstorm )p.
  Alexandru Popescu

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

    http://xircles.codehaus.org/manage_email