-
Bug
-
Resolution: Duplicate
-
P2
-
7
-
generic
-
generic
Please see the minimized test below to reproduce the issue.
Minimized test:
===============
$ cat test.java
import java.lang.invoke.MethodType;
import static java.lang.invoke.MethodType.*;
public class test {
private final static Class[] RETURN_TYPES = {
void.class, boolean.class, byte.class, char.class, short.class,
int.class, long.class, float.class, double.class,
Void.class, Boolean.class, Byte.class, Character.class, Short.class,
Integer.class, Long.class, Float.class, Double.class,
Enum.class, Comparable.class, Thread.State.class, Deprecated.class,
boolean[].class, byte[].class, char[].class, short[].class,
int[].class, long[].class, float[].class, double[].class,
Void[].class, Boolean[].class, Byte[].class, Character[].class, Short[].class,
Integer[].class, Long[].class, Float[].class, Double[].class,
Enum[].class, Comparable[].class, Thread.State[].class, Deprecated[].class
};
public static void main(String[] args) {
for (int i = 0; i < RETURN_TYPES.length; i++) {
Class rtype = RETURN_TYPES[i];
MethodType mt = methodType(rtype);
if (isWrapperType(rtype) != mt.hasWrappers()) {
System.out.println("hasWrappers() failed for method type "
+ mt + ": expected \"" + isWrapperType(rtype) + "\", "
+ "was given \"" + mt.hasWrappers() + "\"");
}
}
}
private static boolean isWrapperType(final Class cl) {
if (cl.equals(Void.class) || cl.equals(Boolean.class)
|| cl.equals(Byte.class) || cl.equals(Character.class)
|| cl.equals(Short.class) || cl.equals(Integer.class)
|| cl.equals(Long.class) || cl.equals(Float.class)
|| cl.equals(Double.class)) {
return true;
}
return false;
}
}
$ java -showversion -verify -XX:+UnlockExperimentalVMOptions -XX:+EnableInvokeDynamic test
java version "1.7.0-ea"
Java(TM) SE Runtime Environment (build 1.7.0-ea-b136)
Java HotSpot(TM) Server VM (build 21.0-b06, mixed mode)
hasWrappers() failed for method type ()Comparable: expected "false", was given "true"
hasWrappers() failed for method type ()Deprecated: expected "false", was given "true"
Minimized test:
===============
$ cat test.java
import java.lang.invoke.MethodType;
import static java.lang.invoke.MethodType.*;
public class test {
private final static Class[] RETURN_TYPES = {
void.class, boolean.class, byte.class, char.class, short.class,
int.class, long.class, float.class, double.class,
Void.class, Boolean.class, Byte.class, Character.class, Short.class,
Integer.class, Long.class, Float.class, Double.class,
Enum.class, Comparable.class, Thread.State.class, Deprecated.class,
boolean[].class, byte[].class, char[].class, short[].class,
int[].class, long[].class, float[].class, double[].class,
Void[].class, Boolean[].class, Byte[].class, Character[].class, Short[].class,
Integer[].class, Long[].class, Float[].class, Double[].class,
Enum[].class, Comparable[].class, Thread.State[].class, Deprecated[].class
};
public static void main(String[] args) {
for (int i = 0; i < RETURN_TYPES.length; i++) {
Class rtype = RETURN_TYPES[i];
MethodType mt = methodType(rtype);
if (isWrapperType(rtype) != mt.hasWrappers()) {
System.out.println("hasWrappers() failed for method type "
+ mt + ": expected \"" + isWrapperType(rtype) + "\", "
+ "was given \"" + mt.hasWrappers() + "\"");
}
}
}
private static boolean isWrapperType(final Class cl) {
if (cl.equals(Void.class) || cl.equals(Boolean.class)
|| cl.equals(Byte.class) || cl.equals(Character.class)
|| cl.equals(Short.class) || cl.equals(Integer.class)
|| cl.equals(Long.class) || cl.equals(Float.class)
|| cl.equals(Double.class)) {
return true;
}
return false;
}
}
$ java -showversion -verify -XX:+UnlockExperimentalVMOptions -XX:+EnableInvokeDynamic test
java version "1.7.0-ea"
Java(TM) SE Runtime Environment (build 1.7.0-ea-b136)
Java HotSpot(TM) Server VM (build 21.0-b06, mixed mode)
hasWrappers() failed for method type ()Comparable: expected "false", was given "true"
hasWrappers() failed for method type ()Deprecated: expected "false", was given "true"
- duplicates
-
JDK-7032850 MethodHandle.invokeGeneric throws unspecified RuntimeException if parameterized method is called
- Closed
- relates to
-
JDK-7034341 MethodType.hasWrappers() throws IAE if a method type contains an argument of the java.lang.Void type
- Closed
-
JDK-7032323 code changes for JSR 292 EG adjustments to API, through Public Review
- Closed