diff options
| author | 2015-01-19 23:14:30 -0500 | |
|---|---|---|
| committer | 2015-01-19 23:14:30 -0500 | |
| commit | c5b7e0ffd03259660221020250bb80cc4006c01e (patch) | |
| tree | 51669f0c498ab83abb91fd5287b96a361b9357db /src | |
| parent | solved tricky issue with incorrect translation of fields/methods referenced b... (diff) | |
| download | enigma-c5b7e0ffd03259660221020250bb80cc4006c01e.tar.gz enigma-c5b7e0ffd03259660221020250bb80cc4006c01e.tar.xz enigma-c5b7e0ffd03259660221020250bb80cc4006c01e.zip | |
fixed M3L-related issues with translation index
Diffstat (limited to 'src')
| -rw-r--r-- | src/cuchaz/enigma/analysis/TranslationIndex.java | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/src/cuchaz/enigma/analysis/TranslationIndex.java b/src/cuchaz/enigma/analysis/TranslationIndex.java index 4a356eb6..7597c3ae 100644 --- a/src/cuchaz/enigma/analysis/TranslationIndex.java +++ b/src/cuchaz/enigma/analysis/TranslationIndex.java | |||
| @@ -10,10 +10,18 @@ | |||
| 10 | ******************************************************************************/ | 10 | ******************************************************************************/ |
| 11 | package cuchaz.enigma.analysis; | 11 | package cuchaz.enigma.analysis; |
| 12 | 12 | ||
| 13 | import java.io.IOException; | ||
| 14 | import java.io.InputStream; | ||
| 15 | import java.io.ObjectInputStream; | ||
| 16 | import java.io.ObjectOutputStream; | ||
| 17 | import java.io.OutputStream; | ||
| 13 | import java.io.Serializable; | 18 | import java.io.Serializable; |
| 19 | import java.util.HashMap; | ||
| 14 | import java.util.List; | 20 | import java.util.List; |
| 15 | import java.util.Map; | 21 | import java.util.Map; |
| 16 | import java.util.Set; | 22 | import java.util.Set; |
| 23 | import java.util.zip.GZIPInputStream; | ||
| 24 | import java.util.zip.GZIPOutputStream; | ||
| 17 | 25 | ||
| 18 | import javassist.CtBehavior; | 26 | import javassist.CtBehavior; |
| 19 | import javassist.CtClass; | 27 | import javassist.CtClass; |
| @@ -81,7 +89,7 @@ public class TranslationIndex implements Serializable { | |||
| 81 | 89 | ||
| 82 | // add the superclass | 90 | // add the superclass |
| 83 | ClassEntry superclassEntry = JavassistUtil.getSuperclassEntry(c); | 91 | ClassEntry superclassEntry = JavassistUtil.getSuperclassEntry(c); |
| 84 | if (!isJre(classEntry) && !isJre(superclassEntry)) { | 92 | if (!isJre(classEntry) && superclassEntry != null && !isJre(superclassEntry)) { |
| 85 | m_superclasses.put(classEntry, superclassEntry); | 93 | m_superclasses.put(classEntry, superclassEntry); |
| 86 | } | 94 | } |
| 87 | 95 | ||
| @@ -190,6 +198,30 @@ public class TranslationIndex implements Serializable { | |||
| 190 | } | 198 | } |
| 191 | 199 | ||
| 192 | private boolean isJre(ClassEntry classEntry) { | 200 | private boolean isJre(ClassEntry classEntry) { |
| 193 | return classEntry.getPackageName().startsWith("java") || classEntry.getPackageName().startsWith("javax"); | 201 | String packageName = classEntry.getPackageName(); |
| 202 | return packageName != null && (packageName.startsWith("java") || packageName.startsWith("javax")); | ||
| 203 | } | ||
| 204 | |||
| 205 | public void write(OutputStream out) | ||
| 206 | throws IOException { | ||
| 207 | GZIPOutputStream gzipout = new GZIPOutputStream(out); | ||
| 208 | ObjectOutputStream oout = new ObjectOutputStream(gzipout); | ||
| 209 | oout.writeObject(m_superclasses); | ||
| 210 | oout.writeObject(m_fieldEntries); | ||
| 211 | oout.writeObject(m_behaviorEntries); | ||
| 212 | gzipout.finish(); | ||
| 213 | } | ||
| 214 | |||
| 215 | @SuppressWarnings("unchecked") | ||
| 216 | public void read(InputStream in) | ||
| 217 | throws IOException { | ||
| 218 | try { | ||
| 219 | ObjectInputStream oin = new ObjectInputStream(new GZIPInputStream(in)); | ||
| 220 | m_superclasses = (HashMap<ClassEntry,ClassEntry>)oin.readObject(); | ||
| 221 | m_fieldEntries = (HashMultimap<ClassEntry,FieldEntry>)oin.readObject(); | ||
| 222 | m_behaviorEntries = (HashMultimap<ClassEntry,BehaviorEntry>)oin.readObject(); | ||
| 223 | } catch (ClassNotFoundException ex) { | ||
| 224 | throw new Error(ex); | ||
| 225 | } | ||
| 194 | } | 226 | } |
| 195 | } | 227 | } |