From 58e68db2c4de612c1534fb4116d931654270df25 Mon Sep 17 00:00:00 2001 From: Alexey Andreev Date: Fri, 29 Sep 2023 18:08:48 +0200 Subject: [PATCH] classlib: properly determine enum class in SwitchBootstrapSubstitutor --- .../teavm/classlib/impl/SwitchBootstrapSubstitutor.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/classlib/src/main/java/org/teavm/classlib/impl/SwitchBootstrapSubstitutor.java b/classlib/src/main/java/org/teavm/classlib/impl/SwitchBootstrapSubstitutor.java index ecae01d9a..bfbc4b986 100644 --- a/classlib/src/main/java/org/teavm/classlib/impl/SwitchBootstrapSubstitutor.java +++ b/classlib/src/main/java/org/teavm/classlib/impl/SwitchBootstrapSubstitutor.java @@ -15,7 +15,6 @@ */ package org.teavm.classlib.impl; -import java.util.List; import org.teavm.dependency.BootstrapMethodSubstitutor; import org.teavm.dependency.DynamicCallSite; import org.teavm.model.BasicBlock; @@ -24,8 +23,6 @@ import org.teavm.model.ValueType; import org.teavm.model.emit.PhiEmitter; import org.teavm.model.emit.ProgramEmitter; import org.teavm.model.emit.ValueEmitter; -import org.teavm.model.instructions.SwitchInstruction; -import org.teavm.model.instructions.SwitchTableEntry; public class SwitchBootstrapSubstitutor implements BootstrapMethodSubstitutor { @Override @@ -47,9 +44,9 @@ public class SwitchBootstrapSubstitutor implements BootstrapMethodSubstitutor { var block = pe.prepareBlock(); pe.enter(block); - ValueType.Object enumType = enumSwitch ? labels.stream() - .filter(l -> l.getKind() == RuntimeConstant.TYPE) - .findAny().map(vt -> (ValueType.Object) vt.getValueType()).orElseThrow() : null; + var enumType = enumSwitch + ? (ValueType.Object) callSite.getCalledMethod().parameterType(0) + : null; if (enumType != null) { pe.initClass(enumType.getClassName()); }