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. 36
      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')
break;
int index = clName.indexOf(';', i);
if (index != clName.length()-1)
break;
clName = clName.substring(i+1, index);
}
m.clazz.bundle.reachableIdentifier(clName, false); 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;
String clName = ref.getClazz();
/* Don't have to reach array methods */
if (clName.charAt(0) != '[') {
clName = clName.substring(1, clName.length()-1).replace('/', '.');
m.clazz.bundle.reachableIdentifier m.clazz.bundle.reachableIdentifier
(ref.getClazz()+"."+ref.getName()+"."+ref.getType(), (clName+"."+ref.getName()+"."+ref.getType(),
instr.opcode == opc_invokevirtual instr.opcode == opc_invokevirtual
|| instr.opcode == opc_invokeinterface); || instr.opcode == opc_invokeinterface);
}
break; break;
} }
} }
@ -89,12 +86,10 @@ 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)
m.clazz.bundle.getIdentifier(ref.getClazz());
if (ci != null) {
FieldIdentifier fi = (FieldIdentifier) FieldIdentifier fi = (FieldIdentifier)
ci.getIdentifier(ref.getName(), ref.getType()); m.clazz.bundle.getIdentifier(ref);
if (jode.Obfuscator.shouldStrip && !fi.isReachable()) { if (fi != null
&& jode.Obfuscator.shouldStrip && !fi.isReachable()) {
/* Replace instruction with pop opcodes. */ /* Replace instruction with pop opcodes. */
int stacksize = int stacksize =
(instr.opcode (instr.opcode
@ -114,7 +109,6 @@ public class SimpleAnalyzer implements CodeAnalyzer, Opcodes {
} }
} }
} }
}
return bytecode; return bytecode;
} }
} }

Loading…
Cancel
Save