Cannot resolve public generic method from package-private base class
Key details
Description
The Clojure compiler cannot resolve a public generic method inherited from a package-private base class.
Instructions to reproduce:
In package P1
Define a package-private class A with generic type parameters
Define a public method M in A using generic types in either its arguments or return value
Define a public class B which extends A
In package P2
Construct an instance of B
Invoke B.M()
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:
The Clojure compiler cannot resolve a public generic method inherited from a package-private base class.
Instructions to reproduce:
In package P1
Define a package-private class A with generic type parameters
Define a public method M in A using generic types in either its arguments or return value
Define a public class B which extends A
In package P2
Construct an instance of B
Invoke B.M()
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:
Netty 4
See AbstractBootstrap.java and issue #1780 and Clojure ticket CLJ-1183
jfager/functional-critbit
See AbstractCritBitTree.java
Example:
(.get (io.prelink.critbit.CritBitTree. (org.ardverk.collection.DefaultKeyAnalyzer.)) nil)