diff options
| author | 2014-09-24 20:32:19 -0400 | |
|---|---|---|
| committer | 2014-09-24 20:32:19 -0400 | |
| commit | 064fe6a628f23f21eb2c8f584215f439e54cfaec (patch) | |
| tree | 733f840aca8dca170e9403de51be256b24ed00b2 /src/cuchaz/enigma/bytecode/ClassTranslator.java | |
| parent | HOW DO I WRITE SO MANY BUGS?!? (diff) | |
| download | enigma-fork-064fe6a628f23f21eb2c8f584215f439e54cfaec.tar.gz enigma-fork-064fe6a628f23f21eb2c8f584215f439e54cfaec.tar.xz enigma-fork-064fe6a628f23f21eb2c8f584215f439e54cfaec.zip | |
fixed in-jar detection for bridge-related methods
Diffstat (limited to 'src/cuchaz/enigma/bytecode/ClassTranslator.java')
| -rw-r--r-- | src/cuchaz/enigma/bytecode/ClassTranslator.java | 41 |
1 files changed, 18 insertions, 23 deletions
diff --git a/src/cuchaz/enigma/bytecode/ClassTranslator.java b/src/cuchaz/enigma/bytecode/ClassTranslator.java index 8892692..db28f21 100644 --- a/src/cuchaz/enigma/bytecode/ClassTranslator.java +++ b/src/cuchaz/enigma/bytecode/ClassTranslator.java | |||
| @@ -21,6 +21,8 @@ import javassist.bytecode.Descriptor; | |||
| 21 | 21 | ||
| 22 | import com.google.common.collect.Maps; | 22 | import com.google.common.collect.Maps; |
| 23 | 23 | ||
| 24 | import cuchaz.enigma.mapping.BehaviorEntry; | ||
| 25 | import cuchaz.enigma.mapping.BehaviorEntryFactory; | ||
| 24 | import cuchaz.enigma.mapping.ClassEntry; | 26 | import cuchaz.enigma.mapping.ClassEntry; |
| 25 | import cuchaz.enigma.mapping.FieldEntry; | 27 | import cuchaz.enigma.mapping.FieldEntry; |
| 26 | import cuchaz.enigma.mapping.MethodEntry; | 28 | import cuchaz.enigma.mapping.MethodEntry; |
| @@ -53,19 +55,15 @@ public class ClassTranslator | |||
| 53 | new ClassEntry( Descriptor.toJvmName( constants.getFieldrefClassName( i ) ) ), | 55 | new ClassEntry( Descriptor.toJvmName( constants.getFieldrefClassName( i ) ) ), |
| 54 | constants.getFieldrefName( i ) | 56 | constants.getFieldrefName( i ) |
| 55 | ); | 57 | ); |
| 56 | String translatedName = m_translator.translate( entry ); | 58 | FieldEntry translatedEntry = m_translator.translateEntry( entry ); |
| 57 | if( translatedName == null ) | ||
| 58 | { | ||
| 59 | translatedName = entry.getName(); | ||
| 60 | } | ||
| 61 | 59 | ||
| 62 | // translate the type | 60 | // translate the type |
| 63 | String type = constants.getFieldrefType( i ); | 61 | String type = constants.getFieldrefType( i ); |
| 64 | String translatedType = m_translator.translateSignature( type ); | 62 | String translatedType = m_translator.translateSignature( type ); |
| 65 | 63 | ||
| 66 | if( !entry.getName().equals( translatedName ) || !type.equals( translatedType ) ) | 64 | if( !entry.equals( translatedEntry ) || !type.equals( translatedType ) ) |
| 67 | { | 65 | { |
| 68 | editor.changeMemberrefNameAndType( i, translatedName, translatedType ); | 66 | editor.changeMemberrefNameAndType( i, translatedEntry.getName(), translatedType ); |
| 69 | } | 67 | } |
| 70 | } | 68 | } |
| 71 | break; | 69 | break; |
| @@ -74,21 +72,16 @@ public class ClassTranslator | |||
| 74 | case ConstPool.CONST_InterfaceMethodref: | 72 | case ConstPool.CONST_InterfaceMethodref: |
| 75 | { | 73 | { |
| 76 | // translate the name and type | 74 | // translate the name and type |
| 77 | MethodEntry entry = new MethodEntry( | 75 | BehaviorEntry entry = BehaviorEntryFactory.create( |
| 78 | new ClassEntry( Descriptor.toJvmName( editor.getMemberrefClassname( i ) ) ), | 76 | Descriptor.toJvmName( editor.getMemberrefClassname( i ) ), |
| 79 | editor.getMemberrefName( i ), | 77 | editor.getMemberrefName( i ), |
| 80 | editor.getMemberrefType( i ) | 78 | editor.getMemberrefType( i ) |
| 81 | ); | 79 | ); |
| 82 | String translatedName = m_translator.translate( entry ); | 80 | BehaviorEntry translatedEntry = m_translator.translateEntry( entry ); |
| 83 | if( translatedName == null ) | ||
| 84 | { | ||
| 85 | translatedName = entry.getName(); | ||
| 86 | } | ||
| 87 | String translatedSignature = m_translator.translateSignature( entry.getSignature() ); | ||
| 88 | 81 | ||
| 89 | if( !entry.getName().equals( translatedName ) || !entry.getSignature().equals( translatedSignature ) ) | 82 | if( !entry.getName().equals( translatedEntry.getName() ) || !entry.getSignature().equals( translatedEntry.getSignature() ) ) |
| 90 | { | 83 | { |
| 91 | editor.changeMemberrefNameAndType( i, translatedName, translatedSignature ); | 84 | editor.changeMemberrefNameAndType( i, translatedEntry.getName(), translatedEntry.getSignature() ); |
| 92 | } | 85 | } |
| 93 | } | 86 | } |
| 94 | break; | 87 | break; |
| @@ -116,14 +109,16 @@ public class ClassTranslator | |||
| 116 | // translate all the methods and constructors | 109 | // translate all the methods and constructors |
| 117 | for( CtBehavior behavior : c.getDeclaredBehaviors() ) | 110 | for( CtBehavior behavior : c.getDeclaredBehaviors() ) |
| 118 | { | 111 | { |
| 119 | // translate the name | 112 | if( behavior instanceof CtMethod ) |
| 120 | MethodEntry entry = new MethodEntry( classEntry, behavior.getName(), behavior.getSignature() ); | ||
| 121 | String translatedName = m_translator.translate( entry ); | ||
| 122 | if( translatedName != null ) | ||
| 123 | { | 113 | { |
| 124 | if( behavior instanceof CtMethod ) | 114 | CtMethod method = (CtMethod)behavior; |
| 115 | |||
| 116 | // translate the name | ||
| 117 | MethodEntry entry = new MethodEntry( classEntry, method.getName(), method.getSignature() ); | ||
| 118 | String translatedName = m_translator.translate( entry ); | ||
| 119 | if( translatedName != null ) | ||
| 125 | { | 120 | { |
| 126 | ((CtMethod)behavior).setName( translatedName ); | 121 | method.setName( translatedName ); |
| 127 | } | 122 | } |
| 128 | } | 123 | } |
| 129 | 124 | ||