From 873fcef956fd5140ee0a31da45a23f80c52e8714 Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 2 Jun 1999 20:22:23 +0000 Subject: [PATCH] correct inner/outer class handling git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@827 379699f6-c40d-0410-875b-85095c16579e --- jode/jode/obfuscator/ClassIdentifier.java | 246 ++++++++++------------ 1 file changed, 115 insertions(+), 131 deletions(-) diff --git a/jode/jode/obfuscator/ClassIdentifier.java b/jode/jode/obfuscator/ClassIdentifier.java index f2a920c..501e8da 100644 --- a/jode/jode/obfuscator/ClassIdentifier.java +++ b/jode/jode/obfuscator/ClassIdentifier.java @@ -184,7 +184,7 @@ public class ClassIdentifier extends Identifier { } ClassInfo[] ifaces = superclass.getInterfaces(); for (int i=0; i < ifaces.length; i++) - initSuperClasses(ifaces[i]); + analyzeSuperClasses(ifaces[i]); superclass = superclass.getSuperclass(); } } @@ -194,20 +194,9 @@ public class ClassIdentifier extends Identifier { GlobalOptions.err.println("Reachable: "+this); ClassInfo[] ifaces = info.getInterfaces(); - ifaceNames = new String[ifaces.length]; - for (int i=0; i < ifaces.length; i++) { - ifaceNames[i] = ifaces[i].getName(); - ClassIdentifier ifaceident - = bundle.getClassIdentifier(ifaceNames[i]); + for (int i=0; i < ifaces.length; i++) analyzeSuperClasses(ifaces[i]); - } - - if (info.getSuperclass() != null) { - superName = info.getSuperclass().getName(); - ClassIdentifier superident - = bundle.getClassIdentifier(superName); - analyzeSuperClasses(info.getSuperclass()); - } + analyzeSuperClasses(info.getSuperclass()); } public void initSuperClasses(ClassInfo superclass) { @@ -301,6 +290,7 @@ public class ClassIdentifier extends Identifier { identifiers[fieldCount + i].setPreserved(); } + // preserve / chain inherited methods and fields. ClassInfo[] ifaces = info.getInterfaces(); ifaceNames = new String[ifaces.length]; for (int i=0; i < ifaces.length; i++) { @@ -404,148 +394,142 @@ public class ClassIdentifier extends Identifier { } public void transformInnerClasses() { - InnerClassInfo[] innerClasses = info.getInnerClasses(); InnerClassInfo[] outerClasses = info.getOuterClasses(); - InnerClassInfo[] extraClasses = info.getExtraClasses(); - if (innerClasses == null && outerClasses == null - && extraClasses == null) - return; - - int newInnerCount, newOuterCount, newExtraCount; - if (Obfuscator.shouldStrip) { - newInnerCount = newOuterCount = newExtraCount = 0; - if (outerClasses != null) { + if (outerClasses != null) { + int newOuterCount = outerClasses.length; + if (Obfuscator.shouldStrip) { for (int i=0; i < outerClasses.length; i++) { if (outerClasses[i].outer != null) { ClassIdentifier outerIdent = bundle.getClassIdentifier(outerClasses[i].outer); - if (outerIdent == null || outerIdent.isReachable()) - newOuterCount++; - } else - newOuterCount++; + if (outerIdent != null && !outerIdent.isReachable()) + newOuterCount--; + } } } - if (innerClasses != null) { + if (newOuterCount == 0) { + info.setOuterClasses(null); + } else { + InnerClassInfo[] newOuters = new InnerClassInfo[newOuterCount]; + int pos = 0; + String lastClass = getFullAlias(); + for (int i=0; i 0 - ? new InnerClassInfo[newInnerCount] : null; - InnerClassInfo[] newOuters = newOuterCount > 0 - ? new InnerClassInfo[newOuterCount] : null; - InnerClassInfo[] newExtras = newExtraCount > 0 - ? new InnerClassInfo[newExtraCount] : null; - - if (newInners != null) { - int pos = 0; - for (int i=0; i 0 + ? new InnerClassInfo[newExtraCount] : null; - if (outerIdent != null && !outerIdent.isReachable()) - continue; - - String inner = lastClass; - String outer = outerIdent == null - ? outerClasses[i].outer : outerIdent.getFullAlias(); - String name; - lastClass = outer; - if (outerClasses[i].name == null) - /* This is an anonymous class */ - name = null; - else if (outer != null && inner.startsWith(outer+"$")) - name = inner.substring(outer.length()+1); - else - name = inner.substring(inner.lastIndexOf('.')+1); - newOuters[pos++] = new InnerClassInfo - (inner, outer, name, outerClasses[i].modifiers); - } - } - if (newExtras != null) { - int pos = 0; - for (int i=0; i