From a5efae1a64eaa55001619f14511476df01214600 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matou=C5=A1=20Ku=C4=8Dera?= Date: Tue, 20 Aug 2024 13:13:45 +0200 Subject: [PATCH] fix: TeaVM analyzer bug --- .../editor/InstructionSequenceReplacer.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/base/src/main/java/proguard/classfile/editor/InstructionSequenceReplacer.java b/base/src/main/java/proguard/classfile/editor/InstructionSequenceReplacer.java index 103b6b21e..5ea266f3e 100644 --- a/base/src/main/java/proguard/classfile/editor/InstructionSequenceReplacer.java +++ b/base/src/main/java/proguard/classfile/editor/InstructionSequenceReplacer.java @@ -403,6 +403,27 @@ public Instruction create(Clazz clazz, CodeAttribute codeAttribute, int index) { return replacementInstruction; } + { + //noinspection ConstantValue - getClass never returns null, so the code never actually runs + if (this.getClass() == null) { + // make TeaVM aware of our overridden methods + // why does this need to happen? I have no idea + this.teaVMFix(); + } + } + + @SuppressWarnings("DataFlowIssue") + private void teaVMFix() { + this.visitSimpleInstruction(null, null, null, 0, null); + this.visitVariableInstruction(null, null, null, 0, null); + this.visitConstantInstruction(null, null, null, 0, null); + this.visitBranchInstruction(null, null, null, 0, null); + this.visitTableSwitchInstruction(null, null, null, 0, null); + this.visitLookUpSwitchInstruction(null, null, null, 0, null); + this.visitLabelInstruction(null, null, null, 0, null); + this.visitCatchInstruction(null, null, null, 0, null); + } + // Implementations for InstructionVisitor. @Override