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

LoadError with compiled multi-byte constant #4662

Closed
jakago opened this issue Jun 9, 2017 · 4 comments
Closed

LoadError with compiled multi-byte constant #4662

jakago opened this issue Jun 9, 2017 · 4 comments
Labels

Comments

@jakago
Copy link

jakago commented Jun 9, 2017

multibyteconst.rb

# coding: utf-8

# 'α'.bytes => [206, 177]
p CONST_α = 1

run with jruby 9.1.9.0

$ jruby multibyteconst.rb
1

compile and run with jruby 9.1.9.0

$ jrubyc multibyteconst.rb
$ jruby multibyteconst.class
LoadError: multibyteconst.class is not compiled Ruby; use java_import to load normal classes
@headius
Copy link
Member

headius commented Jun 9, 2017

Confirmed on master.

@headius
Copy link
Member

headius commented Jun 9, 2017

Actual error...may be an IR persistence bug. @enebo?

$ jruby -d blah.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:498)
	at org.jruby.runtime.load.CompiledScriptLoader.loadScriptFromFile(CompiledScriptLoader.java:35)
	at org.jruby.Ruby.runFromMain(Ruby.java:547)
	at org.jruby.Main.doRunFromMain(Main.java:417)
	at org.jruby.Main.internalRun(Main.java:305)
	at org.jruby.Main.run(Main.java:232)
	at org.jruby.Main.main(Main.java:204)
Caused by: java.lang.ArrayIndexOutOfBoundsException: -79
	at org.jruby.ir.operands.OperandType.fromCoded(OperandType.java:73)
	at org.jruby.ir.persistence.IRReaderStream.decodeOperandType(IRReaderStream.java:389)
	at org.jruby.ir.persistence.IRReaderStream.decodeOperand(IRReaderStream.java:345)
	at org.jruby.ir.instructions.PutConstInstr.decode(PutConstInstr.java:36)
	at org.jruby.ir.persistence.IRReaderStream.decodeInstr(IRReaderStream.java:282)
	at org.jruby.ir.persistence.IRReaderStream.decodeInstructionsAt(IRReaderStream.java:194)
	at org.jruby.ir.persistence.IRReader$1.call(IRReader.java:63)
	at org.jruby.ir.persistence.IRReader$1.call(IRReader.java:59)
	at org.jruby.ir.interpreter.InterpreterContext.getEngine(InterpreterContext.java:40)
	at org.jruby.ir.interpreter.InterpreterContext.getInstructions(InterpreterContext.java:148)
	at org.jruby.ir.interpreter.InterpreterContext.computeScopeFlagsFromInstructions(InterpreterContext.java:154)
	at org.jruby.ir.IRScope.computeScopeFlags(IRScope.java:751)
	at org.jruby.ir.persistence.IRReader.load(IRReader.java:72)
	at org.jruby.ir.runtime.IRRuntimeHelpers.decodeScopeFromBytes(IRRuntimeHelpers.java:1584)
	at blah.loadIR(blah.rb)
	... 10 more
LoadError: blah.class is not compiled Ruby; use java_import to load normal classes

@enebo
Copy link
Member

enebo commented Jun 12, 2017

Just a recap that encoding was done using String.length() and then dumping the bytes. length() reports characters so derp....fwiw this is not a regression as it has always been coded this way (well 1.7 may have worked but it was a completely different code base for AOT).

This is still likely to break in scenarios where the mbc string is not UTF-8 and JVM file.coding is not UTF-8. 9.2 will address this pervasively as we will be passing ByteList or RubySymbol around and stop using j.l.String altogether.

enebo added a commit that referenced this issue Jun 12, 2017
@enebo
Copy link
Member

enebo commented Jun 12, 2017

Whoops this last commit was for #4664 and not #4662.

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

No branches or pull requests

3 participants