RenameClassAdapter extends ClassAdapter { String renameInternalType(String type) { if (type == null) { return null; } if (type.equals(mOldName)) { return mNewName; } if (mOldBase != mOldName && type.equals(mOldBase)) { return mNewBase; } int pos = type.indexOf('$'); if (pos == mOldBase.length() && type.startsWith(mOldBase)) { return mNewBase + type.substring(pos); } if (type.indexOf(';') > 0) { type = renameTypeDesc(type); } return type; } RenameClassAdapter(ClassWriter cv, String oldName, String newName); @Override void visit(int version, int access, String name, String signature,
            String superName, String[] interfaces); @Override void visitInnerClass(String name, String outerName, String innerName, int access); @Override MethodVisitor visitMethod(int access, String name, String desc,
            String signature, String[] exceptions); @Override AnnotationVisitor visitAnnotation(String desc, boolean visible); @Override FieldVisitor visitField(int access, String name, String desc,
            String signature, Object value);  }
@Test public void testRenameInternalType() { assertEquals("Lorg.blah.New;", mOuter.renameInternalType("Lcom.pack.Old;")); assertEquals("Lorg.blah.New$Inner;", mOuter.renameInternalType("Lcom.pack.Old$Inner;")); assertEquals("org.blah.New", mOuter.renameInternalType("com.pack.Old")); assertEquals("org.blah.New$Inner", mOuter.renameInternalType("com.pack.Old$Inner")); assertEquals("org.blah.New$Other", mInner.renameInternalType("com.pack.Old$Other")); assertEquals("org.blah.New$Other", mInner.renameInternalType("com.pack.Old$Other")); }