-
-
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
JRuby unable to find methods unless jar is in boot classpath #4266
Comments
to get your test case to the point where it fails I applied follow patch diff --git a/src/main/java/fi/relex/SimpleClassImpl.java b/src/main/java/fi/relex/SimpleClassImpl.java
index 4ea0874..db6978c 100644
--- a/src/main/java/fi/relex/SimpleClassImpl.java
+++ b/src/main/java/fi/relex/SimpleClassImpl.java
@@ -1,10 +1,10 @@
package fi.relex;
-public class SimpleClassImpl extends SimpleClass {
+class SimpleClassImpl extends SimpleClass {
private final long value;
- public SimpleClassImpl(long value) {
+ SimpleClassImpl(long value) {
this.value = value;
} i.e. it is the https://github.com/jmiettinen/jruby-test/blob/master/src/main/java/fi/relex/BrokenClassImpl.java#L15 has a package private Builder whereas https://github.com/jmiettinen/jruby-test/blob/master/src/main/java/fi/relex/SimpleClassImpl.java#L16 is public weird! I would not ever thought that the bootclassloader can help here - good catch. |
Yeah, that's the thing that makes the difference. I should've brought it up more clearly. As such, being on boot classpath should not have any effect on this as reflection should be able to reach and call both of the classes. Now that I think of it, we've been hit by JRuby being unable call methods from package-private classes before as we're deploying to Tomcat without adding JRuby to boot classpath there. |
The difference seems to stem from the fact that in This is not true at least if there's no My colleague did some digging and it seems that @headius introduced first ban to not use methods from private classes: ec8d280 as a fix for JRUBY-4799. This ban seems to have been loosened a bit later on and public methods for private classes are added if I am not very familiar with how the |
@jmiettinen thanks for the analysis ... your logic totally makes sense, I think there are 2 issues to fix :
|
minor improvement of class.count -1 for jruby#4266's fix
minor improvement of class.count -1 for #4266's fix
minor improvement of class.count -1 for #4266's fix
minor improvement of class.count -1 for jruby#4266's fix
Environment
Darwin jmiettinen.local 14.5.0 Darwin Kernel Version 14.5.0: Sun Sep 25 22:07:15 PDT 2016; root:xnu-2782.50.9~1/RELEASE_X86_64 x86_64
)JAVA_OPTS
run.sh
which runs both failing and succeeding case.org.jruby.Main
which then runs a JRuby-script calling a few Java-classes.Expected Behavior
When running a simple script with just having
JRuby
in the classpath, not in boot classpath, I would expect the JRuby to correctly resolve Java-methods and call them.So in that case, the script should print out results of two different builder implementations:
Actual Behavior
What actually happens is that calls succeed when the target Java-class is publicly visible, the calls succeed, but JRuby cannot find the target when implementor of the method is package-private.
The text was updated successfully, but these errors were encountered: