diff options
Diffstat (limited to 'src/cuchaz/enigma/bytecode/InnerClassWriter.java')
| -rw-r--r-- | src/cuchaz/enigma/bytecode/InnerClassWriter.java | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/cuchaz/enigma/bytecode/InnerClassWriter.java b/src/cuchaz/enigma/bytecode/InnerClassWriter.java index a061792..5e59307 100644 --- a/src/cuchaz/enigma/bytecode/InnerClassWriter.java +++ b/src/cuchaz/enigma/bytecode/InnerClassWriter.java | |||
| @@ -18,6 +18,7 @@ import javassist.bytecode.ConstPool; | |||
| 18 | import javassist.bytecode.Descriptor; | 18 | import javassist.bytecode.Descriptor; |
| 19 | import javassist.bytecode.EnclosingMethodAttribute; | 19 | import javassist.bytecode.EnclosingMethodAttribute; |
| 20 | import javassist.bytecode.InnerClassesAttribute; | 20 | import javassist.bytecode.InnerClassesAttribute; |
| 21 | import cuchaz.enigma.Constants; | ||
| 21 | import cuchaz.enigma.analysis.JarIndex; | 22 | import cuchaz.enigma.analysis.JarIndex; |
| 22 | import cuchaz.enigma.mapping.BehaviorEntry; | 23 | import cuchaz.enigma.mapping.BehaviorEntry; |
| 23 | import cuchaz.enigma.mapping.ClassEntry; | 24 | import cuchaz.enigma.mapping.ClassEntry; |
| @@ -33,21 +34,21 @@ public class InnerClassWriter | |||
| 33 | 34 | ||
| 34 | public void write( CtClass c ) | 35 | public void write( CtClass c ) |
| 35 | { | 36 | { |
| 36 | // get the outer class name | 37 | // is this an inner or outer class? |
| 37 | String obfClassName = Descriptor.toJvmName( c.getName() ); | 38 | String obfInnerClassName = new ClassEntry( Descriptor.toJvmName( c.getName() ) ).getSimpleName(); |
| 38 | String obfOuterClassName = m_jarIndex.getOuterClass( obfClassName ); | 39 | String obfOuterClassName = m_jarIndex.getOuterClass( obfInnerClassName ); |
| 39 | if( obfOuterClassName == null ) | 40 | if( obfOuterClassName == null ) |
| 40 | { | 41 | { |
| 41 | // this is an outer class | 42 | // this is an outer class |
| 42 | obfOuterClassName = obfClassName; | 43 | obfOuterClassName = Descriptor.toJvmName( c.getName() ); |
| 43 | } | 44 | } |
| 44 | else | 45 | else |
| 45 | { | 46 | { |
| 46 | // this is an inner class, rename it to outer$inner | 47 | // this is an inner class, rename it to outer$inner |
| 47 | ClassEntry obfClassEntry = new ClassEntry( obfOuterClassName + "$" + new ClassEntry( obfClassName ).getSimpleName() ); | 48 | ClassEntry obfClassEntry = new ClassEntry( obfOuterClassName + "$" + obfInnerClassName ); |
| 48 | c.setName( obfClassEntry.getName() ); | 49 | c.setName( obfClassEntry.getName() ); |
| 49 | 50 | ||
| 50 | BehaviorEntry caller = m_jarIndex.getAnonymousClassCaller( obfClassName ); | 51 | BehaviorEntry caller = m_jarIndex.getAnonymousClassCaller( obfInnerClassName ); |
| 51 | if( caller != null ) | 52 | if( caller != null ) |
| 52 | { | 53 | { |
| 53 | // write the enclosing method attribute | 54 | // write the enclosing method attribute |
| @@ -85,7 +86,7 @@ public class InnerClassWriter | |||
| 85 | for( String obfInnerClassName : obfInnerClassNames ) | 86 | for( String obfInnerClassName : obfInnerClassNames ) |
| 86 | { | 87 | { |
| 87 | // get the new inner class name | 88 | // get the new inner class name |
| 88 | ClassEntry obfClassEntry = new ClassEntry( obfOuterClassName + "$" + new ClassEntry( obfInnerClassName ).getSimpleName() ); | 89 | ClassEntry obfClassEntry = new ClassEntry( obfOuterClassName + "$" + obfInnerClassName ); |
| 89 | 90 | ||
| 90 | // here's what the JVM spec says about the InnerClasses attribute | 91 | // here's what the JVM spec says about the InnerClasses attribute |
| 91 | // append( inner, outer of inner if inner is member of outer 0 ow, name after $ if inner not anonymous 0 ow, flags ); | 92 | // append( inner, outer of inner if inner is member of outer 0 ow, name after $ if inner not anonymous 0 ow, flags ); |
| @@ -114,12 +115,13 @@ public class InnerClassWriter | |||
| 114 | attr.outerClass( attr.tableLength() - 1 ), | 115 | attr.outerClass( attr.tableLength() - 1 ), |
| 115 | attr.innerClass( attr.tableLength() - 1 ), | 116 | attr.innerClass( attr.tableLength() - 1 ), |
| 116 | attr.innerName( attr.tableLength() - 1 ), | 117 | attr.innerName( attr.tableLength() - 1 ), |
| 117 | obfInnerClassName, obfClassEntry.getName() | 118 | Constants.NonePackage + "/" + obfInnerClassName, |
| 119 | obfClassEntry.getName() | ||
| 118 | ) ); | 120 | ) ); |
| 119 | */ | 121 | */ |
| 120 | 122 | ||
| 121 | // make sure the outer class references only the new inner class names | 123 | // make sure the outer class references only the new inner class names |
| 122 | c.replaceClassName( obfInnerClassName, obfClassEntry.getName() ); | 124 | c.replaceClassName( Constants.NonePackage + "/" + obfInnerClassName, obfClassEntry.getName() ); |
| 123 | } | 125 | } |
| 124 | } | 126 | } |
| 125 | } | 127 | } |