diff --git a/jode/jode/obfuscator/modules/ConstantAnalyzer.java.in b/jode/jode/obfuscator/modules/ConstantAnalyzer.java.in index 5f4c818..c32e8ef 100644 --- a/jode/jode/obfuscator/modules/ConstantAnalyzer.java.in +++ b/jode/jode/obfuscator/modules/ConstantAnalyzer.java.in @@ -1,4 +1,4 @@ -/* ConstantAnalyzer Copyright (C) 1999 Jochen Hoenicke. +/* ConstantAnalyzer Copyright (C) 1999, 2000 Jochen Hoenicke. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -227,7 +227,7 @@ public class ConstantAnalyzer implements Opcodes, CodeAnalyzer { if (value == null ? other.value == null : value.equals(other.value)) { if (value != VOLATILE) { -// other.addConstantListener(this); + other.addConstantListener(this); this.addConstantListener(other); } return; @@ -280,7 +280,9 @@ public class ConstantAnalyzer implements Opcodes, CodeAnalyzer { ConstValue[] locals, TodoQueue notifyQueue) { this.stack = stack; - this.locals = locals; + this.locals = new ConstValue[locals.length]; + for (int i=0; i< locals.length; i++) + this.locals[i] = copy(locals[i]); this.notifyQueue = notifyQueue; } @@ -446,6 +448,7 @@ public class ConstantAnalyzer implements Opcodes, CodeAnalyzer { for (int i=0; i < locals.length; i++) { if (locals[i] != null) { if (other.locals[i] == null) { + locals[i].constantChanged(); locals[i] = null; enqueue(); } else { @@ -514,6 +517,21 @@ 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); @@ -538,7 +556,9 @@ public class ConstantAnalyzer implements Opcodes, CodeAnalyzer { (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) diff --git a/jode/jode/obfuscator/modules/Makefile.am b/jode/jode/obfuscator/modules/Makefile.am index 153d0ef..cf53017 100644 --- a/jode/jode/obfuscator/modules/Makefile.am +++ b/jode/jode/obfuscator/modules/Makefile.am @@ -8,7 +8,7 @@ JAVADEP = $(top_builddir)/javaDependencies.pl -subdir=$(subdir)\ CLASSPATH = @CLASSPATH@ CLASSLIB = @CLASSLIB@ SUBSTCP = @SUBSTCP@ -BUILD_CLASSPATH = $(top_srcdir):$(top_builddir):$(CLASSPATH):$(CLASSLIB) +FULL_CLASSPATH := $(shell $(SUBSTCP) $(top_srcdir):$(top_builddir):$(CLASSPATH):$(CLASSLIB)) MY_JAVA_FILES = \ ConstantAnalyzer.java \ @@ -31,7 +31,7 @@ EXTRA_DIST = $(MY_JAVA_FILES) @QUOTE@-include Makefile.dep %.class: %.java - $(JAVAC) -classpath `$(SUBSTCP) $(BUILD_CLASSPATH):$(CLASSLIB)` -d $(top_builddir) $< + $(JAVAC) -classpath $(FULL_CLASSPATH) -d $(top_builddir) $< Makefile.dep: $(MY_JAVA_FILES:.java=.class) $(JAVADEP) $^ diff --git a/jode/jode/obfuscator/modules/ModifierMatcher.java.in b/jode/jode/obfuscator/modules/ModifierMatcher.java.in index a8e724a..1c8d176 100644 --- a/jode/jode/obfuscator/modules/ModifierMatcher.java.in +++ b/jode/jode/obfuscator/modules/ModifierMatcher.java.in @@ -23,12 +23,13 @@ import jode.obfuscator.Identifier; import jode.obfuscator.ClassIdentifier; import jode.obfuscator.FieldIdentifier; import jode.obfuscator.MethodIdentifier; +import jode.obfuscator.OptionHandler; import java.lang.reflect.Modifier; import @COLLECTIONS@.Collection; import @COLLECTIONS@.Iterator; -public class ModifierMatcher implements IdentifierMatcher, Cloneable { +public class ModifierMatcher implements IdentifierMatcher, OptionHandler, Cloneable { static final int PUBLIC = Modifier.PUBLIC; static final int PROTECTED = Modifier.PROTECTED; static final int PRIVATE = Modifier.PRIVATE; diff --git a/jode/jode/obfuscator/modules/StrongRenamer.java.in b/jode/jode/obfuscator/modules/StrongRenamer.java.in index 85e76f6..403861b 100644 --- a/jode/jode/obfuscator/modules/StrongRenamer.java.in +++ b/jode/jode/obfuscator/modules/StrongRenamer.java.in @@ -1,4 +1,4 @@ -/* StrongRenamer Copyright (C) 1999 Jochen Hoenicke. +/* StrongRenamer Copyright (C) 1999, 2000 Jochen Hoenicke. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -32,6 +32,18 @@ public class StrongRenamer implements Renamer, OptionHandler { }; String charsets[][]; + String javaKeywords[] = { + "abstract", "default", "if", "private", "throw", "boolean", + "do", "implements", "protected", "throws", "break", "double", + "import", "public", "transient", "byte", "else", "instanceof", + "return", "try", "case", "extends", "int", "short", "void", + "catch", "final", "interface", "static", "volatile", "char", + "finally", "long", "super", "while", "class", "float", + "native", "switch", "const", "for", "new", "synchronized", + "continue", "goto", "package", "this", "strictfp", "null", + "true", "false" + }; + public StrongRenamer() { charsets = new String[idents.length][parts.length]; for (int i=0; i< idents.length; i++) @@ -87,16 +99,14 @@ public class StrongRenamer implements Renamer, OptionHandler { int identType; if (ident instanceof PackageIdentifier) identType = 0; - else if (ident instanceof PackageIdentifier) - identType = 1; else if (ident instanceof ClassIdentifier) - identType = 2; + identType = 1; else if (ident instanceof FieldIdentifier) - identType = 3; + identType = 2; else if (ident instanceof MethodIdentifier) - identType = 4; + identType = 3; else if (ident instanceof LocalIdentifier) - identType = 5; + identType = 4; else throw new IllegalArgumentException(ident.getClass().getName()); final String[] theCharset = charsets[identType]; @@ -114,29 +124,38 @@ public class StrongRenamer implements Renamer, OptionHandler { headIndex = 0; return new String(name); } - if (++headIndex < theCharset[0].length()) { - name[0] = theCharset[0].charAt(headIndex); - return new String(name); - } - headIndex = 0; - name[0] = theCharset[0].charAt(0); - - String charset = theCharset[1]; - for (int pos = 1; pos < name.length; pos++) { - int index = charset.indexOf(name[pos]) + 1; - if (index < charset.length()) { - name[pos] = charset.charAt(index); + next_name: + while (true) { + if (++headIndex < theCharset[0].length()) { + name[0] = theCharset[0].charAt(headIndex); return new String(name); } - name[pos] = charset.charAt(0); - } + headIndex = 0; + name[0] = theCharset[0].charAt(0); + + String charset = theCharset[1]; + for (int pos = 1; pos < name.length; pos++) { + int index = charset.indexOf(name[pos]) + 1; + if (index < charset.length()) { + name[pos] = charset.charAt(index); + return new String(name); + } + name[pos] = charset.charAt(0); + } - name = new char[name.length+1]; - name[0] = theCharset[0].charAt(0); - char firstCont = theCharset[1].charAt(0); - for (int i=1; i