-
Bug
-
Resolution: Fixed
-
P2
-
1.4.1
-
beta
-
generic
-
generic
-
Verified
Class.getMethod(String name, Class [] parameterTypes) throws an NPE when
constructing the expected NoSuchMethodException. This problem was introduced
by the fix for bug 4404129 which improved the exception messages for
NoSuchMethodException. This bug will exist for all methods in Class.java
which throw NoSuchMethodExceptions: getMethod, getDeclaredMethod,
getConstructor, getDeclaredConstructor.
The following test case illustrates the problem.
import java.lang.reflect.*;
class A {
public void m(Object o) {}
}
public class Get {
public static void main(String [] args) throws Exception {
Class [] ca = {null};
Method m = A.class.getMethod("m", ca);
}
}
OUTPUT:
$ java -version
java version "1.4.1-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1-beta-b11)
Java HotSpot(TM) Client VM (build 1.4.1-beta-b11, mixed mode)
(iag@ribbit) ~///lang/reflect/4654698 $ java Get
Exception in thread "main" java.lang.NullPointerException
at java.lang.Class.argumentTypesToString(Class.java:1829)
at java.lang.Class.getMethod0(Class.java:1747)
at java.lang.Class.getMethod(Class.java:954)
at Get.main(Get.java:10)
$ /java/re/jdk/1.4.1/promoted/beta/b10/binaries/solaris-sparc/bin/java -version
java version "1.4.1-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1-beta-b10)
Java HotSpot(TM) Client VM (build 1.4.1-beta-b10, mixed mode)
$ /java/re/jdk/1.4.1/promoted/beta/b10/binaries/solaris-sparc/bin/java Get
Exception in thread "main" java.lang.NoSuchMethodException: m
at java.lang.Class.getMethod0(Class.java:1746)
at java.lang.Class.getMethod(Class.java:953)
at Get.main(Get.java:10)
-- iag@sfbay 2002-05-14
constructing the expected NoSuchMethodException. This problem was introduced
by the fix for bug 4404129 which improved the exception messages for
NoSuchMethodException. This bug will exist for all methods in Class.java
which throw NoSuchMethodExceptions: getMethod, getDeclaredMethod,
getConstructor, getDeclaredConstructor.
The following test case illustrates the problem.
import java.lang.reflect.*;
class A {
public void m(Object o) {}
}
public class Get {
public static void main(String [] args) throws Exception {
Class [] ca = {null};
Method m = A.class.getMethod("m", ca);
}
}
OUTPUT:
$ java -version
java version "1.4.1-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1-beta-b11)
Java HotSpot(TM) Client VM (build 1.4.1-beta-b11, mixed mode)
(iag@ribbit) ~///lang/reflect/4654698 $ java Get
Exception in thread "main" java.lang.NullPointerException
at java.lang.Class.argumentTypesToString(Class.java:1829)
at java.lang.Class.getMethod0(Class.java:1747)
at java.lang.Class.getMethod(Class.java:954)
at Get.main(Get.java:10)
$ /java/re/jdk/1.4.1/promoted/beta/b10/binaries/solaris-sparc/bin/java -version
java version "1.4.1-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1-beta-b10)
Java HotSpot(TM) Client VM (build 1.4.1-beta-b10, mixed mode)
$ /java/re/jdk/1.4.1/promoted/beta/b10/binaries/solaris-sparc/bin/java Get
Exception in thread "main" java.lang.NoSuchMethodException: m
at java.lang.Class.getMethod0(Class.java:1746)
at java.lang.Class.getMethod(Class.java:953)
at Get.main(Get.java:10)
-- iag@sfbay 2002-05-14