-
Bug
-
Resolution: Not an Issue
-
P3
-
None
-
1.1
-
x86
-
windows_nt
Name: mc57594 Date: 05/21/97
Invocations of public methods in non-public classes are disallowed. This makes it impossible to invoke methods of public interfaces that are implemented by non-public classes, like "hasMoreElmeents" in VectorEnumerator.
For instance, the following code throws an IllegalAccessException:
import java.util.Vector;
import java.lang.reflect.Method;
public class test {
public static void main(String[] argv) {
Vector v = new Vector();
v.addElement("foo");
Object o = v.elements();
Class c = o.getClass();
Method[] m = c.getDeclaredMethods();
try {
for (int i = 0; i < m.length; i++)
if (m[i].getName().equals("hasMoreElements"))
System.out.println(m[i].invoke(
o,new Object[0]));
}
catch (Exception e) {
System.out.println(e);
}
}
}
I have traced this to line 155 of reflect.c, which calls VerifyClassAccess() and disallows the invocation.
-Clint
company - Metrowerks Inc. , email - ###@###.###
======================================================================