diff options
| author | 2015-03-23 16:26:11 -0400 | |
|---|---|---|
| committer | 2015-03-23 16:26:11 -0400 | |
| commit | 106cb7a2a2e980d596dcfaa5d331ae8b933b6f48 (patch) | |
| tree | 4b8a82b23299a7541bfe24c94dbedc41ddc1d0c4 | |
| parent | Added tag v0.10.2 beta for changeset 681fde332949 (diff) | |
| download | enigma-106cb7a2a2e980d596dcfaa5d331ae8b933b6f48.tar.gz enigma-106cb7a2a2e980d596dcfaa5d331ae8b933b6f48.tar.xz enigma-106cb7a2a2e980d596dcfaa5d331ae8b933b6f48.zip | |
skip writing InnerClasses attribute if there's already one there
just translate the existing one
| -rw-r--r-- | src/cuchaz/enigma/bytecode/InnerClassWriter.java | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/cuchaz/enigma/bytecode/InnerClassWriter.java b/src/cuchaz/enigma/bytecode/InnerClassWriter.java index 0c11b71b..9cdfd685 100644 --- a/src/cuchaz/enigma/bytecode/InnerClassWriter.java +++ b/src/cuchaz/enigma/bytecode/InnerClassWriter.java | |||
| @@ -16,6 +16,7 @@ import java.util.List; | |||
| 16 | import com.google.common.collect.Lists; | 16 | import com.google.common.collect.Lists; |
| 17 | 17 | ||
| 18 | import javassist.CtClass; | 18 | import javassist.CtClass; |
| 19 | import javassist.bytecode.AccessFlag; | ||
| 19 | import javassist.bytecode.ConstPool; | 20 | import javassist.bytecode.ConstPool; |
| 20 | import javassist.bytecode.EnclosingMethodAttribute; | 21 | import javassist.bytecode.EnclosingMethodAttribute; |
| 21 | import javassist.bytecode.InnerClassesAttribute; | 22 | import javassist.bytecode.InnerClassesAttribute; |
| @@ -34,6 +35,13 @@ public class InnerClassWriter { | |||
| 34 | 35 | ||
| 35 | public void write(CtClass c) { | 36 | public void write(CtClass c) { |
| 36 | 37 | ||
| 38 | // don't change anything if there's already an attribute there | ||
| 39 | InnerClassesAttribute oldAttr = (InnerClassesAttribute)c.getClassFile().getAttribute(InnerClassesAttribute.tag); | ||
| 40 | if (oldAttr != null) { | ||
| 41 | // bail! | ||
| 42 | return; | ||
| 43 | } | ||
| 44 | |||
| 37 | ClassEntry obfClassEntry = EntryFactory.getClassEntry(c); | 45 | ClassEntry obfClassEntry = EntryFactory.getClassEntry(c); |
| 38 | List<ClassEntry> obfClassChain = m_index.getObfClassChain(obfClassEntry); | 46 | List<ClassEntry> obfClassChain = m_index.getObfClassChain(obfClassEntry); |
| 39 | 47 | ||
| @@ -102,7 +110,8 @@ public class InnerClassWriter { | |||
| 102 | int innerClassIndex = constPool.addClassInfo(obfInnerClassEntry.getName()); | 110 | int innerClassIndex = constPool.addClassInfo(obfInnerClassEntry.getName()); |
| 103 | int parentClassIndex = constPool.addClassInfo(obfOuterClassEntry.getName()); | 111 | int parentClassIndex = constPool.addClassInfo(obfOuterClassEntry.getName()); |
| 104 | int innerClassNameIndex = 0; | 112 | int innerClassNameIndex = 0; |
| 105 | int accessFlags = 0; | 113 | int accessFlags = AccessFlag.PUBLIC; |
| 114 | // TODO: need to figure out if we can put static or not | ||
| 106 | if (!m_index.isAnonymousClass(obfClassEntry)) { | 115 | if (!m_index.isAnonymousClass(obfClassEntry)) { |
| 107 | innerClassNameIndex = constPool.addUtf8Info(obfInnerClassEntry.getInnermostClassName()); | 116 | innerClassNameIndex = constPool.addUtf8Info(obfInnerClassEntry.getInnermostClassName()); |
| 108 | } | 117 | } |