Actually remap inner class names

parent 63253d4a
Pipeline #2603 passed with stage
in 7 minutes and 19 seconds
......@@ -165,10 +165,13 @@ public class ClassRemapper extends ClassVisitor {
@Override
public void visitInnerClass(
final String name, final String outerName, final String innerName, final int access) {
final String remappedInnerName = remapper.mapType(name);
super.visitInnerClass(
remapper.mapType(name),
outerName == null ? null : remapper.mapType(outerName),
innerName,
innerName == null
? null
: remappedInnerName.substring(remappedInnerName.lastIndexOf('$') + 1),
access);
}
......
......@@ -58,6 +58,26 @@ public class ClassRemapperTest extends AsmTest {
assertEquals("new/pkg/C", classNode.name);
}
@Test
public void testRenameInnerClass() {
final ClassNode node = new ClassNode();
final ClassRemapper remapper =
new ClassRemapper(
node,
new Remapper() {
@Override
public String map(final String internalName) {
if ("a".equals(internalName)) return "pkg/Demo";
if ("a$g".equals(internalName)) return "pkg/Demo$Container";
return internalName;
}
});
remapper.visit(Opcodes.V1_5, Opcodes.ACC_PUBLIC, "a", null, "java/lang/Object", null);
remapper.visitInnerClass("a$g", "a", "g", Opcodes.ACC_PUBLIC);
assertEquals("pkg/Demo", node.innerClasses.get(0).outerName);
assertEquals("Container", node.innerClasses.get(0).innerName);
}
@Test
public void testRenameModuleHashes() {
ClassNode classNode = new ClassNode();
......
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