The document states that SwitchBoostraps.typeSwitch() throws
IllegalArgumentException - if the invocation type is not a method type of first parameter of a reference type, second parameter of type int and with int as its return type
In the following case, when the first param is not a ref type, IAE is expected but not thrown.
SwitchBootstraps.typeSwitch(
LOOKUP,
DUMMY_INVOCATION_NAME,
MethodType.methodType(
int.class, int.class, int.class // <- First param is int.class and not a reference type.
),
LABELS);
Also, the following exception is not thrown:
IllegalArgumentException - if labels contains an element that is not of type Boolean when target is a Boolean.class
var labels = new Object[]{5, 10};
CallSite callSite = SwitchBootstraps.typeSwitch(
LOOKUP,
DUMMY_INVOCATION_NAME,
MethodType.methodType(
int.class, Boolean.class, int.class
),
labels
);
callSite.getTarget().invoke(true, 0);
IllegalArgumentException - if the invocation type is not a method type of first parameter of a reference type, second parameter of type int and with int as its return type
In the following case, when the first param is not a ref type, IAE is expected but not thrown.
SwitchBootstraps.typeSwitch(
LOOKUP,
DUMMY_INVOCATION_NAME,
MethodType.methodType(
int.class, int.class, int.class // <- First param is int.class and not a reference type.
),
LABELS);
Also, the following exception is not thrown:
IllegalArgumentException - if labels contains an element that is not of type Boolean when target is a Boolean.class
var labels = new Object[]{5, 10};
CallSite callSite = SwitchBootstraps.typeSwitch(
LOOKUP,
DUMMY_INVOCATION_NAME,
MethodType.methodType(
int.class, Boolean.class, int.class
),
labels
);
callSite.getTarget().invoke(true, 0);
- clones
-
JDK-8375119 SwitchBoostraps.enumSwitch does not throw an NPE when lookup is null in some cases
-
- Resolved
-