[CLJ-1243] Cannot resolve public generic method from package-private base class Created: 01/Aug/13 Updated: 17/Nov/13
|Affects Version/s:||Release 1.3, Release 1.4, Release 1.5|
The Clojure compiler cannot resolve a public generic method inherited from a package-private base class.
Instructions to reproduce:
This is valid in Java. In Clojure, invoking B.M produces a reflection warning, followed by the error "java.lang.IllegalArgumentException: Can't call public method of non-public class." No amount of type-hinting prevents the warning or the error.
Attachment clj-1243-demo1.tar.gz contains sample code and script to demonstrate the problem.
Examples of Java projects which use public methods in package-private classes:
|Comment by Stuart Sierra [ 01/Aug/13 5:11 PM ]|
It is also not possible to call the method reflectively from Java.
This may be a bug in Java reflection: JDK-4283544
But why does it only happen on generic methods?
|Comment by Stuart Sierra [ 08/Aug/13 11:59 AM ]|
According to Rich Hickey, the presence of bridge methods is unspecified and inconsistent across JDK versions.
A possible solution is to use ASM to examine the bytecode of third-party Java classes, instead of the reflection API. That way the Clojure compiler would have access to the same information as the Java compiler.
|Comment by Andy Fingerhut [ 17/Nov/13 11:01 PM ]|