-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix bug: array types are not rewritten when renaming classes
The bug is present in dexlib2 documentation here: https://github.com/JesusFreke/smali/blob/bf65e575a0fd7f03c41aa56d7a49bf0cda1da06a/dexlib2/src/main/java/org/jf/dexlib2/rewriter/DexRewriter.java#L57-L62
- Loading branch information
Showing
2 changed files
with
36 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
tool/src/main/java/lanchon/dexpatcher/core/util/ElementalTypeRewriter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* DexPatcher - Copyright 2015-2019 Rodrigo Balerdi | ||
* (GNU General Public License version 3 or later) | ||
* | ||
* DexPatcher is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published | ||
* by the Free Software Foundation, either version 3 of the License, | ||
* or (at your option) any later version. | ||
*/ | ||
|
||
package lanchon.dexpatcher.core.util; | ||
|
||
import org.jf.dexlib2.rewriter.TypeRewriter; | ||
|
||
public abstract class ElementalTypeRewriter extends TypeRewriter { | ||
|
||
@Override | ||
public String rewrite(String value) { | ||
int length = value.length(); | ||
if (length == 0 || value.charAt(0) != '[') return rewriteElementalType(value); | ||
int start = 1; | ||
while (start < length && value.charAt(start) == '[') start++; | ||
String elementalType = value.substring(start); | ||
String rewrittenElementalType = rewriteElementalType(elementalType); | ||
if (rewrittenElementalType.equals(elementalType)) return value; | ||
StringBuilder sb = new StringBuilder(start + rewrittenElementalType.length()); | ||
sb.append(value, 0, start).append(rewrittenElementalType); | ||
return sb.toString(); | ||
} | ||
|
||
public abstract String rewriteElementalType(String elementalType); | ||
|
||
} |