Skip to content

[jruby] fails to start due lookup issue with handles #112

Closed

Description

@kares

Reproducable with an embedded use-case, simply booting JRuby (e.g. in Gradle) and trying to run some RubyGems code.

Cause seems to be same as with jruby/jruby-rack#268

> (LoadError) load error: stringio -- java.lang.ExceptionInInitializerError: null

* Try:
> Run with --info or --debug option to get more log output.
> Get more help at https://help.gradle.org.

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':installAllGems'.
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.lambda$executeIfValid$1(ExecuteActionsTaskExecuter.java:130)
        at org.gradle.internal.Try$Failure.ifSuccessfulOrElse(Try.java:293)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeIfValid(ExecuteActionsTaskExecuter.java:128)
        ...
        at org.gradle.internal.concurrent.AbstractManagedExecutor$1.run(AbstractManagedExecutor.java:48)
Caused by: org.jruby.embed.EvalFailedException: (LoadError) load error: stringio -- java.lang.ExceptionInInitializerError: null
        at org.jruby.embed.internal.EmbedEvalUnitImpl.run(EmbedEvalUnitImpl.java:135)
        at org.jruby.embed.ScriptingContainer.runUnit(ScriptingContainer.java:1296)
        at org.jruby.embed.ScriptingContainer.runScriptlet(ScriptingContainer.java:1289)
        ...
        at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
        at org.gradle.internal.concurrent.AbstractManagedExecutor$1.run(AbstractManagedExecutor.java:48)
Caused by: org.jruby.exceptions.LoadError: (LoadError) load error: stringio -- java.lang.ExceptionInInitializerError: null
        at org.jruby.RubyKernel.require(org/jruby/RubyKernel.java:1187)
        at org.jruby.ext.jruby.JRubyUtilLibrary.load_ext(org/jruby/ext/jruby/JRubyUtilLibrary.java:219)
        at RUBY.<main>(uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/zlib.rb:2)
        at org.jruby.RubyKernel.require(org/jruby/RubyKernel.java:1187)
        at RUBY.require(uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:136)
        at RUBY.initialize(uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/rubygems/package.rb:196)
        at org.jruby.RubyClass.new(org/jruby/RubyClass.java:951)
        at RUBY.new(uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/rubygems/package.rb:161)
        at RUBY.at(uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/rubygems/installer.rb:107)
        at RUBY.<main>(<script>:3)
