Fix issue with <clinit> methods introduced by previous commit

This commit is contained in:
Alexey Andreev 2019-08-23 14:26:33 +03:00
parent ed627459c8
commit 7a03ad6c5e
2 changed files with 14 additions and 6 deletions

View File

@ -47,9 +47,13 @@ public class Linker {
MethodReference methodRef = method.getReference();
MethodDependencyInfo methodDep = dependency.getMethod(methodRef);
if (methodDep == null || !methodDep.isUsed()) {
method.getModifiers().add(ElementModifier.ABSTRACT);
method.getModifiers().remove(ElementModifier.NATIVE);
method.setProgram(null);
if (method.hasModifier(ElementModifier.STATIC)) {
cls.removeMethod(method);
} else {
method.getModifiers().add(ElementModifier.ABSTRACT);
method.getModifiers().remove(ElementModifier.NATIVE);
method.setProgram(null);
}
} else if (method.getProgram() != null) {
link(method.getReference(), method.getProgram());
}

View File

@ -963,9 +963,13 @@ public class TeaVM implements TeaVMHost, ServiceRepository {
for (MethodHolder method : cls.getMethods().toArray(new MethodHolder[0])) {
MethodDependencyInfo methodDep = dependencyAnalyzer.getMethod(method.getReference());
if (methodDep == null || !methodDep.isUsed()) {
method.getModifiers().add(ElementModifier.ABSTRACT);
method.getModifiers().remove(ElementModifier.NATIVE);
method.setProgram(null);
if (method.hasModifier(ElementModifier.STATIC)) {
cls.removeMethod(method);
} else {
method.getModifiers().add(ElementModifier.ABSTRACT);
method.getModifiers().remove(ElementModifier.NATIVE);
method.setProgram(null);
}
} else {
MethodReader methodReader = classReader.getMethod(method.getDescriptor());
if (methodReader != null && methodReader.getProgram() != null) {