Commit d5f42662 authored by Ahmed Ashour's avatar Ahmed Ashour Committed by skylot

fix: rename class with reserved java keywords (#485) (PR #488)

parent 988ada3c
......@@ -92,6 +92,9 @@ public class RenameVisitor extends AbstractVisitor {
if (firstChar == '$') {
return 'C' + NameMapper.removeInvalidCharsMiddle(clsName);
}
if (!NameMapper.isValidIdentifier(clsName)) {
return 'C' + clsName;
}
return NameMapper.removeInvalidChars(clsName, "C");
}
......
package jadx.tests.integration.names;
import org.junit.Test;
import jadx.core.dex.nodes.ClassNode;
import jadx.tests.api.SmaliTest;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.not;
import static org.junit.Assert.assertThat;
import java.io.File;
public class TestReservedClassNames extends SmaliTest {
/*
public class do {
}
*/
@Test
public void test() {
ClassNode cls = getClassNodeFromSmali("names" + File.separatorChar + "TestReservedClassNames", "do");
String code = cls.getCode().toString();
assertThat(code, not(containsString("public class do")));
}
}
.class public Ldo;
.super Ljava/lang/Object;
# direct methods
.method public constructor <init>()V
.locals 0
.line 3
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
return-void
.end method
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment