diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Code.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Code.java index 405cd86d9c080..b86bdc19be401 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Code.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Code.java @@ -35,7 +35,9 @@ import java.util.function.ToIntFunction; import static com.sun.tools.javac.code.TypeTag.BOT; +import static com.sun.tools.javac.code.TypeTag.DOUBLE; import static com.sun.tools.javac.code.TypeTag.INT; +import static com.sun.tools.javac.code.TypeTag.LONG; import static com.sun.tools.javac.jvm.ByteCodes.*; import static com.sun.tools.javac.jvm.ClassFile.CONSTANT_Class; import static com.sun.tools.javac.jvm.ClassFile.CONSTANT_Double; @@ -401,7 +403,8 @@ void postop() { */ public void emitLdc(LoadableConstant constant) { int od = poolWriter.putConstant(constant); - if (LoadableConstant.isLongOrDouble(constant)) { + Type constantType = types.constantType(constant); + if (constantType.hasTag(LONG) || constantType.hasTag(DOUBLE)) { emitop2(ldc2w, od, constant); } else if (od <= 255) { emitop1(ldc1, od, constant); @@ -1063,6 +1066,7 @@ public void emitop2(int op, int od, PoolConstant data) { Type t = types.erasure((Type)data); state.push(t); break; } + case ldc2: case ldc2w: state.push(types.constantType((LoadableConstant)data)); break; @@ -1070,9 +1074,6 @@ public void emitop2(int op, int od, PoolConstant data) { state.pop(1); state.push(syms.intType); break; - case ldc2: - state.push(types.constantType((LoadableConstant)data)); - break; case jsr: break; default: diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/PoolConstant.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/PoolConstant.java index b4d0716920ac1..2077efc188826 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/PoolConstant.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/PoolConstant.java @@ -25,12 +25,9 @@ package com.sun.tools.javac.jvm; -import com.sun.tools.javac.code.Symbol.DynamicVarSymbol; import com.sun.tools.javac.code.Type; -import com.sun.tools.javac.code.TypeTag; import com.sun.tools.javac.code.Types; import com.sun.tools.javac.code.Types.UniqueType; -import com.sun.tools.javac.jvm.PoolConstant.LoadableConstant.BasicConstant; import com.sun.tools.javac.util.List; import com.sun.tools.javac.util.Name; import com.sun.tools.javac.util.Pair; @@ -120,18 +117,6 @@ public Object poolKey(Types types) { return data; } } - - static boolean isLongOrDouble(LoadableConstant constant) { - return switch (constant) { - case DynamicVarSymbol dynamicVar -> - dynamicVar.type.hasTag(TypeTag.LONG) || - dynamicVar.type.hasTag(TypeTag.DOUBLE); - case BasicConstant bc -> - bc.tag == ClassFile.CONSTANT_Long || - bc.tag == ClassFile.CONSTANT_Double; - default -> false; - }; - } } /**