Caused by: java.lang.ExceptionInInitializerError
        at org.jruby.ext.stringio.StringIO.<clinit>(StringIO.java:1543)
        at org.jruby.ext.stringio.StringIOLibrary.load(StringIOLibrary.java:38)
        at org.jruby.ext.jruby.JRubyUtilLibrary.loadExtension(JRubyUtilLibrary.java:242)
        at org.jruby.ext.jruby.JRubyUtilLibrary.load_ext(JRubyUtilLibrary.java:219)
        at org.jruby.ext.jruby.JRubyUtilLibrary$INVOKER$s$1$0$load_ext.call(JRubyUtilLibrary$INVOKER$s$1$0$load_ext.gen)
        at org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:466)
        at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:244)
        at org.jruby.ir.interpreter.InterpreterEngine.processCall(InterpreterEngine.java:314)
        at org.jruby.ir.interpreter.StartupInterpreterEngine.interpret(StartupInterpreterEngine.java:66)
        at org.jruby.ir.interpreter.Interpreter.INTERPRET_ROOT(Interpreter.java:98)
        at org.jruby.ir.interpreter.Interpreter.execute(Interpreter.java:83)
        at org.jruby.ir.interpreter.Interpreter.execute(Interpreter.java:32)
        at org.jruby.ir.IRTranslator.execute(IRTranslator.java:41)
        at org.jruby.Ruby.runInterpreter(Ruby.java:1269)
        at org.jruby.Ruby.loadFile(Ruby.java:3060)
        at org.jruby.runtime.load.LibrarySearcher$ResourceLibrary.load(LibrarySearcher.java:931)
        at org.jruby.runtime.load.LibrarySearcher$FoundLibrary.load(LibrarySearcher.java:889)
        at org.jruby.runtime.load.LoadService.tryLoadingLibraryOrScript(LoadService.java:674)
        at org.jruby.runtime.load.LoadService.lambda$smartLoadInternal$0(LoadService.java:576)
        at org.jruby.runtime.load.LoadService$RequireLocks.executeAndClearLock(LoadService.java:517)
        at org.jruby.runtime.load.LoadService$RequireLocks.lock(LoadService.java:481)
        at org.jruby.runtime.load.LoadService$RequireLocks.access$300(LoadService.java:436)
        at org.jruby.runtime.load.LoadService.smartLoadInternal(LoadService.java:562)
        at org.jruby.runtime.load.LoadService.require(LoadService.java:423)
        at org.jruby.RubyKernel.requireCommon(RubyKernel.java:1194)
        at org.jruby.RubyKernel.require(RubyKernel.java:1187)
        at org.jruby.RubyKernel$INVOKER$s$1$0$require.call(RubyKernel$INVOKER$s$1$0$require.gen)
        at org.jruby.internal.runtime.methods.JavaMethod$JavaMethodOneOrNBlock.call(JavaMethod.java:423)
        at org.jruby.RubyClass.finvoke(RubyClass.java:822)
        at org.jruby.runtime.Helpers.invoke(Helpers.java:711)
        at org.jruby.RubyBasicObject.callMethod(RubyBasicObject.java:358)
        at org.jruby.ext.zlib.RubyZlib.createZlibModule(RubyZlib.java:159)
        at org.jruby.ext.zlib.ZlibLibrary.load(ZlibLibrary.java:36)
        at org.jruby.ext.jruby.JRubyUtilLibrary.loadExtension(JRubyUtilLibrary.java:242)
        at org.jruby.ext.jruby.JRubyUtilLibrary.load_ext(JRubyUtilLibrary.java:219)
        at org.jruby.ext.jruby.JRubyUtilLibrary$INVOKER$s$1$0$load_ext.call(JRubyUtilLibrary$INVOKER$s$1$0$load_ext.gen)
        at org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:466)
        at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:244)
        at org.jruby.ir.interpreter.InterpreterEngine.processCall(InterpreterEngine.java:314)
        at org.jruby.ir.interpreter.StartupInterpreterEngine.interpret(StartupInterpreterEngine.java:66)
        at org.jruby.ir.interpreter.Interpreter.INTERPRET_ROOT(Interpreter.java:98)
        at org.jruby.ir.interpreter.Interpreter.execute(Interpreter.java:83)
        at org.jruby.ir.interpreter.Interpreter.execute(Interpreter.java:32)
        at org.jruby.ir.IRTranslator.execute(IRTranslator.java:41)
        at org.jruby.Ruby.runInterpreter(Ruby.java:1269)
        at org.jruby.Ruby.loadFile(Ruby.java:3060)
        at org.jruby.runtime.load.LibrarySearcher$ResourceLibrary.load(LibrarySearcher.java:931)
        at org.jruby.runtime.load.LibrarySearcher$FoundLibrary.load(LibrarySearcher.java:889)
        at org.jruby.runtime.load.LoadService.tryLoadingLibraryOrScript(LoadService.java:674)
        at org.jruby.runtime.load.LoadService.lambda$smartLoadInternal$0(LoadService.java:576)
        at org.jruby.runtime.load.LoadService$RequireLocks.executeAndClearLock(LoadService.java:517)
        at org.jruby.runtime.load.LoadService$RequireLocks.lock(LoadService.java:481)
        at org.jruby.runtime.load.LoadService$RequireLocks.access$300(LoadService.java:436)
        at org.jruby.runtime.load.LoadService.smartLoadInternal(LoadService.java:562)
        at org.jruby.runtime.load.LoadService.require(LoadService.java:423)
        at org.jruby.RubyKernel.requireCommon(RubyKernel.java:1194)
        at org.jruby.RubyKernel.require(RubyKernel.java:1187)
        at org.jruby.RubyKernel$INVOKER$s$1$0$require.call(RubyKernel$INVOKER$s$1$0$require.gen)
        at org.jruby.internal.runtime.methods.JavaMethod$JavaMethodOneOrNBlock.call(JavaMethod.java:423)
        at org.jruby.internal.runtime.methods.AliasMethod.call(AliasMethod.java:106)
        at org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:466)
        at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:244)
        at org.jruby.ir.interpreter.InterpreterEngine.processCall(InterpreterEngine.java:314)
        at org.jruby.ir.interpreter.StartupInterpreterEngine.interpret(StartupInterpreterEngine.java:66)
        at org.jruby.ir.interpreter.InterpreterEngine.interpret(InterpreterEngine.java:82)
        at org.jruby.internal.runtime.methods.MixedModeIRMethod.INTERPRET_METHOD(MixedModeIRMethod.java:201)
        at org.jruby.internal.runtime.methods.MixedModeIRMethod.call(MixedModeIRMethod.java:188)
        at org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:220)
        at org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:466)
        at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:244)
        at org.jruby.ir.interpreter.InterpreterEngine.processCall(InterpreterEngine.java:314)
        at org.jruby.ir.interpreter.StartupInterpreterEngine.interpret(StartupInterpreterEngine.java:66)
        at org.jruby.internal.runtime.methods.MixedModeIRMethod.INTERPRET_METHOD(MixedModeIRMethod.java:128)
        at org.jruby.internal.runtime.methods.MixedModeIRMethod.call(MixedModeIRMethod.java:115)
        at org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:446)
        at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:92)
        at org.jruby.RubyClass.newInstance(RubyClass.java:951)
        at org.jruby.RubyClass$INVOKER$i$newInstance.call(RubyClass$INVOKER$i$newInstance.gen)
        at org.jruby.ir.runtime.IRRuntimeHelpers.unresolvedSuper(IRRuntimeHelpers.java:1488)
        at org.jruby.ir.instructions.ClassSuperInstr.interpret(ClassSuperInstr.java:105)
        at org.jruby.ir.interpreter.InterpreterEngine.processCall(InterpreterEngine.java:363)
        at org.jruby.ir.interpreter.StartupInterpreterEngine.interpret(StartupInterpreterEngine.java:66)
        at org.jruby.ir.interpreter.InterpreterEngine.interpret(InterpreterEngine.java:88)
        at org.jruby.internal.runtime.methods.MixedModeIRMethod.INTERPRET_METHOD(MixedModeIRMethod.java:238)
        at org.jruby.internal.runtime.methods.MixedModeIRMethod.call(MixedModeIRMethod.java:225)
        at org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:228)
        at org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:476)
        at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:293)
        at org.jruby.ir.interpreter.InterpreterEngine.processCall(InterpreterEngine.java:324)
        at org.jruby.ir.interpreter.StartupInterpreterEngine.interpret(StartupInterpreterEngine.java:66)
        at org.jruby.ir.interpreter.InterpreterEngine.interpret(InterpreterEngine.java:88)
        at org.jruby.internal.runtime.methods.MixedModeIRMethod.INTERPRET_METHOD(MixedModeIRMethod.java:238)
        at org.jruby.internal.runtime.methods.MixedModeIRMethod.call(MixedModeIRMethod.java:225)
        at org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:228)
        at org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:476)
        at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:293)
        at org.jruby.ir.interpreter.InterpreterEngine.processCall(InterpreterEngine.java:324)
        at org.jruby.ir.interpreter.StartupInterpreterEngine.interpret(StartupInterpreterEngine.java:66)
        at org.jruby.ir.interpreter.Interpreter.INTERPRET_ROOT(Interpreter.java:98)
        at org.jruby.ir.interpreter.Interpreter.execute(Interpreter.java:83)
        at org.jruby.ir.interpreter.Interpreter.execute(Interpreter.java:32)
        at org.jruby.ir.IRTranslator.execute(IRTranslator.java:41)
        at org.jruby.Ruby.runInterpreter(Ruby.java:1269)
        at org.jruby.Ruby.runInterpreter(Ruby.java:1299)
        at org.jruby.embed.internal.EmbedEvalUnitImpl.run(EmbedEvalUnitImpl.java:120)
        at org.jruby.embed.ScriptingContainer.runUnit(ScriptingContainer.java:1296)
        at org.jruby.embed.ScriptingContainer.runScriptlet(ScriptingContainer.java:1289)
        at fi.relex.gradle.tasks.InstallAllGemsTask.install(InstallAllGemsTask.kt:60)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:125)
        at org.gradle.api.internal.project.taskfactory.StandardTaskAction.doExecute(StandardTaskAction.java:58)
        at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:51)
        at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:29)
        at org.gradle.api.internal.tasks.execution.TaskExecution$3.run(TaskExecution.java:244)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:29)
        ...
        at org.gradle.internal.concurrent.AbstractManagedExecutor$1.run(AbstractManagedExecutor.java:48)
