Skip to content

Commit

Permalink
fix: attempt to improve package rename checks (#1997)
Browse files Browse the repository at this point in the history
  • Loading branch information
skylot committed Sep 9, 2023
1 parent 45a637f commit e358476
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion jadx-core/src/main/java/jadx/core/dex/info/ClassInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public void changeShortName(String aliasName) {

public void changePkg(String aliasPkg) {
if (isInner()) {
throw new JadxRuntimeException("Can't change package for inner class");
throw new JadxRuntimeException("Can't change package for inner class: " + this);
}
if (!Objects.equals(getAliasPkg(), aliasPkg)) {
ClassAliasInfo newAlias = new ClassAliasInfo(aliasPkg, getAliasShortName());
Expand Down
6 changes: 3 additions & 3 deletions jadx-core/src/main/java/jadx/core/dex/nodes/ClassNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ public void rename(String newName) {
clsInfo.changeShortName(newName);
return;
}
if (isInner()) {
if (clsInfo.isInner()) {
addWarn("Can't change package for inner class: " + this + " to " + newName);
return;
}
Expand All @@ -598,7 +598,7 @@ public void rename(String newName) {

private boolean changeClassNodePackage(String fullPkg) {
if (clsInfo.isInner()) {
throw new JadxRuntimeException("Can't change package for inner class");
throw new JadxRuntimeException("Can't change package for inner class: " + clsInfo);
}
if (fullPkg.equals(clsInfo.getAliasPkg())) {
return false;
Expand All @@ -618,7 +618,7 @@ public void removeAlias() {

@Override
public void onParentPackageUpdate(PackageNode updatedPkg) {
if (isInner()) {
if (clsInfo.isInner()) {
return;
}
clsInfo.changePkg(packageNode.getAliasPkgInfo().getFullName());
Expand Down
2 changes: 1 addition & 1 deletion jadx-core/src/main/java/jadx/core/dex/nodes/RootNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ private void initInnerClasses() {
}
classes.forEach(ClassNode::updateParentClass);
for (PackageNode pkg : packages) {
pkg.getClasses().removeIf(ClassNode::isInner);
pkg.getClasses().removeIf(cls -> cls.getClassInfo().isInner());
}
}

Expand Down

0 comments on commit e358476

Please sign in to comment.