-
-
Notifications
You must be signed in to change notification settings - Fork 925
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
Passing a ruby class as a java.lang.Class into Java land #3454
Comments
unfortunately, java support currently does not go that far - you can not instantiate a Ruby defined class on Java's side as |
Ouch!!! This will force me to write a bunch of messy java-ruby bridges. The lack of this feature basically males impossible to use a bunch of java libraries from ruby. Looking forward to this being implemented. |
You could write your Teste class in Ruby and then your code would work like this:
But I guess it depends what else you are doing as to whether that is valid. |
@kimptoc i get the same error! |
@carlosmrce hmm - worked for me :) . The Ruby Teste class I used was something like this:
|
also, should be able to "over-come" the limitation by forcing a Java-class to be generated for the Ruby one: class TesteJob
include Job
def teste
puts "123456"
end
end
teste_jclass = TesteJob.become_java!
Teste.new.executaJob( teste_jclass )
# teste_jclass.newInstance works fine |
become_java! - interesting, thanks for that. https://github.com/jruby/jruby/wiki/GeneratingJavaClasses |
Thanks a lot for the tip @kares !!! Solved the problem for me! |
still would be useful to get this working out-of-the box (without an explicit |
@kares I got another error C:>jruby teste.rb It breaks on the line 'job.teste();' |
…(closing #3454) ... much less confusing than for user classes to see the nearest reified class in the inheritance hierarchy (without explicitly doing `become_java!`)
I guess the code above is pretty self explaining, i hava a Ruby class that implements a Java interface, and i want to pass that class back to another Java class. However, when a execute the ruby code i get the following error:
Shouldn't this work?
ps: teste_jruby.jar is a jar file i exported with the java code.
Thanks,
Carlos.
The text was updated successfully, but these errors were encountered: