Unverified Commit 2db91a42 authored by Jamie Mansfield's avatar Jamie Mansfield
Browse files

Actually remap inner class names

parent 63253d4a
Pipeline #2604 passed with stage
in 7 minutes
......@@ -168,7 +168,7 @@ public class ClassRemapper extends ClassVisitor {
outerName == null ? null : remapper.mapType(outerName),
innerName == null ? null : remapper.mapInnerClassName(name, outerName, innerName),
......@@ -214,6 +214,26 @@ public abstract class Remapper {
return new SignatureRemapper(signatureVisitor, this);
* Maps an inner class name to its new name. The default implementation of this method provides a
* strategy that will work for inner classes produced by Java, but not necessarily other
* languages. Subclasses can override.
* @param name the fully-qualified internal name of the inner class.
* @param ownerName the internal name of the owner class of the inner class.
* @param innerName the internal name of the inner class.
* @return the new inner name of the inner class.
public String mapInnerClassName(
final String name, final String ownerName, final String innerName) {
final String remappedInnerName = this.mapType(name);
if (remappedInnerName.contains("$")) {
return remappedInnerName.substring(remappedInnerName.lastIndexOf('$') + 1);
} else {
return innerName;
* Maps a method name to its new name. The default implementation of this method returns the given
* name, unchanged. Subclasses can override.
......@@ -58,6 +58,26 @@ public class ClassRemapperTest extends AsmTest {
assertEquals("new/pkg/C", classNode.name);
public void testRenameInnerClass() {
final ClassNode node = new ClassNode();
final ClassRemapper remapper =
new ClassRemapper(
new Remapper() {
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);
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