Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java_signature does not work on "self.foo" methods #3203

Closed
rtyler opened this issue Aug 1, 2015 · 1 comment
Closed

java_signature does not work on "self.foo" methods #3203

rtyler opened this issue Aug 1, 2015 · 1 comment

Comments

@rtyler
Copy link

rtyler commented Aug 1, 2015

[1] pry(main)> class NormalClass
[1] pry(main)*   java_signature "java.lang.String hello"
[1] pry(main)*   def self.hello
[1] pry(main)*     return 'hi'
[1] pry(main)*   end  
[1] pry(main)* end  
=> nil
[2] pry(main)> require 'jruby/core_ext'
=> true   
[4] pry(main)> NormalClass.become_java!.declared_methods
=> java.lang.reflect.Method[public static void rubyobj.NormalClass.clinit(org.jruby.Ruby,org.jruby.RubyClass), public static org.jruby.runtime.builtin.IRubyObject rubyobj.NormalClass.hello()]@55634720
[5] pry(main)> 

NOTE the method has a return type of IRubyObject instead of java.lang.String

When using class << self the signature is correct however

[7] pry(main)> class Foo
[7] pry(main)*   class << self
[7] pry(main)*     java_signature 'java.lang.String hello'
[7] pry(main)*     def hello()
[7] pry(main)*       return 'ohai'
[7] pry(main)*     end  
[7] pry(main)*   end  
[7] pry(main)* end  
Java::OrgJrubyParser::ParserSyntaxException: syntax error, unexpected end-of-file
from java.lang.reflect.Method.invoke(java/lang/reflect/Method.java:497)
[8] pry(main)> 
➜  ~  pry
[1] pry(main)> class Foo
[1] pry(main)*   class << self
[1] pry(main)*     java_signature 'java.lang.String hello'
[1] pry(main)*     def hello()
[1] pry(main)*       return 'lol'
[1] pry(main)*     end  
[1] pry(main)*   end  
[1] pry(main)* end  
=> nil
[2] pry(main)> require 'jruby/core_ext'
=> true
[3] pry(main)> Foo.become_java!.declared_methods
=> java.lang.reflect.Method[public static void rubyobj.Foo.clinit(org.jruby.Ruby,org.jruby.RubyClass), public static org.jruby.runtime.builtin.IRubyObject rubyobj.Foo.hello()]@26e356f0
[4] pry(main)> 
@kares
Copy link
Member

kares commented Dec 18, 2015

believe this is fine as it is - behaves the same as similar Ruby "annotation" methods e.g. public ...

@kares kares added this to the Won't Fix milestone Jan 11, 2016
@enebo enebo closed this as completed May 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants