-
Bug
-
Resolution: Not an Issue
-
P4
-
None
-
1.1.5, 1.2.0
-
sparc
-
solaris_2.5
Name: mgC56079 Date: 02/18/98
Reflection throws an IllegalAccessException if a public field inherited from
a non-public interface is accessed.
Direct access works fine however.
----- Here is the test (Const.java) -----
public class Const {
public static void main(String[] args) {
// direct access works fine
System.out.print("Direct access: ");
System.out.println(java.io.ObjectInputStream.STREAM_VERSION);
// access via reflection fails
System.out.print("Reflection: ");
try {
java.lang.reflect.Field f=
java.io.ObjectInputStream.class.getField("STREAM_VERSION");
System.out.println(f.get(null));
}
catch (Exception e) {
e.printStackTrace();
}
}
}
---- Here is the output from the test -------
java Const
Direct access: 5
Reflection: java.lang.IllegalAccessException: java/io/ObjectStreamConstants
at Const.main(Const.java:12)
======================================================================