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

Closure conversion doesn't play nice with some interface method names #2392

Closed
rjnienaber opened this issue Dec 30, 2014 · 1 comment
Closed

Comments

@rjnienaber
Copy link

From: http://jira.codehaus.org/browse/JRUBY-5294. Not working in JRuby 1.7.18 and JRuby 9000.

Define a Java interface with a single-argument method named 'exec'. Define a Java class that defines a method that uses instances of that interface as a callback. Use JRuby to invoke the class's method using a block as its argument, attempting to take advantage of the closure conversion feature of JRuby.

When the callback is invoked by the Java method, rather than running the code defined in the block, the system attempts to coerce the argument to a String and Kernel.exec it. The same issue happens for any Kernel.* method name I've tried.

I'm a complete Ruby/JRuby noob, but based on a quick perusal of the code, it looks like closure conversion is implemented by defining method_missing on a fresh new RubyClass, and that any methods already defined for Ruby's Object are going to be invoked ahead of any interface methods with the same names. This behavior may be completely expected, then; if so, I apologize for the trouble.

I've attached example code illustrating the problem.

@kares
Copy link
Member

kares commented May 23, 2017

has has been resolved in JRuny 9K (won't be fixed in 1.7.x)

@kares kares closed this as completed May 23, 2017
@kares kares added this to the Invalid or Duplicate milestone May 23, 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