Caused by: java.lang.IllegalAccessException: no such method: org.jruby.RubyString.cat19(RubyString)RubyString/invokeVirtual
        at org.jruby.ext.stringio.StringIO.<clinit>(StringIO.java:1539)
        ... 262 more
Caused by: java.lang.LinkageError: loader constraint violation: when resolving method 'org.jruby.RubyString org.jruby.RubyString.cat19(org.jruby.RubyString)' the class loader 'bootstrap' of the current class, java/lang/Object, and the class loader org.gradle.internal.classloader.VisitableURLClassLoader$InstrumentingVisitableURLClassLoader @2f3f854c for the method's defining class, org/jruby/RubyString, have different Class objects for the type org/jruby/RubyString used in the signature (java.lang.Object is in module java.base of loader 'bootstrap'; org.jruby.RubyString is in unnamed module of loader org.gradle.internal.classloader.VisitableURLClassLoader$InstrumentingVisitableURLClassLoader @2f3f854c, parent loader org.gradle.internal.classloader.VisitableURLClassLoader$InstrumentingVisitableURLClassLoader @735d1ef5)
        ... 263 more

Activity

  1. headius commented on Feb 11, 2025

    @headius
    Contributor

    Hmm that should be falling back on a different version of the method. I'll look into it.

  2. headius commented on Feb 11, 2025

    @headius
    Contributor

    Ah yeah this stupid publicLookup vs lookup thing again. I don't understand why the former seems to have so much trouble with classloaders.

    I'll push a PR and you can confirm it @kares.

  3. added a commit that references this issue on Feb 11, 2025
    769e86e
  4. headius commented on Feb 11, 2025

    @headius
    Contributor

    @kares Fix is in #113 and I double-checked that all those methods exist and the handles match signature etc.

  5. kares commented on Feb 12, 2025

    @kares
    ContributorAuthor

    LGTM, thanks.

  6. added a commit that references this issue on Feb 13, 2025
    98aceb0
  7. added a commit that references this issue on Feb 19, 2025
    8fda2d7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions