提交 29ff86b7 编写于 作者: S Skylot

fix: don't unload attributes added to class at initial load (#1010)

上级 381afa27
...@@ -92,6 +92,8 @@ public class AType<T extends IAttribute> { ...@@ -92,6 +92,8 @@ public class AType<T extends IAttribute> {
public static final AType<RegDebugInfoAttr> REG_DEBUG_INFO = new AType<>(); public static final AType<RegDebugInfoAttr> REG_DEBUG_INFO = new AType<>();
public static final Set<AType<?>> SKIP_ON_UNLOAD = new HashSet<>(Arrays.asList( public static final Set<AType<?>> SKIP_ON_UNLOAD = new HashSet<>(Arrays.asList(
SOURCE_FILE,
FIELD_INIT,
FIELD_REPLACE, FIELD_REPLACE,
METHOD_INLINE, METHOD_INLINE,
SKIP_MTH_ARGS)); SKIP_MTH_ARGS));
......
...@@ -167,16 +167,20 @@ public class ClassNode extends NotificationAttrNode implements ILoadable, ICodeN ...@@ -167,16 +167,20 @@ public class ClassNode extends NotificationAttrNode implements ILoadable, ICodeN
f.addAttr(FieldInitAttr.NULL_VALUE); f.addAttr(FieldInitAttr.NULL_VALUE);
} }
} }
List<EncodedValue> values = cls.getStaticFieldInitValues(); try {
int count = values.size(); List<EncodedValue> values = cls.getStaticFieldInitValues();
if (count == 0 || count > staticFields.size()) { int count = values.size();
return; if (count == 0 || count > staticFields.size()) {
} return;
for (int i = 0; i < count; i++) { }
staticFields.get(i).addAttr(FieldInitAttr.constValue(values.get(i))); for (int i = 0; i < count; i++) {
staticFields.get(i).addAttr(FieldInitAttr.constValue(values.get(i)));
}
// process const fields
root().getConstValues().processConstFields(this, staticFields);
} catch (Exception e) {
this.addWarnComment("Failed to load initial values for static fields", e);
} }
// process const fields
root().getConstValues().processConstFields(this, staticFields);
} }
private void addSourceFilenameAttr(String fileName) { private void addSourceFilenameAttr(String fileName) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册