mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-23 00:24:11 -08:00
C: fix duplicate call of some <clinit> methods when using reflection
This commit is contained in:
parent
5a8284222a
commit
6b0b30cb23
|
@ -366,7 +366,8 @@ public class CTarget implements TeaVMTarget, TeaVMCHost {
|
||||||
boolean vmAssertions = Boolean.parseBoolean(System.getProperty("teavm.c.vmAssertions", "false"));
|
boolean vmAssertions = Boolean.parseBoolean(System.getProperty("teavm.c.vmAssertions", "false"));
|
||||||
GenerationContext context = new GenerationContext(vtableProvider, characteristics,
|
GenerationContext context = new GenerationContext(vtableProvider, characteristics,
|
||||||
controller.getDependencyInfo(), stringPool, nameProvider, controller.getDiagnostics(), classes,
|
controller.getDependencyInfo(), stringPool, nameProvider, controller.getDiagnostics(), classes,
|
||||||
intrinsics, generators, asyncMethods::contains, buildTarget, incremental, longjmpUsed,
|
intrinsics, generators, asyncMethods::contains, buildTarget,
|
||||||
|
controller.getClassInitializerInfo(), incremental, longjmpUsed,
|
||||||
vmAssertions, vmAssertions || heapDump);
|
vmAssertions, vmAssertions || heapDump);
|
||||||
|
|
||||||
BufferedCodeWriter runtimeWriter = new BufferedCodeWriter(false);
|
BufferedCodeWriter runtimeWriter = new BufferedCodeWriter(false);
|
||||||
|
@ -752,7 +753,9 @@ public class CTarget implements TeaVMTarget, TeaVMCHost {
|
||||||
}
|
}
|
||||||
writer.println("teavm_afterInitClasses();");
|
writer.println("teavm_afterInitClasses();");
|
||||||
generateStaticInitializerCalls(context, writer, includes, classes);
|
generateStaticInitializerCalls(context, writer, includes, classes);
|
||||||
|
if (context.getClassInitializerInfo().isDynamicInitializer("java.lang.String")) {
|
||||||
writer.println(context.getNames().forClassInitializer("java.lang.String") + "();");
|
writer.println(context.getNames().forClassInitializer("java.lang.String") + "();");
|
||||||
|
}
|
||||||
generateFiberStart(context, writer, includes);
|
generateFiberStart(context, writer, includes);
|
||||||
|
|
||||||
writer.outdent().println("}");
|
writer.outdent().println("}");
|
||||||
|
|
|
@ -976,7 +976,8 @@ public class ClassGenerator {
|
||||||
private boolean needsInitializer(ClassReader cls) {
|
private boolean needsInitializer(ClassReader cls) {
|
||||||
return !context.getCharacteristics().isStaticInit(cls.getName())
|
return !context.getCharacteristics().isStaticInit(cls.getName())
|
||||||
&& !context.getCharacteristics().isStructure(cls.getName())
|
&& !context.getCharacteristics().isStructure(cls.getName())
|
||||||
&& cls.getMethod(new MethodDescriptor("<clinit>", ValueType.VOID)) != null;
|
&& cls.getMethod(new MethodDescriptor("<clinit>", ValueType.VOID)) != null
|
||||||
|
&& context.getClassInitializerInfo().isDynamicInitializer(cls.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean tryDelegateToMethod(ClassHolder cls, MethodHolder method) {
|
private boolean tryDelegateToMethod(ClassHolder cls, MethodHolder method) {
|
||||||
|
|
|
@ -26,6 +26,7 @@ import org.teavm.dependency.DependencyInfo;
|
||||||
import org.teavm.diagnostics.Diagnostics;
|
import org.teavm.diagnostics.Diagnostics;
|
||||||
import org.teavm.model.ClassReaderSource;
|
import org.teavm.model.ClassReaderSource;
|
||||||
import org.teavm.model.MethodReference;
|
import org.teavm.model.MethodReference;
|
||||||
|
import org.teavm.model.analysis.ClassInitializerInfo;
|
||||||
import org.teavm.model.classes.VirtualTableProvider;
|
import org.teavm.model.classes.VirtualTableProvider;
|
||||||
import org.teavm.model.lowlevel.Characteristics;
|
import org.teavm.model.lowlevel.Characteristics;
|
||||||
import org.teavm.vm.BuildTarget;
|
import org.teavm.vm.BuildTarget;
|
||||||
|
@ -43,6 +44,7 @@ public class GenerationContext {
|
||||||
private Map<MethodReference, Intrinsic> intrinsicCache = new HashMap<>();
|
private Map<MethodReference, Intrinsic> intrinsicCache = new HashMap<>();
|
||||||
private Predicate<MethodReference> asyncMethods;
|
private Predicate<MethodReference> asyncMethods;
|
||||||
private BuildTarget buildTarget;
|
private BuildTarget buildTarget;
|
||||||
|
private ClassInitializerInfo classInitializerInfo;
|
||||||
private boolean incremental;
|
private boolean incremental;
|
||||||
private boolean longjmp;
|
private boolean longjmp;
|
||||||
private boolean vmAssertions;
|
private boolean vmAssertions;
|
||||||
|
@ -51,8 +53,9 @@ public class GenerationContext {
|
||||||
public GenerationContext(VirtualTableProvider virtualTableProvider, Characteristics characteristics,
|
public GenerationContext(VirtualTableProvider virtualTableProvider, Characteristics characteristics,
|
||||||
DependencyInfo dependencies, StringPool stringPool, NameProvider names, Diagnostics diagnostics,
|
DependencyInfo dependencies, StringPool stringPool, NameProvider names, Diagnostics diagnostics,
|
||||||
ClassReaderSource classSource, List<Intrinsic> intrinsics, List<Generator> generators,
|
ClassReaderSource classSource, List<Intrinsic> intrinsics, List<Generator> generators,
|
||||||
Predicate<MethodReference> asyncMethods, BuildTarget buildTarget, boolean incremental,
|
Predicate<MethodReference> asyncMethods, BuildTarget buildTarget,
|
||||||
boolean longjmp, boolean vmAssertions, boolean heapDump) {
|
ClassInitializerInfo classInitializerInfo, boolean incremental, boolean longjmp, boolean vmAssertions,
|
||||||
|
boolean heapDump) {
|
||||||
this.virtualTableProvider = virtualTableProvider;
|
this.virtualTableProvider = virtualTableProvider;
|
||||||
this.characteristics = characteristics;
|
this.characteristics = characteristics;
|
||||||
this.dependencies = dependencies;
|
this.dependencies = dependencies;
|
||||||
|
@ -64,6 +67,7 @@ public class GenerationContext {
|
||||||
this.generators = new ArrayList<>(generators);
|
this.generators = new ArrayList<>(generators);
|
||||||
this.asyncMethods = asyncMethods;
|
this.asyncMethods = asyncMethods;
|
||||||
this.buildTarget = buildTarget;
|
this.buildTarget = buildTarget;
|
||||||
|
this.classInitializerInfo = classInitializerInfo;
|
||||||
this.incremental = incremental;
|
this.incremental = incremental;
|
||||||
this.longjmp = longjmp;
|
this.longjmp = longjmp;
|
||||||
this.vmAssertions = vmAssertions;
|
this.vmAssertions = vmAssertions;
|
||||||
|
@ -128,6 +132,10 @@ public class GenerationContext {
|
||||||
return buildTarget;
|
return buildTarget;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ClassInitializerInfo getClassInitializerInfo() {
|
||||||
|
return classInitializerInfo;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isIncremental() {
|
public boolean isIncremental() {
|
||||||
return incremental;
|
return incremental;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user