Details
-
Bug
-
Resolution: Duplicate
-
P4
-
8, 9, 10
-
generic
-
generic
Description
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.
/* 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.
Attachments
Issue Links
- duplicates
-
JDK-8133247 Use of HYPOTHETICAL flag in bridge generation logic leads to missing bridges in some cases
- Resolved
- relates to
-
JDK-8133247 Use of HYPOTHETICAL flag in bridge generation logic leads to missing bridges in some cases
- Resolved
-
JDK-8203488 Remove error generation from TransTypes
- Resolved