diff --git a/teavm-core/src/main/java/org/teavm/model/ClassReaderSource.java b/teavm-core/src/main/java/org/teavm/model/ClassReaderSource.java index dd3b8f482..b602a06a4 100644 --- a/teavm-core/src/main/java/org/teavm/model/ClassReaderSource.java +++ b/teavm-core/src/main/java/org/teavm/model/ClassReaderSource.java @@ -119,7 +119,7 @@ public interface ClassReaderSource { return Optional.of(true); } ClassReader cls = get(subType); - if (subType == null) { + if (cls == null) { return Optional.empty(); } if (cls.getParent() != null && !cls.getParent().equals(cls.getName())) { diff --git a/teavm-core/src/main/java/org/teavm/model/emit/ProgramEmitter.java b/teavm-core/src/main/java/org/teavm/model/emit/ProgramEmitter.java index 25c204116..bc4e1684c 100644 --- a/teavm-core/src/main/java/org/teavm/model/emit/ProgramEmitter.java +++ b/teavm-core/src/main/java/org/teavm/model/emit/ProgramEmitter.java @@ -345,6 +345,9 @@ public final class ProgramEmitter { } public void addInstruction(Instruction insn) { + if (escapes()) { + throw new EmitException("This block has already escaped"); + } if (currentLocation != null) { insn.setLocation(currentLocation); } diff --git a/teavm-core/src/main/java/org/teavm/model/emit/StringChooseEmitter.java b/teavm-core/src/main/java/org/teavm/model/emit/StringChooseEmitter.java index 1717a1a28..0e291d2b6 100644 --- a/teavm-core/src/main/java/org/teavm/model/emit/StringChooseEmitter.java +++ b/teavm-core/src/main/java/org/teavm/model/emit/StringChooseEmitter.java @@ -39,8 +39,10 @@ public class StringChooseEmitter { this.insn = insn; this.joinBlock = joinBlock; this.otherwiseBlock = pe.prepareBlock(); + this.testValue = testValue; insn.setCondition(testValue.invokeVirtual("hashCode", int.class).getVariable()); insn.setDefaultTarget(otherwiseBlock); + pe.addInstruction(insn); pe.enter(otherwiseBlock); pe.jump(joinBlock); pe.enter(joinBlock); @@ -62,7 +64,7 @@ public class StringChooseEmitter { } pe.enter(block); - fork = testValue.invokeVirtual("equals", boolean.class, testValue.cast(Object.class)) + fork = testValue.invokeVirtual("equals", boolean.class, pe.constant(value).cast(Object.class)) .fork(BranchingCondition.NOT_EQUAL); hashForks.put(hash, fork); diff --git a/teavm-core/src/main/java/org/teavm/model/util/InstructionStringifier.java b/teavm-core/src/main/java/org/teavm/model/util/InstructionStringifier.java index 18a5695e7..29e0461ed 100644 --- a/teavm-core/src/main/java/org/teavm/model/util/InstructionStringifier.java +++ b/teavm-core/src/main/java/org/teavm/model/util/InstructionStringifier.java @@ -229,7 +229,7 @@ public class InstructionStringifier implements InstructionReader { sb.append("; "); } SwitchTableEntryReader entry = table.get(i); - sb.append("case ").append(entry.getCondition()).append(": goto $").append(entry.getTarget()); + sb.append("case ").append(entry.getCondition()).append(": goto $").append(entry.getTarget().getIndex()); } sb.append(", default: goto $").append(defaultTarget.getIndex()); }