Skip to content

JRuby, "NoMethodError: undefined method `current' for Java::JavaLang::Thread:Class" #1

@miura

Description

@miura

Not sure if this is the right place to raise this issue as titled, but here you go.

The line causing this error is within jruby-stdlib-1.7.12.jar, at /META-INF/jruby.home/lib/ruby/1.9/monitor.rb:245
. It seems that:

I suspect some code somewhere is importing java.lang.Thread into a top-level namespace (like Object) and as a result overwriting the Ruby "Thread" class.

...accoding to https://www.ruby-forum.com/topic/2920464

By the way, I am not using JRuby so please do not feel this as my urgent request. I tested JRuby after Curtis introduced shading for the multiple version jffi problem. Jython is working well.

Below are the symptoms.


Test 1. Script Editor, one line of code.

Following one line works.

"hello there".upcase[1..4]

Test 2. Script Editor, with automatically inserted lines when "Ruby" is selected as language.

# @AppService appService
require_relative "#{$appService.getApp.getBaseDirectory}/plugins/JRuby/imagej.rb"

This causes the error, see below.

Started New_.rb at Thu Sep 11 11:38:10 CEST 2014
NoMethodError: undefined method `current' for Java::JavaLang::Thread:Class
   mon_check_owner at file:/Applications/Fiji.app/jars/jruby-stdlib-1.7.12.jar!/META-INF/jruby.home/lib/ruby/1.9/monitor.rb:245
          mon_exit at file:/Applications/Fiji.app/jars/jruby-stdlib-1.7.12.jar!/META-INF/jruby.home/lib/ruby/1.9/monitor.rb:195
           require at file:/Applications/Fiji.app/jars/jruby-stdlib-1.7.12.jar!/META-INF/jruby.home/lib/ruby/shared/rubygems/core_ext/kernel_require.rb:143
  require_relative at file:/Applications/Fiji.app/jars/jruby-core-1.7.12.jar!/jruby/kernel19/kernel.rb:21
            (root) at New_.rb:2
org.jruby.embed.EvalFailedException: (NoMethodError) undefined method `current' for Java::JavaLang::Thread:Class
    at org.jruby.embed.internal.EmbedEvalUnitImpl.run(EmbedEvalUnitImpl.java:133)
    at org.jruby.embed.jsr223.JRubyEngine.eval(JRubyEngine.java:118)
    at org.jruby.embed.jsr223.JRubyEngine.eval(JRubyEngine.java:146)
    at org.scijava.script.ScriptModule.run(ScriptModule.java:175)
    at org.scijava.module.ModuleRunner.run(ModuleRunner.java:167)
    at org.scijava.module.ModuleRunner.call(ModuleRunner.java:126)
    at org.scijava.module.ModuleRunner.call(ModuleRunner.java:65)
    at org.scijava.thread.DefaultThreadService$2.call(DefaultThreadService.java:164)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
    at java.lang.Thread.run(Thread.java:695)
Caused by: org.jruby.exceptions.RaiseException: (NoMethodError) undefined method `current' for Java::JavaLang::Thread:Class
    at RUBY.mon_check_owner(file:/Applications/Fiji.app/jars/jruby-stdlib-1.7.12.jar!/META-INF/jruby.home/lib/ruby/1.9/monitor.rb:245)
    at RUBY.mon_exit(file:/Applications/Fiji.app/jars/jruby-stdlib-1.7.12.jar!/META-INF/jruby.home/lib/ruby/1.9/monitor.rb:195)
    at RUBY.require(file:/Applications/Fiji.app/jars/jruby-stdlib-1.7.12.jar!/META-INF/jruby.home/lib/ruby/shared/rubygems/core_ext/kernel_require.rb:143)
    at RUBY.require_relative(file:/Applications/Fiji.app/jars/jruby-core-1.7.12.jar!/jruby/kernel19/kernel.rb:21)
    at RUBY.(root)(New_.rb:2)

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