-
-
Notifications
You must be signed in to change notification settings - Fork 925
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
AsciidoctorJ fails on JRuby 9.2.0.0 #5204
Comments
Nice! @kares is this changes you made or I made? I'm at the pub trying not to crash from jet lag 😀 @robertpanzer This shouldn't he a difficult fix but probably no workaround. |
Cheers! :) 🍻 |
@headius did not touch this part much ... no clues. @robertpanzer we might need your Java version. |
I am seeing this error on both Java 8 and 10 identifying like this:
|
so I looked into the presented case - its quite "edgy" : |
Yeah, I know, we went to the limits :-) |
There's likely a simple tweak here, to always cast the value to be returned to the return type of the method we're implementing. Doing a plain checkcast will obviously raise a ClassCastException within the generated interface impl if the type doesn't match...is that ok? |
I can reproduce with this simple case: ReturnsArray.java import org.jruby.RubyArray;
public interface ReturnsArray {
public RubyArray doIt();
}
And I can fix it with the following patch: diff --git a/core/src/main/java/org/jruby/java/codegen/RealClassGenerator.java b/core/src/main/java/org/jruby/java/codegen/RealClassGenerator.java
index 17e2045393..0a5e4934e9 100644
--- a/core/src/main/java/org/jruby/java/codegen/RealClassGenerator.java
+++ b/core/src/main/java/org/jruby/java/codegen/RealClassGenerator.java
@@ -821,12 +821,13 @@ public abstract class RealClassGenerator {
}
}
} else {
+ // if the return type is not an IRubyObject implementer, coerce to that type before casting
if (!IRubyObject.class.isAssignableFrom(returnType)) {
mv.ldc(Type.getType(returnType));
mv.invokeinterface(
p(IRubyObject.class), "toJava", sig(Object.class, Class.class));
- mv.checkcast(p(returnType));
}
+ mv.checkcast(p(returnType));
mv.areturn();
}
} else { |
@robertpanzer Can you test a master build of JRuby with the above patch and confirm it resolves your issue? |
Sure! I’ll try that tomorrow. |
Actually I made it a bit easier and pushed branch |
This regressed in 3613060, when the |
I went ahead and merged it. Can you come up with a spec for spec/java_integration? |
I just tested with the latest JRuby master and I can confirm that this issue is indeed fixed. |
Great, but when its going to be released to public ? |
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:
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 classAsciidoctorModule
[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
The text was updated successfully, but these errors were encountered: