8327839: Crash with unboxing and widening primitive conversion in switch

Reviewed-by: jlahoda
This commit is contained in:
Aggelos Biboudis 2024-03-18 13:16:29 +00:00
parent 86f1744736
commit fb390d202c
5 changed files with 111 additions and 12 deletions

View file

@ -468,22 +468,23 @@ public class SwitchBootstraps {
Label notNumber = cb.newLabel();
cb.aload(SELECTOR_OBJ);
cb.instanceof_(ConstantDescs.CD_Number);
if (selectorType == long.class || selectorType == float.class || selectorType == double.class) {
if (selectorType == long.class || selectorType == float.class || selectorType == double.class ||
selectorType == Long.class || selectorType == Float.class || selectorType == Double.class) {
cb.ifeq(next);
} else {
cb.ifeq(notNumber);
}
cb.aload(SELECTOR_OBJ);
cb.checkcast(ConstantDescs.CD_Number);
if (selectorType == long.class) {
if (selectorType == long.class || selectorType == Long.class) {
cb.invokevirtual(ConstantDescs.CD_Number,
"longValue",
MethodTypeDesc.of(ConstantDescs.CD_long));
} else if (selectorType == float.class) {
} else if (selectorType == float.class || selectorType == Float.class) {
cb.invokevirtual(ConstantDescs.CD_Number,
"floatValue",
MethodTypeDesc.of(ConstantDescs.CD_float));
} else if (selectorType == double.class) {
} else if (selectorType == double.class || selectorType == Double.class) {
cb.invokevirtual(ConstantDescs.CD_Number,
"doubleValue",
MethodTypeDesc.of(ConstantDescs.CD_double));