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

interface implementation example does not work with JRuby 9000 series #4573

Closed
botchniaque opened this issue Apr 25, 2017 · 2 comments
Closed

Comments

@botchniaque
Copy link

Environment

Provide at least:

  • JRuby version 9.1.8.0
  • Operating system and platform: Ubuntu 16.10 oracle JVM 1.8.0_181

Other relevant info you may wish to add:

  • Installed or activated gems: None
  • Application/framework version None
  • Environment variables: None

Expected Behavior

Running JRuby embed example on how to cast JRuby code to java interface should work as described.

Actual Behavior

Running the example with JRuby 9.1.8.0 throws an exception

org.jruby.exceptions.RaiseException: (TypeError) can't define singleton
	at org.jruby.RubyModule.extend_object(org/jruby/RubyModule.java:2578)

Using JRuby 1.7.26 works fine.

Runnable example can be found here https://github.com/botchniaque/embed-jruby-test

@enebo
Copy link
Member

enebo commented May 15, 2017

fwiw, I think that FluidForce part of the example is a bad example and one we do not want anyone to use. So someone should consider a better mechanism for showing the .getInstance part of our embedding API.

This is not technically a bug because in Ruby 2.x 'def' will now return a Symbol of the method being added. Prior to Ruby 2, def would return nil. So in this example in JRuby 1.7.x we get back 'null' which is passed to getInstance which then uses self so the example works. In JRuby 9.1.x we get back :getFluidForce and then try to use the symbol to get an instance of the FluidForce interface (which of course a symbol does not implement that interface). So embedding API is working as expected but new Ruby semantics broke the example.

II will update the documentation to better illustrate what is happening (add self at bottom of fluid_force.rb) but I find this example to be a bit confusing with .getInstance.

@enebo enebo closed this as completed May 15, 2017
@botchniaque
Copy link
Author

@enebo thanks for clarifying. I will stick to container.callMethod in this case and implement the interface myself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants