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;
}
@DelegateTo("setSimpleNameCacheLowLevel")
private void setSimpleNameCache(String value) {
simpleName = value;
}

View File

@ -248,9 +248,10 @@ public class ClassGenerator {
FieldReference[] instanceFields = new FieldReference[cls.getFields().size()];
int instanceIndex = 0;
for (FieldHolder field : cls.getFields()) {
if (field.hasModifier(ElementModifier.STATIC)) {
if (field.hasModifier(ElementModifier.STATIC) || isMonitorField(field.getReference())) {
continue;
}
String fieldName = context.getNames().forMemberField(field.getReference());
structWriter.printStrictType(field.getType()).print(" ").print(fieldName).println(";");
if (isReferenceType(field.getType())) {
@ -267,6 +268,10 @@ public class ClassGenerator {
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) {
CodeWriter fieldsWriter = structuresWriter.fragment();