Bind only public interface methods for private classes#5984
Bind only public interface methods for private classes#5984headius merged 2 commits intojruby:masterfrom
Conversation
* Private classes were considered for method binding even though we no longer set them accessible on Java 9+ when they have not already been opened. This resulted in Java 9+ environments producing method errors when they attempted to dispatch to those methods on private classes. * In order to fix the above for private classes with public interfaces, this patch also fixes how we traverse a class's implemented interfaces. Possibly from changes in jruby#5832, we were not walking an interface's superinterfaces, causing us to only walk one level in such cases.
|
@kares @enebo I do not think the failing spec should pass. I have not looked into its lineage yet, but the Java would not be able to compile against or invoke these methods for a normal invocation. |
|
Confirmed in both cases that Java cannot call the |
These were born pending and only the attempt to call `capsMethod` started to fail with jruby#5984. That method only exists on private class definitions, and is not callable from normal Java, so we do not bind it.
|
makes sense but what about compatibility for users on 8, |
|
@kares I will make an argument that binding to private without an explicit setAccessible in their code was never intended behavior. In this case we can maybe just point out this was unintended behavior (e.g. a bug). I guess the bigger question with that answer is how common this is in reality. |
This includes two fixes introduced (at least in part) by #5832:
we no longer set them accessible on Java 9+ when they have not
already been opened. This resulted in Java 9+ environments
producing method errors when they attempted to dispatch to those
methods on private classes.
interfaces, this patch also fixes how we traverse a class's
implemented interfaces. Possibly from changes in Reduce overhead of binding Java classes and methods #5832, we were
not walking an interface's superinterfaces, causing us to only
walk one level in such cases.
In my local tests, this caused failures in
spec:jifor specs accessing the following classes; I do not believe that these methods should be callable, since they are on private inner classes without any public interface method:jruby/spec/java_integration/fixtures/InnerClasses.java
Lines 78 to 95 in b35397b