mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 08:14:09 -08:00
Fix metaprogramming bugs
This commit is contained in:
parent
7b33bb643e
commit
b61849ce80
|
@ -419,16 +419,16 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext
|
|||
List<MethodNode> nonInitMethods = new ArrayList<>();
|
||||
MethodHolder clinit = classSource.get(cls.getName()).getMethod(
|
||||
new MethodDescriptor("<clinit>", ValueType.VOID));
|
||||
boolean needsClinit = clinit != null;
|
||||
List<MethodNode> clinitMethods = new ArrayList<>();
|
||||
for (MethodNode method : cls.getMethods()) {
|
||||
if (clinit == null || (!method.getModifiers().contains(NodeModifier.STATIC)
|
||||
&& !method.getReference().getName().equals("<init>"))) {
|
||||
nonInitMethods.add(method);
|
||||
} else {
|
||||
if (needsClinit && (method.getModifiers().contains(NodeModifier.STATIC)
|
||||
|| method.getReference().getName().equals("<init>"))) {
|
||||
clinitMethods.add(method);
|
||||
} else {
|
||||
nonInitMethods.add(method);
|
||||
}
|
||||
}
|
||||
boolean needsClinit = clinit != null;
|
||||
|
||||
if (needsClinit) {
|
||||
writer.append("function ").appendClass(cls.getName()).append("_$clinit()").ws()
|
||||
|
|
|
@ -198,15 +198,9 @@ public abstract class BasicBlockMapper implements InstructionVisitor {
|
|||
|
||||
@Override
|
||||
public void visit(MonitorEnterInstruction insn) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(MonitorExitInstruction insn) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -157,6 +157,9 @@ public final class ProgramUtils {
|
|||
}
|
||||
|
||||
private Variable copyVar(VariableReader var) {
|
||||
if (var == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
return programCopy.variableAt(var.getIndex());
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
*/
|
||||
package org.teavm.classlib.java.lang;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.*;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
|
@ -103,4 +103,31 @@ public class VMTest {
|
|||
}
|
||||
private int foo() { return 2; }
|
||||
private void bar() { throw new RuntimeException(); }
|
||||
|
||||
// See https://github.com/konsoletyper/teavm/issues/167
|
||||
@Test
|
||||
public void passesStaticFieldToSuperClassConstructor() {
|
||||
SubClass obj = new SubClass();
|
||||
assertNotNull(obj.getValue());
|
||||
}
|
||||
|
||||
static class SuperClass {
|
||||
static final Integer ONE = new Integer(1);
|
||||
|
||||
private Integer value;
|
||||
|
||||
public SuperClass(Integer value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public Integer getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
static class SubClass extends SuperClass {
|
||||
SubClass() {
|
||||
super(ONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user