-
Bug
-
Resolution: Fixed
-
P4
-
5.0
-
b19
-
generic
-
generic
-
Verified
As demonstrated by the program below, java.lang.reflect.Method.toGenericString
doesn't print bounds on type variables on generic methods. Run the program like this:
$ java Test java.util.Collections max java.util.Collection java.util.Collections
max
java.util.Collection
public static <T> T java.util.Collections.max(java.util.Collection<? extends T>)
The output should have been:
max
java.util.Collection
public static <T extends Object & Comparable<? super T>> T java.util.Collections.max(java.util.Collection<? extends T>)
import java.lang.reflect.*;
public class Test {
public static void main(String... args) throws ClassNotFoundException, NoSuchMethodException {
for (int i=0; i<args.length; i++) System.out.println(args[i]);
String cName = args[0];
String mName = args[1];
Class<?> c = Class.forName(cName);
Class<?>[] cs = new Class<?>[args.length - 2];
for (int i=0; i<args.length-2; i++) cs[i] = Class.forName(args[i+2]);
Method m = c.getMethod(mName, cs);
System.out.println(m.toGenericString());
}
}
doesn't print bounds on type variables on generic methods. Run the program like this:
$ java Test java.util.Collections max java.util.Collection java.util.Collections
max
java.util.Collection
public static <T> T java.util.Collections.max(java.util.Collection<? extends T>)
The output should have been:
max
java.util.Collection
public static <T extends Object & Comparable<? super T>> T java.util.Collections.max(java.util.Collection<? extends T>)
import java.lang.reflect.*;
public class Test {
public static void main(String... args) throws ClassNotFoundException, NoSuchMethodException {
for (int i=0; i<args.length; i++) System.out.println(args[i]);
String cName = args[0];
String mName = args[1];
Class<?> c = Class.forName(cName);
Class<?>[] cs = new Class<?>[args.length - 2];
for (int i=0; i<args.length-2; i++) cs[i] = Class.forName(args[i+2]);
Method m = c.getMethod(mName, cs);
System.out.println(m.toGenericString());
}
}
- csr for
-
JDK-8212094 (reflect) toGenericString fails to print bounds of type variables on generic methods
-
- Closed
-
- relates to
-
JDK-8058202 AnnotatedType implementations don't override toString(), equals(), hashCode()
-
- Closed
-
-
JDK-8222817 Refactor printing processor to use streams
-
- Resolved
-
-
JDK-8213299 runtime/appcds/jigsaw/classpathtests/EmptyClassInBootClassPath.java failed with java.lang.NoSuchMethodException
-
- Resolved
-