Fix metaprogramming support, fix calculation of virtual tables for final classes

This commit is contained in:
Alexey Andreev 2024-08-14 13:22:27 +02:00
parent 2e59db3ab9
commit 8c15885f44
2 changed files with 6 additions and 7 deletions

View File

@ -130,9 +130,6 @@ public class VirtualTableBuilder {
var methodsAtCallSites = methodsUsedAtCallSites.get(className); var methodsAtCallSites = methodsUsedAtCallSites.get(className);
if (methodsAtCallSites != null) { if (methodsAtCallSites != null) {
for (MethodDescriptor methodDesc : methodsAtCallSites) { for (MethodDescriptor methodDesc : methodsAtCallSites) {
if (cls.hasModifier(ElementModifier.FINAL) && !table.entries.containsKey(methodDesc)) {
continue;
}
MethodReader method = cls.getMethod(methodDesc); MethodReader method = cls.getMethod(methodDesc);
if (method != null && method.getLevel() == AccessLevel.PRIVATE) { if (method != null && method.getLevel() == AccessLevel.PRIVATE) {
continue; continue;

View File

@ -94,10 +94,11 @@ public class MetaprogrammingDependencyListener extends AbstractDependencyListene
if (model.getUsages().size() == 1) { if (model.getUsages().size() == 1) {
emitSingleUsage(model, pe, paramVars); emitSingleUsage(model, pe, paramVars);
} else if (model.getUsages().isEmpty()) { } else if (model.getUsages().isEmpty()) {
if (model.getMethod().getReturnType() == ValueType.VOID) { var returnType = model.getMethod().getReturnType();
if (returnType == ValueType.VOID) {
pe.exit(); pe.exit();
} else { } else {
pe.constantNull(Object.class).returnValue(); pe.defaultValue(returnType).returnValue();
} }
} else { } else {
emitMultipleUsage(model, pe, agent, paramVars); emitMultipleUsage(model, pe, agent, paramVars);
@ -147,10 +148,11 @@ public class MetaprogrammingDependencyListener extends AbstractDependencyListene
} }
choice.otherwise(() -> { choice.otherwise(() -> {
if (methodDep.getReference().getReturnType() == ValueType.VOID) { var returnType = methodDep.getReference().getReturnType();
if (returnType == ValueType.VOID) {
pe.exit(); pe.exit();
} else { } else {
pe.constantNull(Object.class).returnValue(); pe.defaultValue(returnType).returnValue();
} }
}); });
} }