*** empty log message ***

git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@163 379699f6-c40d-0410-875b-85095c16579e
stable
jochen 26 years ago
parent b5d609af5c
commit a6bc1392d1
  1. 30
      jode/jode/bytecode/ClassInfo.java
  2. 127
      jode/jode/bytecode/SearchPath.java
  3. 8
      jode/jode/decompiler/LocalInfo.java
  4. 2
      jode/jode/decompiler/LocalVariableRangeList.java
  5. 2
      jode/jode/decompiler/LocalVariableTable.java
  6. 8
      jode/jode/decompiler/MethodAnalyzer.java
  7. 4
      jode/jode/expr/ComplexExpression.java
  8. 9
      jode/jode/expr/LocalLoadOperator.java
  9. 5
      jode/jode/flow/CompleteSynchronized.java
  10. 5
      jode/jode/flow/CreateConstantArray.java
  11. 5
      jode/jode/flow/CreateExpression.java
  12. 5
      jode/jode/flow/CreateForInitializer.java
  13. 9
      jode/jode/flow/CreateIfThenElseOperator.java
  14. 30
      jode/jode/flow/FlowBlock.java
  15. 5
      jode/jode/flow/RemoveEmpty.java
  16. 18
      jode/jode/flow/TransformConstructors.java
  17. 17
      jode/jode/flow/TransformExceptionHandlers.java
  18. 2
      jode/jode/flow/VariableSet.java
  19. 2
      jode/jode/obfuscator/ClassBundle.java
  20. 58
      jode/jode/obfuscator/Main.java
  21. 6
      jode/jode/type/Type.java

