Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: JRuby 1.6.4
-
Fix Version/s: JRuby 1.7.0.pre2
-
Component/s: None
-
Labels:None
-
Environment:notes from me:
* I am unsure of the constantine/constants etc actually included w/ JR 1.6.5.
-
Number of attachments :
Description
AFFECTED VERSION
Before i get started, i am actually complaining about 1.6.5 (five) which is officially available from jruby.org but Affected versions only goes up to 1.6.4
REAL DESCRIPTION
I am getting a NPE using an embedded JRuby which is loaded from a non system ClassLoader.
The stack trace below demonstrates the problem (note i have kept the interesting frames).
java.lang.NullPointerException
at com.kenai.constantine.Platform.getPackageName(Platform.java:39)
at com.kenai.constantine.ConstantSet.getEnumClass(ConstantSet.java:84)
at com.kenai.constantine.ConstantSet.getConstantSet(ConstantSet.java:60)
at com.kenai.constantine.platform.ConstantResolver.getConstants(ConstantResolver.java:181)
at com.kenai.constantine.platform.ConstantResolver.getConstant(ConstantResolver.java:102)
at com.kenai.constantine.platform.ConstantResolver.intValue(ConstantResolver.java:146)
at com.kenai.constantine.platform.OpenFlags.value(OpenFlags.java:28)
at org.jruby.RubyFile.createFileClass(RubyFile.java:265)
at org.jruby.Ruby.initCore(Ruby.java:1269)
at org.jruby.Ruby.bootstrap(Ruby.java:1099)
at org.jruby.Ruby.init(Ruby.java:1071)
at org.jruby.Ruby.newInstance(Ruby.java:186)
at org.jruby.embed.internal.LocalContext.getThreadSafeRuntime(LocalContext.java:69)
at org.jruby.embed.internal.ThreadSafeLocalContextProvider.getRuntime(ThreadSafeLocalContextProvider.java:61)
at org.jruby.embed.ScriptingContainer.terminate(ScriptingContainer.java:1721)
Sorry i cannot comment on the Constantine that is actually used as jruby-complete.jar does not include C source. Note being uninformed i could not easily determine which version of C is actually bundled.
My guess is that java.lang.Package.getPackage(String) returns null because the class is not coming from the System ClassLoader.
The easy fix was to grab a fixed C from
https://github.com/jnr/jnr-constants.
after which everything just works.
This was previously discussed at http://www.ruby-forum.com/topic/2321320.
Thanks Wayne for the fix and everyone else for JR.
I have confirmed this does not affect 1.7.0 preview 2, btw. But it does affect up to 1.6.7.