|
|
@ -170,12 +170,10 @@ public class ClassIdentifier extends Identifier { |
|
|
|
& modif) == 0 |
|
|
|
& modif) == 0 |
|
|
|
&& !topmethods[i].getName().equals("<init>")) { |
|
|
|
&& !topmethods[i].getName().equals("<init>")) { |
|
|
|
reachableIdentifier |
|
|
|
reachableIdentifier |
|
|
|
(topmethods[i].getName(), |
|
|
|
(topmethods[i].getName(), topmethods[i].getType(), |
|
|
|
topmethods[i].getType().getTypeSignature(), |
|
|
|
|
|
|
|
true); |
|
|
|
true); |
|
|
|
preserveIdentifier |
|
|
|
preserveIdentifier |
|
|
|
(topmethods[i].getName(), |
|
|
|
(topmethods[i].getName(), topmethods[i].getType()); |
|
|
|
topmethods[i].getType().getTypeSignature()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -288,13 +286,10 @@ public class ClassIdentifier extends Identifier { |
|
|
|
for (int i=0; i < ifaces.length; i++) { |
|
|
|
for (int i=0; i < ifaces.length; i++) { |
|
|
|
ClassIdentifier ifaceident |
|
|
|
ClassIdentifier ifaceident |
|
|
|
= bundle.getClassIdentifier(ifaces[i].getName()); |
|
|
|
= bundle.getClassIdentifier(ifaces[i].getName()); |
|
|
|
if (ifaceident != null) { |
|
|
|
if (ifaceident != null && !ifaceident.isReachable()) |
|
|
|
if (!Obfuscator.shouldStrip || ifaceident.isReachable()) |
|
|
|
addIfaces(result, ifaceident.info.getInterfaces()); |
|
|
|
result.addElement(ifaceident.getFullAlias()); |
|
|
|
else |
|
|
|
else |
|
|
|
result.addElement(ifaces[i]); |
|
|
|
addIfaces(result, ifaceident.info.getInterfaces()); |
|
|
|
|
|
|
|
} else |
|
|
|
|
|
|
|
result.addElement(ifaces[i].getName()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -305,104 +300,68 @@ public class ClassIdentifier extends Identifier { |
|
|
|
* where the first entry is the super class (may be null) and the |
|
|
|
* where the first entry is the super class (may be null) and the |
|
|
|
* other entries are the interfaces. |
|
|
|
* other entries are the interfaces. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public String[] getSuperIfaces() { |
|
|
|
public void transformSuperIfaces() { |
|
|
|
/* First generate Ifaces and superclass infos */ |
|
|
|
if (!Obfuscator.shouldStrip) |
|
|
|
Vector newSuperIfaces = new Vector(); |
|
|
|
return; |
|
|
|
addIfaces(newSuperIfaces, info.getInterfaces()); |
|
|
|
|
|
|
|
String superName = null; |
|
|
|
Vector newIfaces = new Vector(); |
|
|
|
|
|
|
|
addIfaces(newIfaces, info.getInterfaces()); |
|
|
|
ClassInfo superClass = info.getSuperclass(); |
|
|
|
ClassInfo superClass = info.getSuperclass(); |
|
|
|
while (superClass != null) { |
|
|
|
while (superClass != null) { |
|
|
|
ClassIdentifier superident |
|
|
|
ClassIdentifier superident |
|
|
|
= bundle.getClassIdentifier(superClass.getName()); |
|
|
|
= bundle.getClassIdentifier(superClass.getName()); |
|
|
|
if (superident != null) { |
|
|
|
if (superident == null || superident.isReachable()) |
|
|
|
if (!Obfuscator.shouldStrip || superident.isReachable()) { |
|
|
|
|
|
|
|
superName = superident.getFullAlias(); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
addIfaces(newSuperIfaces, superClass.getInterfaces()); |
|
|
|
|
|
|
|
superClass = superClass.getSuperclass(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
superName = superClass.getName(); |
|
|
|
|
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
addIfaces(newIfaces, superClass.getInterfaces()); |
|
|
|
|
|
|
|
superClass = superClass.getSuperclass(); |
|
|
|
} |
|
|
|
} |
|
|
|
newSuperIfaces.insertElementAt(superName, 0); |
|
|
|
ClassInfo[] ifaces = new ClassInfo[newIfaces.size()]; |
|
|
|
String[] result = new String[newSuperIfaces.size()]; |
|
|
|
newIfaces.copyInto(ifaces); |
|
|
|
newSuperIfaces.copyInto(result); |
|
|
|
info.setSuperclass(superClass); |
|
|
|
return result; |
|
|
|
info.setInterfaces(ifaces); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void storeClass(DataOutputStream out) throws IOException { |
|
|
|
public void doTransformations() { |
|
|
|
if (Obfuscator.verboseLevel > 0) |
|
|
|
if (Obfuscator.verboseLevel > 0) |
|
|
|
Obfuscator.err.println("Writing "+this); |
|
|
|
Obfuscator.err.println("Transforming "+this); |
|
|
|
GrowableConstantPool gcp = new GrowableConstantPool(); |
|
|
|
info.setName(getFullAlias()); |
|
|
|
|
|
|
|
transformSuperIfaces(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int newFieldCount = 0, newMethodCount = 0; |
|
|
|
|
|
|
|
for (int i=0; i < fieldCount; i++) |
|
|
|
|
|
|
|
if (!Obfuscator.shouldStrip || identifiers[i].isReachable()) |
|
|
|
|
|
|
|
newFieldCount++; |
|
|
|
for (int i=fieldCount; i < identifiers.length; i++) |
|
|
|
for (int i=fieldCount; i < identifiers.length; i++) |
|
|
|
if (!Obfuscator.shouldStrip || identifiers[i].isReachable()) |
|
|
|
if (!Obfuscator.shouldStrip || identifiers[i].isReachable()) |
|
|
|
((MethodIdentifier)identifiers[i]).doCodeTransformations(gcp); |
|
|
|
newMethodCount++; |
|
|
|
|
|
|
|
|
|
|
|
int[] hierarchyInts; |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
String[] hierarchy = getSuperIfaces(); |
|
|
|
|
|
|
|
hierarchyInts = new int[hierarchy.length]; |
|
|
|
|
|
|
|
for (int i=0; i< hierarchy.length; i++) { |
|
|
|
|
|
|
|
if (hierarchy[i] != null) |
|
|
|
|
|
|
|
hierarchyInts[i] = gcp.putClassName(hierarchy[i]); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
hierarchyInts[i] = 0; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
hierarchy = null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
int nameIndex = gcp.putClassName(getFullAlias()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int fields = 0; |
|
|
|
FieldInfo[] newFields = new FieldInfo[newFieldCount]; |
|
|
|
int methods = 0; |
|
|
|
MethodInfo[] newMethods = new MethodInfo[newMethodCount]; |
|
|
|
|
|
|
|
newFieldCount = newMethodCount = 0; |
|
|
|
|
|
|
|
|
|
|
|
for (int i=0; i<fieldCount; i++) { |
|
|
|
for (int i=0; i < fieldCount; i++) { |
|
|
|
if (!Obfuscator.shouldStrip || identifiers[i].isReachable()) { |
|
|
|
if (!Obfuscator.shouldStrip || identifiers[i].isReachable()) { |
|
|
|
((FieldIdentifier)identifiers[i]).fillConstantPool(gcp); |
|
|
|
((FieldIdentifier)identifiers[i]).doTransformations(); |
|
|
|
fields++; |
|
|
|
newFields[newFieldCount++] |
|
|
|
|
|
|
|
= ((FieldIdentifier)identifiers[i]).info; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
for (int i=fieldCount; i < identifiers.length; i++) { |
|
|
|
for (int i=fieldCount; i < identifiers.length; i++) { |
|
|
|
if (!Obfuscator.shouldStrip || identifiers[i].isReachable()) { |
|
|
|
if (!Obfuscator.shouldStrip || identifiers[i].isReachable()) { |
|
|
|
((MethodIdentifier)identifiers[i]).fillConstantPool(gcp); |
|
|
|
((MethodIdentifier)identifiers[i]).doTransformations(); |
|
|
|
methods++; |
|
|
|
newMethods[newMethodCount++] |
|
|
|
|
|
|
|
= ((MethodIdentifier)identifiers[i]).info; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
info.setFields(newFields); |
|
|
|
|
|
|
|
info.setMethods(newMethods); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
out.writeInt(0xcafebabe); |
|
|
|
public void storeClass(DataOutputStream out) throws IOException { |
|
|
|
out.writeShort(3); |
|
|
|
if (Obfuscator.verboseLevel > 0) |
|
|
|
out.writeShort(45); |
|
|
|
Obfuscator.err.println("Writing "+this); |
|
|
|
gcp.write(out); |
|
|
|
info.write(out); |
|
|
|
|
|
|
|
|
|
|
|
out.writeShort(info.getModifiers()); |
|
|
|
|
|
|
|
out.writeShort(nameIndex); |
|
|
|
|
|
|
|
out.writeShort(hierarchyInts[0]); |
|
|
|
|
|
|
|
out.writeShort(hierarchyInts.length-1); |
|
|
|
|
|
|
|
for (int i=1; i<hierarchyInts.length; i++) |
|
|
|
|
|
|
|
out.writeShort(hierarchyInts[i]); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
out.writeShort(fields); |
|
|
|
|
|
|
|
for (int i=0; i<fieldCount; i++) { |
|
|
|
|
|
|
|
if (!Obfuscator.shouldStrip || identifiers[i].isReachable()) |
|
|
|
|
|
|
|
((FieldIdentifier)identifiers[i]).write(out); |
|
|
|
|
|
|
|
else if (Obfuscator.isDebugging) |
|
|
|
|
|
|
|
Obfuscator.err.println(identifiers[i].toString() |
|
|
|
|
|
|
|
+ " is stripped"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
out.writeShort(methods); |
|
|
|
|
|
|
|
for (int i=fieldCount; i < identifiers.length; i++) { |
|
|
|
|
|
|
|
if (!Obfuscator.shouldStrip || identifiers[i].isReachable()) |
|
|
|
|
|
|
|
((MethodIdentifier)identifiers[i]).write(out); |
|
|
|
|
|
|
|
else if (Obfuscator.isDebugging) |
|
|
|
|
|
|
|
Obfuscator.err.println(identifiers[i].toString() |
|
|
|
|
|
|
|
+ " is stripped"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
out.writeShort(0); // no attributes;
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public Identifier getParent() { |
|
|
|
public Identifier getParent() { |
|
|
@ -475,7 +434,7 @@ public class ClassIdentifier extends Identifier { |
|
|
|
FieldInfo[] finfos = clazz.getFields(); |
|
|
|
FieldInfo[] finfos = clazz.getFields(); |
|
|
|
for (int i=0; i< finfos.length; i++) { |
|
|
|
for (int i=0; i< finfos.length; i++) { |
|
|
|
if (finfos[i].getName().equals(fieldName) |
|
|
|
if (finfos[i].getName().equals(fieldName) |
|
|
|
&& finfos[i].getType().getTypeSignature().startsWith(typeSig)) |
|
|
|
&& finfos[i].getType().startsWith(typeSig)) |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -547,8 +506,7 @@ public class ClassIdentifier extends Identifier { |
|
|
|
MethodInfo[] minfos = clazz.getMethods(); |
|
|
|
MethodInfo[] minfos = clazz.getMethods(); |
|
|
|
for (int i=0; i< minfos.length; i++) { |
|
|
|
for (int i=0; i< minfos.length; i++) { |
|
|
|
if (minfos[i].getName().equals(methodName) |
|
|
|
if (minfos[i].getName().equals(methodName) |
|
|
|
&& minfos[i].getType().getTypeSignature() |
|
|
|
&& minfos[i].getType().startsWith(paramType)) |
|
|
|
.startsWith(paramType)) |
|
|
|
|
|
|
|
return minfos[i]; |
|
|
|
return minfos[i]; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|