@ -48,11 +48,20 @@ public class ClassInfo extends BinaryInfo {
private MethodInfo[] methods; private MethodInfo[] methods;
private AttributeInfo[] attributes; private AttributeInfo[] attributes;
public final static ClassInfo javaLangObject = public final static ClassInfo javaLangObject = forName("java.lang.Object");
ClassInfo.forName("java.lang.Object");
public static void setClassPath(String path) { public static void setClassPath(String path) {
classpath = new SearchPath(path); classpath = new SearchPath(path);
Enumeration enum = classes.elements();
while (enum.hasMoreElements()) {
ClassInfo ci = (ClassInfo) enum.nextElement();
ci.status = 0;
ci.superclass = null;
ci.fields = null;
ci.interfaces = null;
ci.methods = null;
ci.attributes = null;
}
} }
public static boolean exists(String name) { public static boolean exists(String name) {
@ -202,16 +211,15 @@ public class ClassInfo extends BinaryInfo {
} catch (IOException ex) { } catch (IOException ex) {
String message = ex.getLocalizedMessage(); String message = ex.getLocalizedMessage();
if ((howMuch & ~(METHODS|HIERARCHY)) == 0) if ((howMuch & ~(METHODS|HIERARCHY)) == 0)
System.err.println("Can't read class " + name jode.Decompiler.err.println
+ ", types may be incorrect. (" ("Can't read class " + name + ", types may be incorrect. ("
+ ex.getClass().getName() + ex.getClass().getName()
+ (message != null ? ": " + message : "") + (message != null ? ": " + message : "") + ")");
+ ")");
else else
System.err.println("Can't read class " + name + "(" jode.Decompiler.err.println
+ ex.getClass().getName() ("Can't read class " + name
+ (message != null ? ": " + message : "") + "(" + ex.getClass().getName()
+ ")"); + (message != null ? ": " + message : "") + ")");
if (name.equals("java.lang.Object")) if (name.equals("java.lang.Object"))
superclass = null; superclass = null;

@ -18,10 +18,12 @@
*/ */
package jode.bytecode; package jode.bytecode;
import java.io.*; import java.io.*;
import java.net.*;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
import java.util.zip.ZipFile; import java.util.zip.ZipFile;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import java.util.Enumeration; import java.util.Enumeration;
import jode.Decompiler;
/** /**
* This class represents a path of multiple directories and/or zip files, * This class represents a path of multiple directories and/or zip files,
@ -31,6 +33,12 @@ import java.util.Enumeration;
*/ */
public class SearchPath { public class SearchPath {
/**
* Hack to allow URLs that use the same separator as the normal
* path separator. Use a very unusual character for this.
*/
public static final char protocolSeparator = 31;
URL[] bases;
File[] dirs; File[] dirs;
ZipFile[] zips; ZipFile[] zips;
@ -45,23 +53,59 @@ public class SearchPath {
new StringTokenizer(path, File.pathSeparator); new StringTokenizer(path, File.pathSeparator);
int length = tokenizer.countTokens(); int length = tokenizer.countTokens();
bases = new URL[length];
dirs = new File[length]; dirs = new File[length];
zips = new ZipFile[length]; zips = new ZipFile[length];
for (int i=0; i< length; i++) { for (int i=0; i< length; i++) {
dirs[i] = new File(tokenizer.nextToken()); String token = tokenizer.nextToken()
if (!dirs[i].isDirectory()) { .replace(protocolSeparator, ':');
try { int index = token.indexOf(':');
zips[i] = new ZipFile(dirs[i]); if (index != -1 && index < token.length()-2
} catch (java.io.IOException ex) { && token.charAt(index+1) == '/'
/* disable this entry */ && token.charAt(index+2) == '/') {
dirs[i] = null; // This looks like an URL.
} try {
} bases[i] = new URL(token);
} } catch (MalformedURLException ex) {
/* disable entry */
bases[i] = null;
dirs[i] = null;
}
} else {
try {
dirs[i] = new File(token);
if (!dirs[i].isDirectory()) {
try {
zips[i] = new ZipFile(dirs[i]);
} catch (java.io.IOException ex) {
/* disable this entry */
dirs[i] = null;
}
}
} catch (SecurityException ex) {
/* disable this entry */
Decompiler.err.println("Warning: SecurityException while"
+ " accessing " + token);
dirs[i] = null;
}
}
}
} }
public boolean exists(String filename) { public boolean exists(String filename) {
for (int i=0; i<dirs.length; i++) { for (int i=0; i<dirs.length; i++) {
if (bases[i] != null) {
try {
URL url = new URL(bases[i], filename);
URLConnection conn = url.openConnection();
conn.connect();
conn.getInputStream().close();
return true;
} catch (IOException ex) {
/* ignore */
}
continue;
}
if (dirs[i] == null) if (dirs[i] == null)
continue; continue;
if (zips[i] != null) { if (zips[i] != null) {
@ -72,9 +116,13 @@ public class SearchPath {
if (java.io.File.separatorChar != '/') if (java.io.File.separatorChar != '/')
filename = filename filename = filename
.replace('/', java.io.File.separatorChar); .replace('/', java.io.File.separatorChar);
File f = new File(dirs[i], filename); try {
if (f.exists()) File f = new File(dirs[i], filename);
return true; if (f.exists())
return true;
} catch (SecurityException ex) {
/* ignore and take next element */
}
} }
} }
return false; return false;
@ -88,6 +136,21 @@ public class SearchPath {
*/ */
public InputStream getFile(String filename) throws IOException { public InputStream getFile(String filename) throws IOException {
for (int i=0; i<dirs.length; i++) { for (int i=0; i<dirs.length; i++) {
if (bases[i] != null) {
try {
URL url = new URL(bases[i], filename);
URLConnection conn = url.openConnection();
return conn.getInputStream();
} catch (SecurityException ex) {
Decompiler.err.println("Warning: SecurityException"
+" while accessing "
+bases[i]+filename);
/* ignore and take next element */
} catch (FileNotFoundException ex) {
/* ignore and take next element */
}
continue;
}
if (dirs[i] == null) if (dirs[i] == null)
continue; continue;
if (zips[i] != null) { if (zips[i] != null) {
@ -98,9 +161,16 @@ public class SearchPath {
if (java.io.File.separatorChar != '/') if (java.io.File.separatorChar != '/')
filename = filename filename = filename
.replace('/', java.io.File.separatorChar); .replace('/', java.io.File.separatorChar);
File f = new File(dirs[i], filename); try {
if (f.exists()) File f = new File(dirs[i], filename);
return new FileInputStream(f); if (f.exists())
return new FileInputStream(f);
} catch (SecurityException ex) {
Decompiler.err.println("Warning: SecurityException"
+" while accessing "
+dirs[i]+filename);
/* ignore and take next element */
}
} }
} }
throw new FileNotFoundException(filename); throw new FileNotFoundException(filename);
@ -133,9 +203,15 @@ public class SearchPath {
if (java.io.File.separatorChar != '/') if (java.io.File.separatorChar != '/')
filename = filename filename = filename
.replace('/', java.io.File.separatorChar); .replace('/', java.io.File.separatorChar);
File f = new File(dirs[i], filename); try {
if (f.exists()) File f = new File(dirs[i], filename);
return f.isDirectory(); if (f.exists())
return f.isDirectory();
} catch (SecurityException ex) {
Decompiler.err.println("Warning: SecurityException"
+" while accessing "
+dirs[i]+filename);
}
} }
} }
return false; return false;
@ -190,9 +266,16 @@ public class SearchPath {
(java.io.File.separatorChar != '/') (java.io.File.separatorChar != '/')
? dirName.replace('/', java.io.File.separatorChar) ? dirName.replace('/', java.io.File.separatorChar)
: dirName; : dirName;
File f = new File(dirs[pathNr], localDirName); try {
if (f.exists() && f.isDirectory()) File f = new File(dirs[pathNr], localDirName);
files = f.list(); if (f.exists() && f.isDirectory())
files = f.list();
} catch (SecurityException ex) {
Decompiler.err.println("Warning: SecurityException"
+" while accessing "
+dirs[pathNr]+localDirName);
/* ignore and take next element */
}
} }
pathNr++; pathNr++;
} }

@ -75,7 +75,7 @@ public class LocalInfo {
} else { } else {
if (this != li) { if (this != li) {
shadow = li; shadow = li;
// System.err.println("combining "+name+"("+type+") and " // Decompiler.err.println("combining "+name+"("+type+") and "
// +li.name+"("+li.type+")"); // +li.name+"("+li.type+")");
li.setType(type); li.setType(type);
@ -88,7 +88,7 @@ public class LocalInfo {
(LocalVarOperator) enum.nextElement(); (LocalVarOperator) enum.nextElement();
if (needTypeUpdate) { if (needTypeUpdate) {
if (Decompiler.isTypeDebugging) if (Decompiler.isTypeDebugging)
System.err.println("updating " + lvo); Decompiler.err.println("updating " + lvo);
lvo.updateType(); lvo.updateType();
} }
shadow.operators.addElement(lvo); shadow.operators.addElement(lvo);
@ -183,7 +183,7 @@ public class LocalInfo {
LocalInfo li = getLocalInfo(); LocalInfo li = getLocalInfo();
newType = li.type.intersection(newType); newType = li.type.intersection(newType);
if (Decompiler.isTypeDebugging) if (Decompiler.isTypeDebugging)
System.err.println(getName()+" setType, new: "+newType Decompiler.err.println(getName()+" setType, new: "+newType
+ " old: "+li.type); + " old: "+li.type);
if (!li.type.equals(newType)) { if (!li.type.equals(newType)) {
li.type = newType; li.type = newType;
@ -191,7 +191,7 @@ public class LocalInfo {
while (enum.hasMoreElements()) { while (enum.hasMoreElements()) {
LocalVarOperator lvo = (LocalVarOperator) enum.nextElement(); LocalVarOperator lvo = (LocalVarOperator) enum.nextElement();
if (Decompiler.isTypeDebugging) if (Decompiler.isTypeDebugging)
System.err.println("updating "+lvo); Decompiler.err.println("updating "+lvo);
lvo.updateType(); lvo.updateType();
} }
} }

@ -51,7 +51,7 @@ public class LocalVariableRangeList {
after = after.next; after = after.next;
} }
if (after != null && li.start + li.length > after.start) if (after != null && li.start + li.length > after.start)
System.err.println("warning: non disjoint locals"); Decompiler.err.println("warning: non disjoint locals");
li.next = after; li.next = after;
if (before == null) if (before == null)
list = li; list = li;

@ -46,7 +46,7 @@ public class LocalVariableTable {
int slot = stream.readUnsignedShort(); int slot = stream.readUnsignedShort();
locals[slot].addLocal(start, end-start, name, type); locals[slot].addLocal(start, end-start, name, type);
if (Decompiler.showLVT) if (Decompiler.showLVT)
System.err.println(name + ": " + type Decompiler.err.println(name + ": " + type
+" range "+start+" - "+end +" range "+start+" - "+end
+" slot "+slot); +" slot "+slot);
} }

@ -132,10 +132,10 @@ public class MethodAnalyzer implements Analyzer {
if (!Decompiler.immediateOutput) { if (!Decompiler.immediateOutput) {
if (Decompiler.isVerbose) if (Decompiler.isVerbose)
System.err.print(methodName+": "); Decompiler.err.print(methodName+": ");
code.analyze(); code.analyze();
if (Decompiler.isVerbose) if (Decompiler.isVerbose)
System.err.println(""); Decompiler.err.println("");
} }
} }
@ -147,10 +147,10 @@ public class MethodAnalyzer implements Analyzer {
// immediate output. // immediate output.
if (Decompiler.isVerbose) if (Decompiler.isVerbose)
System.err.print(methodName+": "); Decompiler.err.print(methodName+": ");
code.analyze(); code.analyze();
if (Decompiler.isVerbose) if (Decompiler.isVerbose)
System.err.println(""); Decompiler.err.println("");
} }
if (isConstructor() && isStatic() if (isConstructor() && isStatic()

@ -175,7 +175,7 @@ public class ComplexExpression extends Expression {
opType = opType.intersection(exprType); opType = opType.intersection(exprType);
if (!opType.equals(exprType) && opType != Type.tError) { if (!opType.equals(exprType) && opType != Type.tError) {
if (Decompiler.isTypeDebugging) if (Decompiler.isTypeDebugging)
System.err.println("change in "+this+": " Decompiler.err.println("change in "+this+": "
+exprType +exprType
+"->"+opType); +"->"+opType);
subExpressions[i].setType(opType); subExpressions[i].setType(opType);
@ -205,7 +205,7 @@ public class ComplexExpression extends Expression {
if (!types[i].equals(opType) if (!types[i].equals(opType)
&& types[i] != Type.tError) { && types[i] != Type.tError) {
if (Decompiler.isTypeDebugging) if (Decompiler.isTypeDebugging)
System.err.println("change in "+this+": " Decompiler.err.println("change in "+this+": "
+operator.getOperandType(i) +operator.getOperandType(i)
+"->"+types[i]); +"->"+types[i]);
changed = true; changed = true;

@ -18,6 +18,7 @@
*/ */
package jode.decompiler; package jode.decompiler;
import jode.Decompiler;
import jode.Type; import jode.Type;
import jode.LocalInfo; import jode.LocalInfo;
@ -49,8 +50,8 @@ implements LocalVarOperator {
} }
public void updateType() { public void updateType() {
if (jode.Decompiler.isTypeDebugging) if (Decompiler.isTypeDebugging)
System.err.println("local "+local.getName()+" changed: " Decompiler.err.println("local "+local.getName()+" changed: "
+type+" to "+local.getType() +type+" to "+local.getType()
+" in "+parent); +" in "+parent);
super.setType(local.getType()); super.setType(local.getType());
@ -59,12 +60,12 @@ implements LocalVarOperator {
} }
public Type getType() { public Type getType() {
// System.err.println("LocalLoad.getType of "+local.getName()+": "+local.getType()); // Decompiler.err.println("LocalLoad.getType of "+local.getName()+": "+local.getType());
return local.getType(); return local.getType();
} }
public void setType(Type type) { public void setType(Type type) {
// System.err.println("LocalLoad.setType of "+local.getName()+": "+local.getType()); // Decompiler.err.println("LocalLoad.setType of "+local.getName()+": "+local.getType());
super.setType(local.setType(type)); super.setType(local.setType(type));
} }

@ -18,6 +18,7 @@
*/ */
package jode.flow; package jode.flow;
import jode.Decompiler;
import jode.decompiler.*; import jode.decompiler.*;
public class CompleteSynchronized { public class CompleteSynchronized {
@ -48,8 +49,8 @@ public class CompleteSynchronized {
return false; return false;
} }
if (jode.Decompiler.isVerbose) if (Decompiler.isVerbose)
System.err.print('s'); Decompiler.err.print('s');
synBlock.isEntered = true; synBlock.isEntered = true;
synBlock.moveDefinitions(last.outer,last); synBlock.moveDefinitions(last.outer,last);

@ -18,6 +18,7 @@
*/ */
package jode.flow; package jode.flow;
import jode.Decompiler;
import jode.decompiler.*; import jode.decompiler.*;
import jode.Type; import jode.Type;
@ -96,8 +97,8 @@ public class CreateConstantArray {
if (arraylength <= index) if (arraylength <= index)
return false; return false;
if (jode.Decompiler.isVerbose) if (Decompiler.isVerbose)
System.err.print('a'); Decompiler.err.print('a');
ConstantArrayOperator cao ConstantArrayOperator cao
= new ConstantArrayOperator(newArrayOp.getType(), = new ConstantArrayOperator(newArrayOp.getType(),

@ -18,6 +18,7 @@
*/ */
package jode.flow; package jode.flow;
import jode.Decompiler;
import jode.decompiler.*; import jode.decompiler.*;
/** /**
@ -110,8 +111,8 @@ public class CreateExpression {
sequBlock = (SequentialBlock)sequBlock.outer; sequBlock = (SequentialBlock)sequBlock.outer;
} }
if(jode.Decompiler.isVerbose) if(Decompiler.isVerbose)
System.err.print('x'); Decompiler.err.print('x');
Expression newExpr; Expression newExpr;
if (params == 1 && op instanceof NopOperator) { if (params == 1 && op instanceof NopOperator) {

@ -18,6 +18,7 @@
*/ */
package jode.flow; package jode.flow;
import jode.Decompiler;
import jode.decompiler.*; import jode.decompiler.*;
public class CreateForInitializer { public class CreateForInitializer {
@ -43,8 +44,8 @@ public class CreateForInitializer {
|| !forBlock.conditionMatches(init)) || !forBlock.conditionMatches(init))
return false; return false;
if (jode.Decompiler.isVerbose) if (Decompiler.isVerbose)
System.err.print('f'); Decompiler.err.print('f');
forBlock.setInit((InstructionBlock) sequBlock.subBlocks[0]); forBlock.setInit((InstructionBlock) sequBlock.subBlocks[0]);
return true; return true;

@ -18,6 +18,7 @@
*/ */
package jode.flow; package jode.flow;
import jode.Decompiler;
import jode.Type; import jode.Type;
import jode.decompiler.*; import jode.decompiler.*;
@ -62,8 +63,8 @@ public class CreateIfThenElseOperator {
| !createFunnyHelper(trueDest, falseDest, ifBlock.elseBlock)) | !createFunnyHelper(trueDest, falseDest, ifBlock.elseBlock))
return false; return false;
if (jode.Decompiler.isVerbose) if (Decompiler.isVerbose)
System.err.print('?'); Decompiler.err.print('?');
IfThenElseOperator iteo = new IfThenElseOperator(Type.tBoolean); IfThenElseOperator iteo = new IfThenElseOperator(Type.tBoolean);
((InstructionBlock)ifBlock.thenBlock).setInstruction ((InstructionBlock)ifBlock.thenBlock).setInstruction
@ -217,8 +218,8 @@ public class CreateIfThenElseOperator {
return false; return false;
e[0] = ifBlock.cond; e[0] = ifBlock.cond;
if (jode.Decompiler.isVerbose) if (Decompiler.isVerbose)
System.err.print('?'); Decompiler.err.print('?');
thenBlock.flowBlock.removeSuccessor(thenBlock.jump); thenBlock.flowBlock.removeSuccessor(thenBlock.jump);
thenBlock.removeJump(); thenBlock.removeJump();

@ -519,10 +519,10 @@ public class FlowBlock {
this.gen.unionExact(successor.gen); this.gen.unionExact(successor.gen);
if (Decompiler.debugInOut) { if (Decompiler.debugInOut) {
System.err.println("UpdateInOut: gens : "+gens); Decompiler.err.println("UpdateInOut: gens : "+gens);
System.err.println(" kills: "+kills); Decompiler.err.println(" kills: "+kills);
System.err.println(" s.in : "+successor.in); Decompiler.err.println(" s.in : "+successor.in);
System.err.println(" in : "+in); Decompiler.err.println(" in : "+in);
} }
} }
@ -643,16 +643,16 @@ public class FlowBlock {
/* Update the in/out-Vectors now */ /* Update the in/out-Vectors now */
updateInOut(succ, jumps); updateInOut(succ, jumps);
if (Decompiler.isFlowDebugging) if (Decompiler.isFlowDebugging)
System.err.println("before Optimize: "+this); Decompiler.err.println("before Optimize: "+this);
/* Try to eliminate as many jumps as possible. /* Try to eliminate as many jumps as possible.
*/ */
jumps = optimizeJumps(jumps, succ); jumps = optimizeJumps(jumps, succ);
if (Decompiler.isFlowDebugging) if (Decompiler.isFlowDebugging)
System.err.println("before Remaining: "+this); Decompiler.err.println("before Remaining: "+this);
resolveRemaining(jumps); resolveRemaining(jumps);
if (Decompiler.isFlowDebugging) if (Decompiler.isFlowDebugging)
System.err.println("after Optimize: "+this); Decompiler.err.println("after Optimize: "+this);
/* Now unify the blocks. /* Now unify the blocks.
*/ */
@ -952,7 +952,7 @@ public class FlowBlock {
public void doTransformations() { public void doTransformations() {
if (Decompiler.isFlowDebugging) if (Decompiler.isFlowDebugging)
System.err.println("before Transformation: "+this); Decompiler.err.println("before Transformation: "+this);
while (lastModified instanceof SequentialBlock) { while (lastModified instanceof SequentialBlock) {
if (!lastModified.getSubBlocks()[0].doTransformations()) if (!lastModified.getSubBlocks()[0].doTransformations())
@ -962,7 +962,7 @@ public class FlowBlock {
/* empty */; /* empty */;
if (Decompiler.isFlowDebugging) if (Decompiler.isFlowDebugging)
System.err.println("after Transformation: "+this); Decompiler.err.println("after Transformation: "+this);
} }
/** /**
@ -1007,7 +1007,7 @@ public class FlowBlock {
*/ */
public boolean analyze(int start, int end) { public boolean analyze(int start, int end) {
if (Decompiler.debugAnalyze) if (Decompiler.debugAnalyze)
System.err.println("analyze("+start+", "+end+")"); Decompiler.err.println("analyze("+start+", "+end+")");
boolean changed = false; boolean changed = false;
@ -1023,10 +1023,10 @@ public class FlowBlock {
if (doT2(start, end)) { if (doT2(start, end)) {
if (Decompiler.isFlowDebugging) if (Decompiler.isFlowDebugging)
System.err.println("after T2: "+this); Decompiler.err.println("after T2: "+this);
if (Decompiler.debugAnalyze) if (Decompiler.debugAnalyze)
System.err.println("T2("+addr+","+(addr+length) Decompiler.err.println("T2("+addr+","+(addr+length)
+") succeeded"); +") succeeded");
/* T2 transformation succeeded. This may /* T2 transformation succeeded. This may
* make another T1 analysis in the previous * make another T1 analysis in the previous
@ -1043,7 +1043,7 @@ public class FlowBlock {
* Finish this analyzation. * Finish this analyzation.
*/ */
if (Decompiler.debugAnalyze) if (Decompiler.debugAnalyze)
System.err.println Decompiler.err.println
("No more successors applicable: " ("No more successors applicable: "
+ start + " - " + end + "; " + start + " - " + end + "; "
+ addr + " - " + (addr+length)); + addr + " - " + (addr+length));
@ -1058,7 +1058,7 @@ public class FlowBlock {
changed = true; changed = true;
if (Decompiler.isFlowDebugging) if (Decompiler.isFlowDebugging)
System.err.println("after T1: "+this); Decompiler.err.println("after T1: "+this);
break; break;
} }
@ -1072,7 +1072,7 @@ public class FlowBlock {
((FlowBlock)enum.nextElement()).addr; ((FlowBlock)enum.nextElement()).addr;
if (predAddr < start || predAddr >= end) { if (predAddr < start || predAddr >= end) {
if (Decompiler.debugAnalyze) if (Decompiler.debugAnalyze)
System.err.println Decompiler.err.println
("breaking analyze(" ("breaking analyze("
+ start + ", " + end + "); " + start + ", " + end + "); "
+ addr + " - " + (addr+length)); + addr + " - " + (addr+length));

@ -18,6 +18,7 @@
*/ */
package jode.flow; package jode.flow;
import jode.Decompiler;
import jode.decompiler.*; import jode.decompiler.*;
public class RemoveEmpty { public class RemoveEmpty {
@ -49,8 +50,8 @@ public class RemoveEmpty {
/* XXX check if blocks may be swapped /* XXX check if blocks may be swapped
* (there mustn't be side effects in one of them). * (there mustn't be side effects in one of them).
*/ */
System.err.println("WARNING: this program contains a SWAP " Decompiler.err.println("WARNING: this program contains a SWAP "
+"opcode and may not be translated correctly."); +"opcode and may not be translated correctly.");
if (block1.getInstruction().isVoid() if (block1.getInstruction().isVoid()
|| block2.getInstruction().isVoid()) || block2.getInstruction().isVoid())

@ -36,7 +36,7 @@ public class TransformConstructors {
StructuredBlock[] sb = new StructuredBlock[constrCount]; StructuredBlock[] sb = new StructuredBlock[constrCount];
for (int i=0; i< constrCount; ) { for (int i=0; i< constrCount; ) {
sb[i] = cons[i].getMethodHeader().block; sb[i] = cons[i].getMethodHeader().block;
// System.err.println("constr "+i+": "+sb[i]); // Decompiler.err.println("constr "+i+": "+sb[i]);
if (!isStatic) { if (!isStatic) {
InstructionBlock ib; InstructionBlock ib;
if (sb[i] instanceof InstructionBlock) if (sb[i] instanceof InstructionBlock)
@ -64,7 +64,7 @@ public class TransformConstructors {
/* This constructor calls another constructor, so we /* This constructor calls another constructor, so we
* can skip it. * can skip it.
*/ */
// System.err.println("skipping this()"); // Decompiler.err.println("skipping this()");
cons[i] = cons[--constrCount]; cons[i] = cons[--constrCount];
continue; continue;
} }
@ -78,7 +78,7 @@ public class TransformConstructors {
sb[i] = sb[i].getSubBlocks()[1]; sb[i] = sb[i].getSubBlocks()[1];
else else
sb[i] = null; sb[i] = null;
// System.err.println("normal constructor"); // Decompiler.err.println("normal constructor");
} }
i++; i++;
} }
@ -107,16 +107,16 @@ public class TransformConstructors {
if (!expr.isConstant()) { if (!expr.isConstant()) {
// System.err.println("not constant: "+expr); // Decompiler.err.println("not constant: "+expr);
break big_loop; break big_loop;
} }
// System.err.println("field "+pfo.getFieldName()+ " = "+expr); // Decompiler.err.println("field "+pfo.getFieldName()+ " = "+expr);
if (!isStatic if (!isStatic
&& !(((ComplexExpression)instr).getSubExpressions()[0] && !(((ComplexExpression)instr).getSubExpressions()[0]
.toString().equals("this"))) { .toString().equals("this"))) {
// System.err.println("not this: "+instr); // Decompiler.err.println("not this: "+instr);
break big_loop; break big_loop;
} }
@ -126,14 +126,14 @@ public class TransformConstructors {
: sb[i]; : sb[i];
if (!(ib instanceof InstructionBlock) if (!(ib instanceof InstructionBlock)
|| !((InstructionBlock)ib).getInstruction().equals(instr)) { || !((InstructionBlock)ib).getInstruction().equals(instr)) {
// System.err.println("constr "+i+" differs: "+ib); // Decompiler.err.println("constr "+i+" differs: "+ib);
break big_loop; break big_loop;
} }
} }
if (!clazzAnalyzer.setFieldInitializer(pfo.getFieldName(), expr)) { if (!clazzAnalyzer.setFieldInitializer(pfo.getFieldName(), expr)) {
// System.err.println("setField failed"); // Decompiler.err.println("setField failed");
break big_loop; break big_loop;
} }
@ -146,7 +146,7 @@ public class TransformConstructors {
} }
for (int i=0; i< constrCount; i++) for (int i=0; i< constrCount; i++)
if (sb[i] == null) { if (sb[i] == null) {
// System.err.println("constr "+i+" is over"); // Decompiler.err.println("constr "+i+" is over");
break big_loop; break big_loop;
} }
} }

@ -18,6 +18,7 @@
*/ */
package jode.flow; package jode.flow;
import jode.AssertError; import jode.AssertError;
import jode.Decompiler;
import jode.Type; import jode.Type;
import jode.LocalInfo; import jode.LocalInfo;
import jode.decompiler.*; import jode.decompiler.*;
@ -139,10 +140,10 @@ public class TransformExceptionHandlers {
tryFlow.in.unionExact(catchFlow.in); tryFlow.in.unionExact(catchFlow.in);
tryFlow.gen.unionExact(catchFlow.gen); tryFlow.gen.unionExact(catchFlow.gen);
if (jode.Decompiler.debugInOut) { if (Decompiler.debugInOut) {
System.err.println("UpdateInOutCatch: gens : "+gens); Decompiler.err.println("UpdateInOutCatch: gens : "+gens);
System.err.println(" s.in : "+catchFlow.in); Decompiler.err.println(" s.in : "+catchFlow.in);
System.err.println(" in : "+tryFlow.in); Decompiler.err.println(" in : "+tryFlow.in);
} }
} }
@ -832,8 +833,8 @@ public class TransformExceptionHandlers {
int endHandler = (i< count-1 && endPCs[i+1] > handlerPCs[i]) int endHandler = (i< count-1 && endPCs[i+1] > handlerPCs[i])
? endPCs[i+1] ? endPCs[i+1]
: Integer.MAX_VALUE; : Integer.MAX_VALUE;
if (jode.Decompiler.debugAnalyze) if (Decompiler.debugAnalyze)
System.err.println("analyzeCatch(" + startPCs[i] + ", " Decompiler.err.println("analyzeCatch(" + startPCs[i] + ", "
+ endPCs[i] + ", " +handlerPCs[i] + ")"); + endPCs[i] + ", " +handlerPCs[i] + ")");
FlowBlock tryFlow = flows[startPCs[i]]; FlowBlock tryFlow = flows[startPCs[i]];
while (tryFlow.analyze(startPCs[i], handlerPCs[i])); while (tryFlow.analyze(startPCs[i], handlerPCs[i]));
@ -873,8 +874,8 @@ public class TransformExceptionHandlers {
analyzeCatchBlock(jode.Type.tObject, tryFlow, catchFlow); analyzeCatchBlock(jode.Type.tObject, tryFlow, catchFlow);
tryFlow.checkConsistent(); tryFlow.checkConsistent();
if (jode.Decompiler.debugAnalyze) if (Decompiler.debugAnalyze)
System.err.println("analyzeCatch(" + tryFlow.addr + ", " Decompiler.err.println("analyzeCatch(" + tryFlow.addr + ", "
+ (tryFlow.addr + tryFlow.length) + + (tryFlow.addr + tryFlow.length) +
") done."); ") done.");
} }

@ -54,7 +54,7 @@ public class VariableSet implements Cloneable {
size += count; size += count;
if (size > locals.length) { if (size > locals.length) {
int nextSize = locals.length * 2; int nextSize = locals.length * 2;
// System.err.println("wanted: "+size+" next: "+nextSize); // Decompiler.err.println("wanted: "+size+" next: "+nextSize);
LocalInfo[] newLocals LocalInfo[] newLocals
= new LocalInfo[nextSize > size ? nextSize : size]; = new LocalInfo[nextSize > size ? nextSize : size];
System.arraycopy(locals, 0, newLocals, 0, count); System.arraycopy(locals, 0, newLocals, 0, count);

@ -31,7 +31,7 @@ public class ClassBundle {
public void loadClass(ClassInfo clazz) { public void loadClass(ClassInfo clazz) {
if (loadedClasses.get(clazz.getName()) != null) { if (loadedClasses.get(clazz.getName()) != null) {
System.err.println("warning: ignoring double class: " Decompiler.err.println("warning: ignoring double class: "
+ clazz.getName()); + clazz.getName());
return; return;
} }

@ -20,16 +20,18 @@ package jode;
import jode.bytecode.ClassInfo; import jode.bytecode.ClassInfo;
import jode.obfuscator.*; import jode.obfuscator.*;
import java.util.Vector; import java.util.Vector;
import java.lang.reflect.Modifier;
public class Obfuscator { public class Obfuscator {
public static boolean isVerbose = false; public static boolean isVerbose = false;
public static boolean isDebugging = false; public static boolean isDebugging = false;
public static final int PRESERVE_PRIVATE = 0; // does this make sense? public static final int PRESERVE_NONE = 0;
public static final int PRESERVE_PACKAGE = 1; public static final int PRESERVE_PUBLIC = Modifier.PUBLIC;
public static final int PRESERVE_PROTECTED = 2; public static final int PRESERVE_PROTECTED =
public static final int PRESERVE_PUBLIC = 3; PRESERVE_PUBLIC | Modifier.PROTECTED;
public static final int PRESERVE_NONE = 4; public static final int PRESERVE_PACKAGE =
PRESERVE_PROTECTED | Modifier.PRIVATE; //XXX
public static final int RENAME_STRONG = 0; public static final int RENAME_STRONG = 0;
public static final int RENAME_WEAK = 1; public static final int RENAME_WEAK = 1;
@ -38,42 +40,40 @@ public class Obfuscator {
public static final int RENAME_TABLE = 4; public static final int RENAME_TABLE = 4;
public static void usage() { public static void usage() {
System.err.println("usage: jode.Obfuscator flags* [class | package]*"); Decompiler.err.println("usage: jode.Obfuscator flags* [class | package]*");
System.err.println("\t[-v] "+"Verbose output"); Decompiler.err.println("\t[-v] "+"Verbose output");
System.err.println("\t[-debug] "+"Debugging"); Decompiler.err.println("\t[-debug] "+"Debugging");
System.err.println("\t[-nostrip] "+ Decompiler.err.println("\t[-nostrip] "+
"Don't strip not needed methods"); "Don't strip not needed methods");
System.err.println("\t[-sourcepath] "+ Decompiler.err.println("\t[-sourcepath] "+
"Colon-separated list of source-file directory"); "Colon-separated list of source-file directory");
System.err.println("\t[-d <directory>] "+ Decompiler.err.println("\t[-d <directory>] "+
"Destination directory for output classes"); "Destination directory for output classes");
System.err.println("Preserve options: "); Decompiler.err.println("Preserve options: ");
System.err.println("\t[-private] "+ Decompiler.err.println("\t[-package] "+
"Preserve all private members");
System.err.println("\t[-package] "+
"Preserve all package members"); "Preserve all package members");
System.err.println("\t[-protected] "+ Decompiler.err.println("\t[-protected] "+
"Preserve all protected members"); "Preserve all protected members");
System.err.println("\t[-public] "+ Decompiler.err.println("\t[-public] "+
"Preserve all public members"); "Preserve all public members");
System.err.println("\t[-class <name>] "+ Decompiler.err.println("\t[-class <name>] "+
"Preserve only the given class (allowed multiple times"); "Preserve only the given class (allowed multiple times");
System.err.println("\t[-method <name>] "+ Decompiler.err.println("\t[-method <name>] "+
"Preserve only the given metod (allowed multiple times"); "Preserve only the given metod (allowed multiple times");
System.err.println("Obfuscating options: "); Decompiler.err.println("Obfuscating options: ");
System.err.println("\t[-strong] "+ Decompiler.err.println("\t[-strong] "+
"Rename identifiers to random number/letters"); "Rename identifiers to random number/letters");
System.err.println("\t[-weak] "+ Decompiler.err.println("\t[-weak] "+
"Rename to random, but legal java identifier"); "Rename to random, but legal java identifier");
System.err.println("\t[-unique] "+ Decompiler.err.println("\t[-unique] "+
"Rename to unique legal java identifier"); "Rename to unique legal java identifier");
System.err.println("\t[-none] "+ Decompiler.err.println("\t[-none] "+
"Don't rename any method."); "Don't rename any method.");
System.err.println("\t[-table <file>] "+ Decompiler.err.println("\t[-table <file>] "+
"Read translation table from file"); "Read translation table from file");
System.err.println("\t[-revtable <file>] "+ Decompiler.err.println("\t[-revtable <file>] "+
"Write reversed translation table to file"); "Write reversed translation table to file");
} }
@ -107,8 +107,6 @@ public class Obfuscator {
destPath = params[++i]; destPath = params[++i];
/* Preserve options */ /* Preserve options */
else if (params[i].equals("-private"))
preserve = PRESERVE_PRIVATE;
else if (params[i].equals("-package")) else if (params[i].equals("-package"))
preserve = PRESERVE_PACKAGE; preserve = PRESERVE_PACKAGE;
else if (params[i].equals("-protected")) else if (params[i].equals("-protected"))
@ -145,13 +143,13 @@ public class Obfuscator {
break; break;
} else { } else {
if (!params[i].startsWith("-h")) if (!params[i].startsWith("-h"))
System.err.println("Unknown option: "+params[i]); Decompiler.err.println("Unknown option: "+params[i]);
usage(); usage();
return; return;
} }
} }
if (i == params.length) { if (i == params.length) {
System.err.println("No package or classes specified."); Decompiler.err.println("No package or classes specified.");
usage(); usage();
return; return;
} }

@ -397,7 +397,7 @@ public class Type {
if (result == tError) { if (result == tError) {
boolean oldTypeDebugging = Decompiler.isTypeDebugging; boolean oldTypeDebugging = Decompiler.isTypeDebugging;
Decompiler.isTypeDebugging = true; Decompiler.isTypeDebugging = true;
System.err.println("intersecting "+ this +" and "+ type Decompiler.err.println("intersecting "+ this +" and "+ type
+ " to <" + bottom + "," + top + ">" + " to <" + bottom + "," + top + ">"
+ " to <error>"); + " to <error>");
Decompiler.isTypeDebugging = oldTypeDebugging; Decompiler.isTypeDebugging = oldTypeDebugging;
@ -405,10 +405,10 @@ public class Type {
throw new AssertError("type error"); throw new AssertError("type error");
} else if (Decompiler.isTypeDebugging) { } else if (Decompiler.isTypeDebugging) {
if (this.equals(type)) { if (this.equals(type)) {
// System.err.println("intersecting identical: "+this); // Decompiler.err.println("intersecting identical: "+this);
// Thread.dumpStack(); // Thread.dumpStack();
} else } else
System.err.println("intersecting "+ this +" and "+ type + Decompiler.err.println("intersecting "+ this +" and "+ type +
" to " + result); " to " + result);
} }

Loading…
Cancel
Save