C backend: fix bug Class implementation. Don't emit unnecessary Object.monitor field

This commit is contained in:
Alexey Andreev 2019-04-26 18:26:23 +03:00
parent da68fa0083
commit 8a45dc300c
2 changed files with 7 additions and 1 deletions

View File

@ -153,6 +153,7 @@ public class TClass<T> extends TObject implements TAnnotatedElement {
return Address.ofObject(this).<RuntimeClass>toStructure().simpleName; return Address.ofObject(this).<RuntimeClass>toStructure().simpleName;
} }
@DelegateTo("setSimpleNameCacheLowLevel")
private void setSimpleNameCache(String value) { private void setSimpleNameCache(String value) {
simpleName = value; simpleName = value;
} }

View File

@ -248,9 +248,10 @@ public class ClassGenerator {
FieldReference[] instanceFields = new FieldReference[cls.getFields().size()]; FieldReference[] instanceFields = new FieldReference[cls.getFields().size()];
int instanceIndex = 0; int instanceIndex = 0;
for (FieldHolder field : cls.getFields()) { for (FieldHolder field : cls.getFields()) {
if (field.hasModifier(ElementModifier.STATIC)) { if (field.hasModifier(ElementModifier.STATIC) || isMonitorField(field.getReference())) {
continue; continue;
} }
String fieldName = context.getNames().forMemberField(field.getReference()); String fieldName = context.getNames().forMemberField(field.getReference());
structWriter.printStrictType(field.getType()).print(" ").print(fieldName).println(";"); structWriter.printStrictType(field.getType()).print(" ").print(fieldName).println(";");
if (isReferenceType(field.getType())) { if (isReferenceType(field.getType())) {
@ -267,6 +268,10 @@ public class ClassGenerator {
structWriter.outdent().print("} ").print(name).println(";"); structWriter.outdent().print("} ").print(name).println(";");
} }
private boolean isMonitorField(FieldReference field) {
return field.getClassName().equals("java.lang.Object") && field.getFieldName().equals("monitor");
}
private void generateClassStaticFields(ClassHolder cls) { private void generateClassStaticFields(ClassHolder cls) {
CodeWriter fieldsWriter = structuresWriter.fragment(); CodeWriter fieldsWriter = structuresWriter.fragment();