Skip to content

AsciidoctorJ fails on JRuby 9.2.0.0 #5204

@robertpanzer

Description

@robertpanzer

Environment

JRuby 9.2.0.0
OS X: Darwin Roberts-MacBook-Air.local 17.5.0 Darwin Kernel Version 17.5.0: Fri Apr 13 19:32:32 PDT 2018; root:xnu-4570.51.2~1/RELEASE_X86_64 x86_64

Expected Behavior

I tried upgrading the dependency in AsciidoctorJ to 9.2.0.0 and expected the build to run.

Actual Behavior

As soon as the Asciidoctor instance is created, it fails with a java.lang.VerifyError:

java.lang.VerifyError: Bad return type
Exception Details:
  Location:
    org/jruby/gen/InterfaceImpl659984099.converters()Lorg/jruby/RubyArray; @45: areturn
  Reason:
    Type 'org/jruby/runtime/builtin/IRubyObject' (current frame, stack[0]) is not assignable to 'org/jruby/RubyArray' (from method signature)
  Current Frame:
    bci: @45
    flags: { }
    locals: { 'org/jruby/gen/InterfaceImpl659984099', 'org/jruby/runtime/builtin/IRubyObject', 'org/jruby/Ruby' }
    stack: { 'org/jruby/runtime/builtin/IRubyObject' }
  Bytecode:
    0000000: 2ab4 0015 4c2b b900 1d01 004d b200 1f2b
    0000010: 126e 126f b600 272c b600 2d2b 2bb9 0031
    0000020: 0100 126f b200 73b2 003d b600 43b0     

	at java.base/java.lang.Class.getDeclaredConstructors0(Native Method)
	at java.base/java.lang.Class.privateGetDeclaredConstructors(Class.java:3090)
	at java.base/java.lang.Class.getConstructor0(Class.java:3295)
	at java.base/java.lang.Class.getConstructor(Class.java:2110)
	at org.jruby.javasupport.Java.newInterfaceImpl(Java.java:1352)
	at org.jruby.java.proxies.JavaInterfaceTemplate.newInterfaceProxy(JavaInterfaceTemplate.java:285)
	at org.jruby.java.proxies.JavaInterfaceTemplate.access$100(JavaInterfaceTemplate.java:34)
	at org.jruby.java.proxies.JavaInterfaceTemplate$InterfaceProxyFactory.call(JavaInterfaceTemplate.java:233)
	at org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:194)
	at org.jruby.RubyClass.finvoke(RubyClass.java:560)
	at org.jruby.runtime.Helpers.invoke(Helpers.java:353)
	at org.jruby.javasupport.JavaUtil.convertProcToInterface(JavaUtil.java:278)
	at org.jruby.RubyBasicObject.defaultToJava(RubyBasicObject.java:898)
	at org.jruby.RubyBasicObject.toJava(RubyBasicObject.java:876)
	at org.jruby.javasupport.JavaEmbedUtils.rubyToJava(JavaEmbedUtils.java:247)
	at org.asciidoctor.internal.RubyUtils.rubyToJava(RubyUtils.java:19)
	at org.asciidoctor.internal.JRubyAsciidoctorModuleFactory.createAsciidoctorModule(JRubyAsciidoctorModuleFactory.java:27)
...

At the moment the "glue" between the Java API and the Asciidoctor Ruby implementation is moved to JRuby, by having a Java interface AsciidoctorModule [1] and a Ruby class AsciidoctorModule[2] and letting JRuby implement this interface for this Ruby class [3].
It looks like this fails now exactly where JRuby creates the proxy for this interface.

I created a test repository at https://github.com/robertpanzer/jruby92test where I also tried to reproduce the error with a simplified version, but there it succeeds.
The repo also contains a test with Asciidoctor though, and that one fails.

Maybe you have an idea if we did sth wrong in AsciidoctorJ or if this is a real bug.
For the future I am considering to remove the dynamic implementation of this interface anyway, so that I have a workaround (asciidoctor/asciidoctorj#652), but it would still be nice to know to cause of this error.

[1] https://github.com/asciidoctor/asciidoctorj/blob/master/asciidoctorj-core/src/main/java/org/asciidoctor/internal/AsciidoctorModule.java
[2] https://github.com/asciidoctor/asciidoctorj/blob/master/asciidoctorj-core/src/main/resources/org/asciidoctor/internal/asciidoctorclass.rb
[3] https://github.com/asciidoctor/asciidoctorj/blob/master/asciidoctorj-core/src/main/java/org/asciidoctor/internal/JRubyAsciidoctorModuleFactory.java#L27

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions