remove opc_anewarray

getIdentifier(ref)
instr.objData changed


git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@587 379699f6-c40d-0410-875b-85095c16579e
stable
jochen 26 years ago
parent 9836620e6c
commit bd50eca261
  1. 72
      jode/jode/obfuscator/SimpleAnalyzer.java

@ -39,25 +39,17 @@ public class SimpleAnalyzer implements CodeAnalyzer, Opcodes {
for (Instruction instr = bytecode.getFirstInstr(); for (Instruction instr = bytecode.getFirstInstr();
instr != null; instr = instr.nextByAddr) { instr != null; instr = instr.nextByAddr) {
switch (instr.opcode) { switch (instr.opcode) {
case opc_new:
case opc_anewarray:
case opc_checkcast: case opc_checkcast:
case opc_instanceof: case opc_instanceof:
case opc_multianewarray: { case opc_multianewarray: {
String clName = (String) instr.objData; String clName = (String) instr.objData;
if (clName.charAt(0) == '[') { int i = 0;
int i; while (i < clName.length() && clName.charAt(i) == '[')
for (i=0; i< clName.length(); i++) i++;
if (clName.charAt(i) != '[') if (i < clName.length() && clName.charAt(i) == 'L') {
break; clName = clName.substring(i+1, clName.length()-1);
if (i >= clName.length() || clName.charAt(i) != 'L') m.clazz.bundle.reachableIdentifier(clName, false);
break;
int index = clName.indexOf(';', i);
if (index != clName.length()-1)
break;
clName = clName.substring(i+1, index);
} }
m.clazz.bundle.reachableIdentifier(clName, false);
break; break;
} }
case opc_getstatic: case opc_getstatic:
@ -67,10 +59,15 @@ public class SimpleAnalyzer implements CodeAnalyzer, Opcodes {
case opc_invokeinterface: case opc_invokeinterface:
case opc_invokevirtual: { case opc_invokevirtual: {
Reference ref = (Reference) instr.objData; Reference ref = (Reference) instr.objData;
m.clazz.bundle.reachableIdentifier String clName = ref.getClazz();
(ref.getClazz()+"."+ref.getName()+"."+ref.getType(), /* Don't have to reach array methods */
if (clName.charAt(0) != '[') {
clName = clName.substring(1, clName.length()-1).replace('/', '.');
m.clazz.bundle.reachableIdentifier
(clName+"."+ref.getName()+"."+ref.getType(),
instr.opcode == opc_invokevirtual instr.opcode == opc_invokevirtual
|| instr.opcode == opc_invokeinterface); || instr.opcode == opc_invokeinterface);
}
break; break;
} }
} }
@ -89,29 +86,26 @@ public class SimpleAnalyzer implements CodeAnalyzer, Opcodes {
if (instr.opcode == opc_putstatic if (instr.opcode == opc_putstatic
|| instr.opcode == opc_putfield) { || instr.opcode == opc_putfield) {
Reference ref = (Reference) instr.objData; Reference ref = (Reference) instr.objData;
ClassIdentifier ci = (ClassIdentifier) FieldIdentifier fi = (FieldIdentifier)
m.clazz.bundle.getIdentifier(ref.getClazz()); m.clazz.bundle.getIdentifier(ref);
if (ci != null) { if (fi != null
FieldIdentifier fi = (FieldIdentifier) && jode.Obfuscator.shouldStrip && !fi.isReachable()) {
ci.getIdentifier(ref.getName(), ref.getType()); /* Replace instruction with pop opcodes. */
if (jode.Obfuscator.shouldStrip && !fi.isReachable()) { int stacksize =
/* Replace instruction with pop opcodes. */ (instr.opcode
int stacksize = == Instruction.opc_putstatic) ? 0 : 1;
(instr.opcode stacksize += Type.tType(ref.getType()).stackSize();
== Instruction.opc_putstatic) ? 0 : 1; if (stacksize == 3) {
stacksize += Type.tType(ref.getType()).stackSize(); /* Add a pop instruction after this opcode. */
if (stacksize == 3) { Instruction second = instr.appendInstruction();
/* Add a pop instruction after this opcode. */ second.length = 1;
Instruction second = instr.appendInstruction(); second.opcode = Instruction.opc_pop;
second.length = 1; stacksize--;
second.opcode = Instruction.opc_pop; }
stacksize--; instr.objData = null;
} instr.intData = 0;
instr.objData = null; instr.opcode = Instruction.opc_pop - 1 + stacksize;
instr.intData = 0; instr.length = 1;
instr.opcode = Instruction.opc_pop - 1 + stacksize;
instr.length = 1;
}
} }
} }
} }

Loading…
Cancel
Save