Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: JRuby 1.6RC1
-
Fix Version/s: JRuby 1.6RC2
-
Component/s: Compiler
-
Labels:None
-
Environment:The TorqueBox rspec/arquillian tests executed on OSX
-
Number of attachments :
Description
With jruby 1.5.6, RubyClass#reify (via become_java!) worked to create bonafide java classes.
In 1.6.0.RC1 an NPE now results from executing the same code path.
java.lang.NullPointerException org.jruby.RubyClass.reify(RubyClass.java:1169) org.jruby.RubyClass.reify(RubyClass.java:1146) org.jruby.RubyJRuby$JRubyClassExtensions.become_java_bang(RubyJRuby.java:488) org.jruby.RubyJRuby$JRubyClassExtensions$s_method_0_1$RUBYINVOKER$become_java_bang.call(org/jruby/RubyJRuby$JRubyClassExtensions$s_method_0_1$RUBYINVOKER$become_java_bang.gen:65535) org.jruby.internal.runtime.methods.JavaMethod$JavaMethodN.call(JavaMethod.java:626) org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:196) org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:262) org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:105) org.jruby.ast.CallNoArgNode.interpret(CallNoArgNode.java:61)
The code calling become_java! is within our RSpec/Arquillian integration, which requires Java classes with static methods that have annotations attached.
We take an RSpec ExampleGroup, synthesize some static methods, annotate, call become_java! and hand to Arquillian.
Our code is here, line 65 being the code that now fails under 1.6.0.RC1 with the above NPE:
https://github.com/torquebox/torquebox/blob/master/integration-tests/spec/container.rb
This appears to occur when you call become_java! upon a Ruby class that subclasses another Ruby class.
If become_java! is called on the hierarchy from the root to the subclass leaf, it succeeds. If the first become_java! invocation occurs on a leaf before being called on the superclass, the above exception occurs.
require 'jruby/core_ext' require 'java' class MyBaseThing end #MyBaseThing.become_java! class MySubThing < MyBaseThing def self.static_method() end class << self add_method_signature( "static_method", [java.util.HashMap] ) add_method_annotation( "static_method", java.lang.Deprecated=> {} ) end end MySubThing.become_java!The last line of the code above will fail while line 7 (MyBaseThing.become_java!) is commented out. Uncomment that line, and MySubThing.become_java! will succeed.
It would see RubyClass.reify should work its way down from the root of the hierachy to the leaf.