diff --git a/jode/ChangeLog b/jode/ChangeLog index 128485c..eb0f245 100644 --- a/jode/ChangeLog +++ b/jode/ChangeLog @@ -1,7 +1,18 @@ +2001-07-10 Jochen Hoenicke + + * 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 * 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 diff --git a/jode/jode/obfuscator/modules/ConstantAnalyzer.java.in b/jode/jode/obfuscator/modules/ConstantAnalyzer.java.in index 1fa83c6..1943c95 100644 --- a/jode/jode/obfuscator/modules/ConstantAnalyzer.java.in +++ b/jode/jode/obfuscator/modules/ConstantAnalyzer.java.in @@ -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); } diff --git a/jode/jode/obfuscator/modules/SimpleAnalyzer.java.in b/jode/jode/obfuscator/modules/SimpleAnalyzer.java.in index ec5459c..ab1b370 100644 --- a/jode/jode/obfuscator/modules/SimpleAnalyzer.java.in +++ b/jode/jode/obfuscator/modules/SimpleAnalyzer.java.in @@ -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)