diff --git a/core/src/main/java/org/teavm/model/classes/VirtualTableBuilder.java b/core/src/main/java/org/teavm/model/classes/VirtualTableBuilder.java index 8ab98d3cc..00523a84b 100644 --- a/core/src/main/java/org/teavm/model/classes/VirtualTableBuilder.java +++ b/core/src/main/java/org/teavm/model/classes/VirtualTableBuilder.java @@ -130,9 +130,6 @@ public class VirtualTableBuilder { var methodsAtCallSites = methodsUsedAtCallSites.get(className); if (methodsAtCallSites != null) { for (MethodDescriptor methodDesc : methodsAtCallSites) { - if (cls.hasModifier(ElementModifier.FINAL) && !table.entries.containsKey(methodDesc)) { - continue; - } MethodReader method = cls.getMethod(methodDesc); if (method != null && method.getLevel() == AccessLevel.PRIVATE) { continue; diff --git a/metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/MetaprogrammingDependencyListener.java b/metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/MetaprogrammingDependencyListener.java index c3fbe0dc6..2cefd0fbb 100644 --- a/metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/MetaprogrammingDependencyListener.java +++ b/metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/MetaprogrammingDependencyListener.java @@ -94,10 +94,11 @@ public class MetaprogrammingDependencyListener extends AbstractDependencyListene if (model.getUsages().size() == 1) { emitSingleUsage(model, pe, paramVars); } else if (model.getUsages().isEmpty()) { - if (model.getMethod().getReturnType() == ValueType.VOID) { + var returnType = model.getMethod().getReturnType(); + if (returnType == ValueType.VOID) { pe.exit(); } else { - pe.constantNull(Object.class).returnValue(); + pe.defaultValue(returnType).returnValue(); } } else { emitMultipleUsage(model, pe, agent, paramVars); @@ -147,10 +148,11 @@ public class MetaprogrammingDependencyListener extends AbstractDependencyListene } choice.otherwise(() -> { - if (methodDep.getReference().getReturnType() == ValueType.VOID) { + var returnType = methodDep.getReference().getReturnType(); + if (returnType == ValueType.VOID) { pe.exit(); } else { - pe.constantNull(Object.class).returnValue(); + pe.defaultValue(returnType).returnValue(); } }); }