-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
8, 9
-
generic
-
generic
FULL PRODUCT VERSION :
A DESCRIPTION OF THE PROBLEM :
I have two classes A and B, where B extends A and A is package protected. Both classes are in the same package.
class A
{
public static final String VALUE = "foo";
}
public class B extends A
{
}
// The static constant VALUE from A is accessible through B:
System.out.println( B.VALUE );
// Reflective access doesn't work without making the field accessible, which is not always an option.
// And whenever regular access is possible, reflective access should be as well from the same context.
Class< B > clazz = ...;
Field field = clazz.getField( "VALUE" );
String value = (String) field.get( null );
System.out.println( value );
REGRESSION. Last worked in version 8u131
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Whenever regular access is possible, reflective access should be as well from the same context.
ACTUAL -
Reflective access doesn't work without making the field accessible, which is not always an option.
REPRODUCIBILITY :
This bug can be reproduced always.
A DESCRIPTION OF THE PROBLEM :
I have two classes A and B, where B extends A and A is package protected. Both classes are in the same package.
class A
{
public static final String VALUE = "foo";
}
public class B extends A
{
}
// The static constant VALUE from A is accessible through B:
System.out.println( B.VALUE );
// Reflective access doesn't work without making the field accessible, which is not always an option.
// And whenever regular access is possible, reflective access should be as well from the same context.
Class< B > clazz = ...;
Field field = clazz.getField( "VALUE" );
String value = (String) field.get( null );
System.out.println( value );
REGRESSION. Last worked in version 8u131
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Whenever regular access is possible, reflective access should be as well from the same context.
ACTUAL -
Reflective access doesn't work without making the field accessible, which is not always an option.
REPRODUCIBILITY :
This bug can be reproduced always.
- duplicates
-
JDK-4283544 (reflect) Field and Method do not correctly obey language accessibility rules
- Open