[JIRA] Assigned: (RUBY2JAVA-1) ruby2java needs to cast return values to java.lang.String

  • From: "automatthew (JIRA)" <jira-no-reply@kenai.com>
  • To: issues@ruby2java.kenai.com
  • Subject: [JIRA] Assigned: (RUBY2JAVA-1) ruby2java needs to cast return values to java.lang.String
  • Date: Tue, 24 Nov 2009 18:53:28 +0000 (GMT+00:00)


     [ 
http://kenai.com/jira/browse/RUBY2JAVA-1?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

automatthew reassigned RUBY2JAVA-1:
-----------------------------------

    Assignee: automatthew

> ruby2java needs to cast return values to java.lang.String
> ---------------------------------------------------------
>
>                 Key: RUBY2JAVA-1
>                 URL: http://kenai.com/jira/browse/RUBY2JAVA-1
>             Project: ruby2java
>          Issue Type: Bug
>            Reporter: headius
>            Assignee: automatthew
>
> (originally filed as a JRuby bug by Ian Dees)
> Given the following Ruby file:
> {code:title=sample.rb}
> Sample
>   def bar
>     "Hello from Ruby"
>   end
>   if defined? Ruby2Java
>     signature :bar, [] => java.lang.String
>   end
> end
> {code}
> ... and the following Java file:
> {code:title=SampleTest.java}
> public class SampleTest {
>     public static void main(String args[]) {
>         Sample s = new Sample();
>     }
> }
> {code}
> When you run:
> {noformat}
> ruby2java Sample sample.rb
> java -cp jruby.jar:. SampleTest
> {noformat}
> The following error occurs:
> {noformat}
> Exception in thread "main" java.lang.VerifyError: (class: Sample, method: 
> bar signature: ()Ljava/lang/String;) Illegal type in constant pool
>       at SampleTest.main(SampleTest.java:3)
> {noformat}
> Per Charlie, here's the {{bar}} method, disassembled:
> {noformat}
> public java.lang.String bar();
>   Code:
>    Stack=4, Locals=2, Args_size=1
>    0: aload_0
>    1: dup
>    2: invokeinterface #52,  1; //InterfaceMethod 
> org/jruby/runtime/builtin/IRubyObject.getRuntime:()Lorg/jruby/Ruby;
>    7: dup
>    8: astore_1
>    9: invokevirtual   #56; //Method 
> org/jruby/Ruby.getCurrentContext:()Lorg/jruby/runtime/ThreadContext;
>    12:        ldc     #57; //String bar
>    14:        iconst_0
>    15:        anewarray       #49; //class 
> org/jruby/runtime/builtin/IRubyObject
>    18:        invokevirtual   #63; //Method 
> org/jruby/RubyBasicObject.callMethod:(Lorg/jruby/runtime/ThreadContext;Ljava/lang/String;[Lorg/jruby/runtime/builtin/IRubyObject;)Lorg/jruby/runtime/builtin/IRubyObject;
>    21:        ldc     #65; //class java/lang/String
>    23:        invokestatic    #71; //Method 
> org/jruby/javasupport/JavaUtil.convertRubyToJava:(Lorg/jruby/runtime/builtin/IRubyObject;Ljava/lang/Class;)Ljava/lang/Object;
>    26:        areturn
> {noformat}
> Charlie points out that the Ruby string should be cast to a 
> java.lang.String before returning.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://kenai.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


[JIRA] Assigned: (RUBY2JAVA-1) ruby2java needs to cast return values to java.lang.String

automatthew (JIRA) 11/24/2009
  • Mysql
  • Glassfish
  • Jruby
  • Rails
  • Nblogo
Terms of Use; Privacy Policy;
© 2010, Oracle Corporation and/or its affiliates
(revision 20120518.3c65429)
 
 
Close
loading
Please Confirm
Close