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' ruby files with JRuby9000 (using rescue) #3613

Closed
gcristelli opened this issue Jan 24, 2016 · 4 comments
Closed

LoadError with 'compiled' ruby files with JRuby9000 (using rescue) #3613

gcristelli opened this issue Jan 24, 2016 · 4 comments

Comments

@gcristelli
Copy link

Compiling Ruby code into a class file and trying to load it afterwards leads to "LoadError: use java_import to load normal classes" if it includes a rescue command.

test.rb

puts 'hello world' rescue nil

compiled and run with

jrubyc test.rb
jruby -e "load 'test.class'"

leads to

LoadError: test.class is not compiled Ruby; use java_import to load normal classes
   load at org/jruby/RubyKernel.java:955
  <top> at -e:1

This happens with the current 9.0.5.0 snapshot and all previous 9.0.x versions.

$ jruby -v
jruby 9.0.5.0-SNAPSHOT (2.2.3) 2016-01-22 d7aefef Java HotSpot(TM) 64-Bit Server VM 25.65-b01 on 1.8.0_65-b17 +jit [linux-amd64]

@headius
Copy link
Member

headius commented Feb 14, 2016

Well that's weird.

@headius
Copy link
Member

headius commented Feb 14, 2016

I can't reproduce this on 9.1 (ruby-2.3 branch) so it's possible I fixed it with other jrubyc fixes.

[] ~/projects/jruby $ jrubyc test.rb

[] ~/projects/jruby $ jruby -e "load 'test.class'"
hello world

[] ~/projects/jruby $ cat test.rb
puts 'hello world' rescue nil

@headius headius closed this as completed Feb 14, 2016
@headius headius added this to the JRuby 9.1.0.0 milestone Feb 14, 2016
@pangloss
Copy link

I ran into this issue as well. It's a serious blocker for me.

@pangloss
Copy link

I just tested whether a JVM version difference in my stack could be the problem, but it seems that did not affect it.

The execution environment is the Docker official jruby:9.0.5.0-jre image. I originally built the jar on a Mac with Java 1.7.0_45 and rvm jruby-9.0.5.0. I retried building under the Docker official jruby:9.0.5.0-jdk image, but got the same error:

LoadError: uri:classloader:/pacer-model/core.class is not compiled Ruby; use java_import to load normal classes
  require at org/jruby/RubyKernel.java:937
  require at /app/vendor/bundle/jruby/2.2.0/gems/polyglot-0.3.5/lib/polyglot.rb:65
    <top> at /app/vendor/bundle/jruby/2.2.0/gems/pacer-model-2.5.0.pre-java/lib/pacer-model.rb:9
  require at org/jruby/RubyKernel.java:937
   (root) at /app/vendor/bundle/jruby/2.2.0/gems/polyglot-0.3.5/lib/polyglot.rb:1
    <top> at /app/vendor/bundle/jruby/2.2.0/gems/polyglot-0.3.5/lib/polyglot.rb:65
  require at org/jruby/RubyKernel.java:937
   (root) at /app/vendor/bundle/jruby/2.2.0/gems/pacer-model-2.5.0.pre-java/lib/pacer-model/loader.rb:21
    <top> at /app/vendor/bundle/jruby/2.2.0/gems/polyglot-0.3.5/lib/polyglot.rb:1
  require at org/jruby/RubyKernel.java:937
    <top> at /app/vendor/bundle/jruby/2.2.0/gems/polyglot-0.3.5/lib/polyglot.rb:65

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

No branches or pull requests

3 participants