Skip to content

Commit

Permalink
fix: UnsupportedOperationException on adding a field
Browse files Browse the repository at this point in the history
  • Loading branch information
jpstotz committed Aug 17, 2022
1 parent 127f0ec commit fdd647d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions jadx-core/src/main/java/jadx/core/dex/nodes/ClassNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,9 @@ public List<FieldNode> getFields() {
}

public void addField(FieldNode fld) {
if (fields == Collections.EMPTY_LIST) {
fields = new ArrayList<>();
}
fields.add(fld);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ private static void addResourceFields(ClassNode resCls, ResourceStorage resStora
FieldNode newResField = new FieldNode(typeCls, rFieldInfo,
AccessFlags.PUBLIC | AccessFlags.STATIC | AccessFlags.FINAL);
newResField.addAttr(new EncodedValue(EncodedType.ENCODED_INT, resource.getId()));
typeCls.getFields().add(newResField);
typeCls.addField(newResField);
if (rClsExists) {
newResField.addInfoComment("Added by JADX");
}
Expand Down

0 comments on commit fdd647d

Please sign in to comment.