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

jrubyc failing - TypeError: failed to coerce org.objectweb.asm.ClassWriter to org.jruby.org.objectweb.asm.ClassVisitor #2887

Closed
torcido opened this Issue Apr 29, 2015 · 9 comments

Comments

Projects
None yet
5 participants
@torcido
Copy link

torcido commented Apr 29, 2015

Running jrubyc on a directory is failing with the following error:

TypeError: failed to coerce org.objectweb.asm.ClassWriter to org.jruby.org.objectweb.asm.ClassVisitor
block in compile_files_with_options at uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/jruby/compiler.rb:179
call at org/jruby/RubyProc.java:303
block in compile_files_with_options at uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/jruby/compiler.rb:243
each at org/jruby/RubyArray.java:1571
block in compile_files_with_options at uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/jruby/compiler.rb:242
each at org/jruby/RubyArray.java:1571
compile_files_with_options at uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/jruby/compiler.rb:233
compile_argv at uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/jruby/compiler.rb:94
at jrubyc.rb:3

It doesn't seem to matter which codebase we run it on, we're consistently getting this error. It's failing in both java 7 and 8.

@kares

This comment has been minimized.

Copy link
Member

kares commented Apr 29, 2015

I'm not sure it's apparent what JRuby version you're using ... thanks!

@enebo enebo added this to the JRuby 9.0.0.0.rc1 milestone Apr 29, 2015

@enebo enebo added the JRuby 9000 label Apr 29, 2015

@enebo

This comment has been minimized.

Copy link
Member

enebo commented Apr 29, 2015

@torcido no doubt this is some private code which you were trying to compile, Could you run this command again with --verbose:

jrubyc --verbose lib

This should show you which file this is blowing up on and then we can try and see what is different about it to cause this problem.

@torcido

This comment has been minimized.

Copy link
Author

torcido commented Apr 29, 2015

This is using jruby 9.0.0.0.pre2

Compiling all in '/Volumes/src/gems/configuration_properties/gem_source/lib/configuration_properties'...
Compiling lib/configuration_properties/version.rb
TypeError: failed to coerce org.objectweb.asm.ClassWriter to org.jruby.org.objectweb.asm.ClassVisitor
block in compile_files_with_options at uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/jruby/compiler.rb:179
call at org/jruby/RubyProc.java:303
block in compile_files_with_options at uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/jruby/compiler.rb:243
each at org/jruby/RubyArray.java:1571
block in compile_files_with_options at uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/jruby/compiler.rb:242
each at org/jruby/RubyArray.java:1571
compile_files_with_options at uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/jruby/compiler.rb:233
compile_argv at uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/jruby/compiler.rb:94
at ./jrubyc.rb:3

And the spectacular content of that file:

cat lib/configuration_properties/version.rb

class ConfigurationProperties
VERSION = "1.0.6"
end

@headius

This comment has been minimized.

Copy link
Member

headius commented May 4, 2015

This is some problem with shading of the ASM artifacts or the compiler's logic to guess the right shaded name(s). I'll have a look after 1.7.20, but @mkristian might help by confirming when and whether we are renaming ASM packages in our builds.

@mkristian

This comment has been minimized.

Copy link
Member

mkristian commented May 4, 2015

on 9k.pre2 only jruby-core artifact has the regular ASM packages all other distribution artifacts (tar.gz and zip distributions, jruby-jars.gem, jruby-complete.jar) or local build uses renamce ASM packages. next 9k.rc will have throughout renamed ASM packages.

1.7.20 is basically the same as 9k.pre2 but as on more artifact "org.jruby:jruby-noasm" which depends on jruby-core-noasm.jar

from the stacktrace I conclude that you either use jruby-stdlib.jar + jruby-core.jar or jruby-complete.jar ? how to execute jruby (do not really get it from the stacktraces) ?

@torcido

This comment has been minimized.

Copy link
Author

torcido commented May 5, 2015

I am launching jruby via the jruby-complete jar, from a fairly simple script where the invocation looks something like:

java -cp jruby-complete.jar org.jruby.Main ./jrubyc.rb "$@"

Where jrubyc.rb is copied from the installation:

require 'jruby/jrubyc'
status =  JRuby::Compiler::compile_argv(ARGV)
if (status != 0)
  puts "Compilation FAILED: #{status} error(s) encountered"
  exit status
end
@mkristian

This comment has been minimized.

Copy link
Member

mkristian commented May 5, 2015

thanx. I can reproduce it and something is not right with jruby-complete-9.0.0.0.pre2.jar :(

@mkristian mkristian self-assigned this May 5, 2015

@headius

This comment has been minimized.

Copy link
Member

headius commented May 5, 2015

Summarizing the error:

The Ruby compiler.rb script is attempting to construct a new SkinnyMethodAdapter passing the previously-constructed ClassWriter in. However, the ClassWriter created from Ruby code is an org.objectweb.asm.ClassWriter and the one SkinnyMethodAdapter was loaded with is the mangled name org.jruby.org.objectweb.asm.ClassWriter.

I suspect that the normal, unmangled ASM classes are getting into the jar you're using (complete, I think) causing this script to use them instead of the mangled names, and that mismatches with mangled JRuby ASM in the same jar.

@mkristian

This comment has been minimized.

Copy link
Member

mkristian commented May 5, 2015

yes, the jruby-complete jar has the shaded and unshaded classes - which most probably causes the error.

@mkristian mkristian closed this in 69147e5 May 11, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.