Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile of method call with block return results is "is not compiled Ruby; use java_import to load normal classes" #3651

Closed
shovtyuk opened this issue Feb 8, 2016 · 4 comments
Labels
ir
Milestone

Comments

@shovtyuk
Copy link

@shovtyuk shovtyuk commented Feb 8, 2016

test.rb:

def func &block
  yield
end
func{ puts '1' }

affected both jruby-9.0.5.0 and jruby-9.1.0.0-SNAPSHOT

$ jrubyc test.rb && jruby -e "require 'jruby'; JRuby.runtime.debug = true; require './test.class'"
java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.jruby.runtime.load.CompiledScriptLoader.loadScriptFromFile(CompiledScriptLoader.java:35)
    at org.jruby.runtime.load.LibrarySearcher$ClassResourceLibrary.load(LibrarySearcher.java:256)
    at org.jruby.runtime.load.LibrarySearcher$FoundLibrary.load(LibrarySearcher.java:34)
    at org.jruby.runtime.load.LoadService.tryLoadingLibraryOrScript(LoadService.java:900)
    at org.jruby.runtime.load.LoadService.smartLoadInternal(LoadService.java:541)
    at org.jruby.runtime.load.LoadService.requireCommon(LoadService.java:426)
    at org.jruby.runtime.load.LoadService.require(LoadService.java:392)
    at org.jruby.RubyKernel.requireCommon(RubyKernel.java:944)
    at org.jruby.RubyKernel.require19(RubyKernel.java:937)
    at org.jruby.RubyKernel$INVOKER$s$1$0$require19.call(RubyKernel$INVOKER$s$1$0$require19.gen)
    at org.jruby.internal.runtime.methods.JavaMethod$JavaMethodOneOrNBlock.call(JavaMethod.java:380)
    at org.jruby.internal.runtime.methods.AliasMethod.call(AliasMethod.java:61)
    at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:161)
    at org.jruby.ir.interpreter.InterpreterEngine.processCall(InterpreterEngine.java:316)
    at org.jruby.ir.interpreter.StartupInterpreterEngine.interpret(StartupInterpreterEngine.java:77)
    at org.jruby.ir.interpreter.InterpreterEngine.interpret(InterpreterEngine.java:86)
    at org.jruby.internal.runtime.methods.MixedModeIRMethod.INTERPRET_METHOD(MixedModeIRMethod.java:184)
    at org.jruby.internal.runtime.methods.MixedModeIRMethod.call(MixedModeIRMethod.java:170)
    at org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:197)
    at org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:313)
    at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:163)
    at DashE.invokeOther5:require(-e)
    at DashE.RUBY$script(-e:1)
    at java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:627)
    at org.jruby.ir.Compiler$1.load(Compiler.java:111)
    at org.jruby.Ruby.runScript(Ruby.java:817)
    at org.jruby.Ruby.runScript(Ruby.java:809)
    at org.jruby.Ruby.runNormally(Ruby.java:747)
    at org.jruby.Ruby.runFromMain(Ruby.java:569)
    at org.jruby.Main.doRunFromMain(Main.java:415)
    at org.jruby.Main.internalRun(Main.java:310)
    at org.jruby.Main.run(Main.java:239)
    at org.jruby.Main.main(Main.java:201)
Caused by: java.lang.IllegalArgumentException: Unhandled operation: return_or_rethrow_saved_exc
    at org.jruby.ir.persistence.IRReaderStream.decodeInstr(IRReaderStream.java:292)
    at org.jruby.ir.persistence.IRReaderStream.decodeInstructionsAt(IRReaderStream.java:173)
    at org.jruby.ir.persistence.IRReader.load(IRReader.java:54)
    at org.jruby.ir.runtime.IRRuntimeHelpers.decodeScopeFromBytes(IRRuntimeHelpers.java:1467)
    at test.loadIR(test.rb)
    ... 37 more
Exception `LoadError' at org/jruby/RubyKernel.java:937 - /Users/easyrider/Desktop/test/test.class is not compiled Ruby; use java_import to load normal classes
LoadError: /Users/easyrider/Desktop/test/test.class is not compiled Ruby; use java_import to load normal classes
  require at org/jruby/RubyKernel.java:937
  require at /Users/easyrider/.rvm/rubies/jruby-head/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:54
    <top> at -e:1
@shovtyuk
Copy link
Author

@shovtyuk shovtyuk commented Feb 8, 2016

this reproduced with any block/proc/lambda, for example {a:1,b:2}.each{|k,v| puts "#{k}:#{v}" }

@tobymurray-nanometrics
Copy link

@tobymurray-nanometrics tobymurray-nanometrics commented Feb 18, 2016

I've run into this in both 9.0.4.0 and 9.0.5.0, and I have not been able to find any workable workarounds.

kares added a commit that referenced this issue Feb 21, 2016
@kares kares added the ir label Feb 21, 2016
@kares kares added this to the JRuby 9.1.0.0 milestone Feb 21, 2016
@kares kares closed this Feb 21, 2016
kares added a commit to kares/jruby that referenced this issue Mar 2, 2016
kares added a commit that referenced this issue Mar 2, 2016
…ading regressions

e.g. #3651
@abecciu
Copy link

@abecciu abecciu commented Mar 7, 2016

@kares is there a workaround or backport for those of us using a stable version like 9.0.5.0?

@kares
Copy link
Member

@kares kares commented Mar 8, 2016

@abecciu no "backport" its a change with jruby's dist artifacts, also can not use 9.0.5 to compile and than 9.1 at runtime. there's only the possibility to setup Bundler to use a 9.1 SNAPSHOT (or do not compile).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.