* jode/obfuscator/modules/SimpleAnalyzer.java.in:

Ported fix from ConstantAnalyzer:
(canonizeReference): for interfaces call canonizeIfaceReference.
(canonizeIfaceReference): new method.
* jode/obfuscator/modules/ConstantAnalyzer.java.in:
made sub class of SimpleAnalyzer.
(canonizeReference): Removed, since its inherited.
(canonizeIfaceReference): dito.


git-svn-id: https://svn.code.sf.net/p/jode/code/branches/branch_1_1@1325 379699f6-c40d-0410-875b-85095c16579e
branch_1_1
hoenicke 23 years ago
parent fa005e09ee
commit a65fd35ceb
  1. 13
      jode/ChangeLog
  2. 71
      jode/jode/obfuscator/modules/ConstantAnalyzer.java.in
  3. 19
      jode/jode/obfuscator/modules/SimpleAnalyzer.java.in

@ -1,7 +1,18 @@
2001-07-10 Jochen Hoenicke <jochen@gnu.org>
* jode/obfuscator/modules/SimpleAnalyzer.java.in:
Ported fix from ConstantAnalyzer:
(canonizeReference): for interfaces call canonizeIfaceReference.
(canonizeIfaceReference): new method.
* jode/obfuscator/modules/ConstantAnalyzer.java.in:
made sub class of SimpleAnalyzer.
(canonizeReference): Removed, since its inherited.
(canonizeIfaceReference): dito.
2001-07-08 Jochen Hoenicke <jochen@gnu.org>
* jode/bytecode/BytecodeInfo.java.in (calculateMaxStack): Handle
special case for empty method. Previous code would just crash.
special case for empty method. Previous code would just crash.
2001-06-15 Jochen Hoenicke <jochen@gnu.org>

@ -45,7 +45,8 @@ import @COLLECTIONS@.ListIterator;
*
* @author Jochen Hoenicke
*/
public class ConstantAnalyzer implements Opcodes, CodeAnalyzer {
public class ConstantAnalyzer extends SimpleAnalyzer
implements Opcodes, CodeAnalyzer {
BytecodeInfo bytecode;
@ -517,74 +518,6 @@ public class ConstantAnalyzer implements Opcodes, CodeAnalyzer {
((StackLocalInfo)instr.getTmpInfo()).merge(info);
}
private ClassInfo canonizeIfaceRef(ClassInfo clazz, Reference ref) {
while (clazz != null) {
if (clazz.findMethod(ref.getName(), ref.getType()) != null)
return clazz;
ClassInfo[] ifaces = clazz.getInterfaces();
for (int i = 0; i < ifaces.length; i++) {
ClassInfo realClass = canonizeIfaceRef(ifaces[i], ref);
if (realClass != null)
return realClass;
}
clazz = clazz.getSuperclass();
}
return null;
}
public Identifier canonizeReference(Instruction instr) {
Reference ref = instr.getReference();
Identifier ident = Main.getClassBundle().getIdentifier(ref);
String clName = ref.getClazz();
String realClazzName;
if (ident != null) {
ClassIdentifier clazz = (ClassIdentifier)ident.getParent();
realClazzName = "L" + (clazz.getFullName()
.replace('.', '/')) + ";";
} else {
/* We have to look at the ClassInfo's instead, to
* point to the right method.
*/
ClassInfo clazz;
if (clName.charAt(0) == '[') {
/* Arrays don't define new methods (well clone(),
* but that can be ignored).
*/
clazz = ClassInfo.javaLangObject;
} else {
clazz = ClassInfo.forName
(clName.substring(1, clName.length()-1)
.replace('/','.'));
}
if (instr.getOpcode() == opc_invokeinterface) {
clazz = canonizeIfaceRef(clazz, ref);
} else if (instr.getOpcode() >= opc_invokevirtual) {
while (clazz != null
&& clazz.findMethod(ref.getName(),
ref.getType()) == null)
clazz = clazz.getSuperclass();
} else {
while (clazz != null
&& clazz.findField(ref.getName(),
ref.getType()) == null)
clazz = clazz.getSuperclass();
}
if (clazz == null) {
GlobalOptions.err.println("WARNING: Can't find reference: "
+ref);
realClazzName = clName;
} else
realClazzName = "L" + clazz.getName().replace('.', '/') + ";";
}
if (!realClazzName.equals(ref.getClazz())) {
ref = Reference.getReference(realClazzName,
ref.getName(), ref.getType());
instr.setReference(ref);
}
return ident;
}
public void handleReference(Reference ref, boolean isVirtual) {
Main.getClassBundle().reachableReference(ref, isVirtual);
}

@ -34,6 +34,21 @@ import @COLLECTIONS@.ListIterator;
public class SimpleAnalyzer implements CodeAnalyzer, Opcodes {
private ClassInfo canonizeIfaceRef(ClassInfo clazz, Reference ref) {
while (clazz != null) {
if (clazz.findMethod(ref.getName(), ref.getType()) != null)
return clazz;
ClassInfo[] ifaces = clazz.getInterfaces();
for (int i = 0; i < ifaces.length; i++) {
ClassInfo realClass = canonizeIfaceRef(ifaces[i], ref);
if (realClass != null)
return realClass;
}
clazz = clazz.getSuperclass();
}
return null;
}
public Identifier canonizeReference(Instruction instr) {
Reference ref = instr.getReference();
Identifier ident = Main.getClassBundle().getIdentifier(ref);
@ -58,7 +73,9 @@ public class SimpleAnalyzer implements CodeAnalyzer, Opcodes {
(clName.substring(1, clName.length()-1)
.replace('/','.'));
}
if (instr.getOpcode() >= opc_invokevirtual) {
if (instr.getOpcode() == opc_invokeinterface) {
clazz = canonizeIfaceRef(clazz, ref);
} else if (instr.getOpcode() >= opc_invokevirtual) {
while (clazz != null
&& clazz.findMethod(ref.getName(),
ref.getType()) == null)

Loading…
Cancel
Save