fix: resolve ClassCastException on encoded value access (#946)

This commit is contained in:
Skylot
2020-06-01 21:38:52 +01:00
parent 6192ced214
commit 5e62b9077a
2 changed files with 4 additions and 4 deletions
@@ -287,9 +287,9 @@ public class RegionGen extends InsnGen {
staticField(code, fn.getFieldInfo());
// print original value, sometimes replaced with incorrect field
FieldInitAttr valueAttr = fn.get(AType.FIELD_INIT);
if (valueAttr != null) {
if (valueAttr != null && valueAttr.getValueType() == FieldInitAttr.InitType.CONST) {
Object value = valueAttr.getEncodedValue();
if (value != null && valueAttr.getValueType() == FieldInitAttr.InitType.CONST) {
if (value != null) {
code.add(" /*").add(value.toString()).add("*/");
}
}
@@ -72,9 +72,9 @@ public class ConstStorage {
if (accFlags.isStatic() && accFlags.isFinal()) {
FieldInitAttr fv = f.get(AType.FIELD_INIT);
if (fv != null
&& fv.getEncodedValue() != null
&& fv.getValueType() == FieldInitAttr.InitType.CONST
&& fv != FieldInitAttr.NULL_VALUE) {
&& fv != FieldInitAttr.NULL_VALUE
&& fv.getEncodedValue() != null) {
addConstField(cls, f, fv.getEncodedValue().getValue(), accFlags.isPublic());
}
}