-
Bug
-
Resolution: Fixed
-
P3
-
1.2.0
-
1.2fcs
-
sparc
-
solaris_2.5
-
Verified
Name: mgC56079 Date: 09/10/98
Here is the minimized test demonstrating the bug:
==== InvokeTest1.java ====
package pkg1;
import java.lang.reflect.*;
public class InvokeTest1 {
public static void main(String a[]) {
try {
Object args[] = {};
Class params[] = {};
Object Ob = new pkg.InvokeTest();
Method m = pkg.InvokeTest.class.getDeclaredMethod("test", params);
m.invoke( Ob, args );
} catch (Exception e) {
e.printStackTrace();
System.out.println("failed 1");
}
}
}
==== InvokeTest.java ====
package pkg;
import java.lang.reflect.*;
public class InvokeTest {
public void test() {
try {
Object args[] = {};
Class params[] = {};
Object Ob = new SomeClass();
Method m = SomeClass.class.getDeclaredMethod("method", params);
m.invoke( Ob, args );
System.out.println("passed");
} catch (Exception e) {
e.printStackTrace();
System.out.println("failed 2");
}
}
}
class SomeClass {
public void method() {
}
}
=== Sample run (jdk1.1.6, jdk1.2beta4, jdk1.2fcsH; correct) ===
% javac -d . InvokeTest.java InvokeTest1.java
% java pkg1.InvokeTest1
passed
=== Sample run (jdk1.1.6, jdk1.2fcsI; wrong) ===
% javac -d . InvokeTest.java InvokeTest1.java
% java pkg1.InvokeTest1
java.lang.IllegalAccessException: pkg/SomeClass
at java.lang.reflect.Method.invoke(Native Method)
at pkg.InvokeTest.test(Compiled Code)
at java.lang.reflect.Method.invoke(Native Method)
at pkg1.InvokeTest1.main(Compiled Code)
failed 2
======================================================================