Skip to content

Kernel.load(file, true) produces RuntimeException: Should not get here! #3180

@dekellum

Description

@dekellum

Jruby, hasn't had support for the wrap=true option of Kernel::load. While previously (1.6.8, 1.7.0, 1.7.16, 1.7.21) it would not honor this option, it now (9.0.0.0) produces a runtime exception java.lang.RuntimeException: Should not get here! scopeType is SCRIPT_BODY if the wrap option is set.

There was previously a JRUBY-4339 on codehaus:

http://ruby.11.x6.nabble.com/jira-Created-JRUBY-4339-Kernel-load-with-wrap-true-does-not-protect-the-global-namespace-of-calling-m-td3480038.html

The jruby 1.7.0 release notes suggest this was fixed?

http://jruby.org/2012/10/22/jruby-1-7-0.html

...but my testing doesn't agree. Here is a minimal test setup:

https://github.com/dekellum/test-load-wrap

And here is output from MRI (passing); jruby 1.7.0, 1.7.16, 1.7.21 (shows not honoring wrap); and jruby 9.0.0.0 (new RuntimeException raised). For prior 9.x pre-releases I believe #3126 was preventing me from getting this far to see this issue.

% ruby -v loader.rb 
ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-linux]
Top level loader method called from loadee

% jruby -v loader.rb 
jruby 1.7.0 (1.9.3p203) 2012-10-22 ff1ebbe on OpenJDK 64-Bit Server VM 1.8.0_51-b16 +indy [linux-amd64]
Top level loader method called from loadee
RuntimeError: ERROR: Given load() with wrap=true, loadee's foo shouldn't be defined
  (root) at loader.rb:8

% jruby -v loader.rb 
jruby 1.7.16 (1.9.3p392) 2014-09-25 575b395 on OpenJDK 64-Bit Server VM 1.8.0_51-b16 +jit [linux-amd64]
Top level loader method called from loadee
RuntimeError: ERROR: Given load() with wrap=true, loadee's foo shouldn't be defined
  (root) at loader.rb:8

% jruby -v loader.rb 
jruby 1.7.21 (1.9.3p551) 2015-07-07 a741a82 on OpenJDK 64-Bit Server VM 1.8.0_51-b16 +jit [linux-amd64]
Top level loader method called from loadee
RuntimeError: ERROR: Given load() with wrap=true, loadee's foo shouldn't be defined
  (root) at loader.rb:8

% jruby -v loader.rb 
jruby 9.0.0.0 (2.2.2) 2015-07-21 e10ec96 OpenJDK 64-Bit Server VM 25.51-b03 on 1.8.0_51-b16 +jit [linux-amd64]
Top level loader method called from loadee
IRRuntimeHelpers.java:789:in `findInstanceMethodContainer': java.lang.RuntimeException: Should not get here! scopeType is SCRIPT_BODY
    from IRRuntimeHelpers.java:1259:in `defInterpretedInstanceMethod'
    from DefineInstanceMethodInstr.java:56:in `interpret'
    from StartupInterpreterEngine.java:183:in `processOtherOp'
    from StartupInterpreterEngine.java:107:in `interpret'
    from Interpreter.java:116:in `INTERPRET_ROOT'
    from Interpreter.java:103:in `execute'
    from Interpreter.java:32:in `execute'
    from IRTranslator.java:42:in `execute'
    from Ruby.java:837:in `runInterpreter'
    from Ruby.java:2901:in `loadFile'
    from LibrarySearcher.java:245:in `load'
    from LibrarySearcher.java:35:in `load'
    from LoadService.java:335:in `load'
    from RubyKernel.java:966:in `loadCommon'
    from RubyKernel.java:958:in `load19'
    from RubyKernel$INVOKER$s$0$1$load19.gen:-1:in `call'
    from DynamicMethod.java:213:in `call'
    from DynamicMethod.java:209:in `call'
    from CachingCallSite.java:333:in `cacheAndCall'
    from CachingCallSite.java:195:in `call'
    from loader.rb:-1:in `invokeOther7:load'
    from loader.rb:5:in `RUBY$script'
    from MethodHandle.java:625:in `invokeWithArguments'
    from Compiler.java:111:in `load'
    from Ruby.java:821:in `runScript'
    from Ruby.java:813:in `runScript'
    from Ruby.java:751:in `runNormally'
    from Ruby.java:573:in `runFromMain'
    from Main.java:403:in `doRunFromMain'
    from Main.java:298:in `internalRun'
    from Main.java:225:in `run'
    from Main.java:197:in `main'

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions