Duplicate :
|
|
Relates :
|
|
Relates :
|
javac is normally adding visibility bridges for methods if they are public but declared by a package-private class: /* package-private */ class SuperClass { public Object foo() { return null; } } public class SubClass extends SuperClass { } This is not the case if a method has a generic type: /* package-private */ class SuperClass<X> { public X foo() { return null; } } public class SubClass extends SuperClass<Void> { } As a result, reflective access of this method fails with an IllegalAccessException if the following code is run from outside the package of SuperClass and SubClass: SubClass.class.getMethod("foo").invoke(new SubClass()); I would expect javac to create a visibility bridge for the method in question to allow for reflective access.
|