cache name, type

call bundle.getReferenceAlias


git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@717 379699f6-c40d-0410-875b-85095c16579e
stable
jochen 26 years ago
parent ca01c61a18
commit 38c20744e8
  1. 48
      jode/jode/obfuscator/MethodIdentifier.java

@ -34,6 +34,8 @@ import java.util.Hashtable;
public class MethodIdentifier extends Identifier implements Opcodes { public class MethodIdentifier extends Identifier implements Opcodes {
ClassIdentifier clazz; ClassIdentifier clazz;
MethodInfo info; MethodInfo info;
String name;
String type;
///#ifdef JDK12 ///#ifdef JDK12
/// /** /// /**
@ -69,6 +71,8 @@ public class MethodIdentifier extends Identifier implements Opcodes {
public MethodIdentifier(ClassIdentifier clazz, MethodInfo info) { public MethodIdentifier(ClassIdentifier clazz, MethodInfo info) {
super(info.getName()); super(info.getName());
this.name = info.getName();
this.type = info.getType();
this.clazz = clazz; this.clazz = clazz;
this.info = info; this.info = info;
} }
@ -130,11 +134,11 @@ public class MethodIdentifier extends Identifier implements Opcodes {
} }
public String getName() { public String getName() {
return info.getName(); return name;
} }
public String getType() { public String getType() {
return info.getType(); return type;
} }
public boolean conflicting(String newAlias, boolean strong) { public boolean conflicting(String newAlias, boolean strong) {
@ -165,9 +169,14 @@ public class MethodIdentifier extends Identifier implements Opcodes {
* <li>renaming field, method and class references</li> * <li>renaming field, method and class references</li>
* </ul> * </ul>
*/ */
boolean wasTransformed = false;
public void doTransformations() { public void doTransformations() {
if (wasTransformed)
throw new jode.AssertError
("doTransformation called on transformed method");
wasTransformed = true;
info.setName(getAlias()); info.setName(getAlias());
info.setType(clazz.bundle.getTypeAlias(info.getType())); info.setType(clazz.bundle.getTypeAlias(type));
if (getCodeAnalyzer() != null) { if (getCodeAnalyzer() != null) {
BytecodeInfo strippedBytecode = getCodeAnalyzer().stripCode(); BytecodeInfo strippedBytecode = getCodeAnalyzer().stripCode();
// strippedBytecode.dumpCode(GlobalOptions.err); // strippedBytecode.dumpCode(GlobalOptions.err);
@ -196,44 +205,25 @@ public class MethodIdentifier extends Identifier implements Opcodes {
case opc_invokestatic: case opc_invokestatic:
case opc_invokeinterface: case opc_invokeinterface:
case opc_invokevirtual: { case opc_invokevirtual: {
Reference ref = (Reference) instr.objData; instr.objData = clazz.bundle.getReferenceAlias
MethodIdentifier mi = (MethodIdentifier) ((Reference) instr.objData);
clazz.bundle.getIdentifier(ref);
String newType = clazz.bundle.getTypeAlias(ref.getType());
if (mi != null)
instr.objData = new Reference
("L"+mi.clazz.getFullAlias().replace('.','/')+';',
mi.getAlias(), newType);
else
instr.objData = new Reference
(ref.getClazz(), ref.getName(), newType);
break; break;
} }
case opc_putstatic: case opc_putstatic:
case opc_putfield: case opc_putfield:
case opc_getstatic: case opc_getstatic:
case opc_getfield: { case opc_getfield: {
Reference ref = (Reference) instr.objData; instr.objData = clazz.bundle.getReferenceAlias
String newType = clazz.bundle.getTypeAlias(ref.getType()); ((Reference) instr.objData);
FieldIdentifier fi = (FieldIdentifier)
clazz.bundle.getIdentifier(ref);
if (fi != null) {
instr.objData = new Reference
("L"+fi.clazz.getFullAlias().replace('.','/')+';',
fi.getAlias(), newType);
} else
instr.objData = new Reference
(ref.getClazz(), ref.getName(), newType);
break; break;
} }
case opc_new: case opc_new:
case opc_checkcast: case opc_checkcast:
case opc_instanceof: case opc_instanceof:
case opc_multianewarray: { case opc_multianewarray: {
String clName = (String) instr.objData; instr.objData = clazz.bundle.getTypeAlias
clName = clazz.bundle.getTypeAlias(clName); ((String) instr.objData);
instr.objData = clName;
break; break;
} }
} }

Loading…
Cancel
Save