From a6bc1392d1dc001a9f11800b353e7f0576527e18 Mon Sep 17 00:00:00 2001 From: jochen Date: Sun, 17 Jan 1999 18:15:56 +0000 Subject: [PATCH] *** empty log message *** git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@163 379699f6-c40d-0410-875b-85095c16579e --- jode/jode/bytecode/ClassInfo.java | 30 +++-- jode/jode/bytecode/SearchPath.java | 127 +++++++++++++++--- jode/jode/decompiler/LocalInfo.java | 8 +- .../decompiler/LocalVariableRangeList.java | 2 +- jode/jode/decompiler/LocalVariableTable.java | 2 +- jode/jode/decompiler/MethodAnalyzer.java | 8 +- jode/jode/expr/ComplexExpression.java | 4 +- jode/jode/expr/LocalLoadOperator.java | 9 +- jode/jode/flow/CompleteSynchronized.java | 5 +- jode/jode/flow/CreateConstantArray.java | 5 +- jode/jode/flow/CreateExpression.java | 5 +- jode/jode/flow/CreateForInitializer.java | 5 +- jode/jode/flow/CreateIfThenElseOperator.java | 9 +- jode/jode/flow/FlowBlock.java | 30 ++--- jode/jode/flow/RemoveEmpty.java | 5 +- jode/jode/flow/TransformConstructors.java | 18 +-- .../jode/flow/TransformExceptionHandlers.java | 17 +-- jode/jode/flow/VariableSet.java | 2 +- jode/jode/obfuscator/ClassBundle.java | 2 +- jode/jode/obfuscator/Main.java | 58 ++++---- jode/jode/type/Type.java | 6 +- 21 files changed, 227 insertions(+), 130 deletions(-) diff --git a/jode/jode/bytecode/ClassInfo.java b/jode/jode/bytecode/ClassInfo.java index 50dcc7a..19a9c70 100644 --- a/jode/jode/bytecode/ClassInfo.java +++ b/jode/jode/bytecode/ClassInfo.java @@ -48,11 +48,20 @@ public class ClassInfo extends BinaryInfo { private MethodInfo[] methods; private AttributeInfo[] attributes; - public final static ClassInfo javaLangObject = - ClassInfo.forName("java.lang.Object"); + public final static ClassInfo javaLangObject = forName("java.lang.Object"); public static void setClassPath(String 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) { @@ -202,16 +211,15 @@ public class ClassInfo extends BinaryInfo { } catch (IOException ex) { String message = ex.getLocalizedMessage(); if ((howMuch & ~(METHODS|HIERARCHY)) == 0) - System.err.println("Can't read class " + name - + ", types may be incorrect. (" - + ex.getClass().getName() - + (message != null ? ": " + message : "") - + ")"); + jode.Decompiler.err.println + ("Can't read class " + name + ", types may be incorrect. (" + + ex.getClass().getName() + + (message != null ? ": " + message : "") + ")"); else - System.err.println("Can't read class " + name + "(" - + ex.getClass().getName() - + (message != null ? ": " + message : "") - + ")"); + jode.Decompiler.err.println + ("Can't read class " + name + + "(" + ex.getClass().getName() + + (message != null ? ": " + message : "") + ")"); if (name.equals("java.lang.Object")) superclass = null; diff --git a/jode/jode/bytecode/SearchPath.java b/jode/jode/bytecode/SearchPath.java index b367fa6..a25ff44 100644 --- a/jode/jode/bytecode/SearchPath.java +++ b/jode/jode/bytecode/SearchPath.java @@ -18,10 +18,12 @@ */ package jode.bytecode; import java.io.*; +import java.net.*; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; import java.util.StringTokenizer; import java.util.Enumeration; +import jode.Decompiler; /** * This class represents a path of multiple directories and/or zip files, @@ -31,6 +33,12 @@ import java.util.Enumeration; */ 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; ZipFile[] zips; @@ -45,23 +53,59 @@ public class SearchPath { new StringTokenizer(path, File.pathSeparator); int length = tokenizer.countTokens(); + bases = new URL[length]; dirs = new File[length]; zips = new ZipFile[length]; for (int i=0; i< length; i++) { - dirs[i] = new File(tokenizer.nextToken()); - if (!dirs[i].isDirectory()) { - try { - zips[i] = new ZipFile(dirs[i]); - } catch (java.io.IOException ex) { - /* disable this entry */ - dirs[i] = null; - } - } - } + String token = tokenizer.nextToken() + .replace(protocolSeparator, ':'); + int index = token.indexOf(':'); + if (index != -1 && index < token.length()-2 + && token.charAt(index+1) == '/' + && token.charAt(index+2) == '/') { + // 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) { for (int i=0; i after.start) - System.err.println("warning: non disjoint locals"); + Decompiler.err.println("warning: non disjoint locals"); li.next = after; if (before == null) list = li; diff --git a/jode/jode/decompiler/LocalVariableTable.java b/jode/jode/decompiler/LocalVariableTable.java index d74c65b..43d4872 100644 --- a/jode/jode/decompiler/LocalVariableTable.java +++ b/jode/jode/decompiler/LocalVariableTable.java @@ -46,7 +46,7 @@ public class LocalVariableTable { int slot = stream.readUnsignedShort(); locals[slot].addLocal(start, end-start, name, type); if (Decompiler.showLVT) - System.err.println(name + ": " + type + Decompiler.err.println(name + ": " + type +" range "+start+" - "+end +" slot "+slot); } diff --git a/jode/jode/decompiler/MethodAnalyzer.java b/jode/jode/decompiler/MethodAnalyzer.java index 745fd6e..cc6b88d 100644 --- a/jode/jode/decompiler/MethodAnalyzer.java +++ b/jode/jode/decompiler/MethodAnalyzer.java @@ -132,10 +132,10 @@ public class MethodAnalyzer implements Analyzer { if (!Decompiler.immediateOutput) { if (Decompiler.isVerbose) - System.err.print(methodName+": "); + Decompiler.err.print(methodName+": "); code.analyze(); if (Decompiler.isVerbose) - System.err.println(""); + Decompiler.err.println(""); } } @@ -147,10 +147,10 @@ public class MethodAnalyzer implements Analyzer { // immediate output. if (Decompiler.isVerbose) - System.err.print(methodName+": "); + Decompiler.err.print(methodName+": "); code.analyze(); if (Decompiler.isVerbose) - System.err.println(""); + Decompiler.err.println(""); } if (isConstructor() && isStatic() diff --git a/jode/jode/expr/ComplexExpression.java b/jode/jode/expr/ComplexExpression.java index 1b11380..c9d187d 100644 --- a/jode/jode/expr/ComplexExpression.java +++ b/jode/jode/expr/ComplexExpression.java @@ -175,7 +175,7 @@ public class ComplexExpression extends Expression { opType = opType.intersection(exprType); if (!opType.equals(exprType) && opType != Type.tError) { if (Decompiler.isTypeDebugging) - System.err.println("change in "+this+": " + Decompiler.err.println("change in "+this+": " +exprType +"->"+opType); subExpressions[i].setType(opType); @@ -205,7 +205,7 @@ public class ComplexExpression extends Expression { if (!types[i].equals(opType) && types[i] != Type.tError) { if (Decompiler.isTypeDebugging) - System.err.println("change in "+this+": " + Decompiler.err.println("change in "+this+": " +operator.getOperandType(i) +"->"+types[i]); changed = true; diff --git a/jode/jode/expr/LocalLoadOperator.java b/jode/jode/expr/LocalLoadOperator.java index e34506f..393a62a 100644 --- a/jode/jode/expr/LocalLoadOperator.java +++ b/jode/jode/expr/LocalLoadOperator.java @@ -18,6 +18,7 @@ */ package jode.decompiler; +import jode.Decompiler; import jode.Type; import jode.LocalInfo; @@ -49,8 +50,8 @@ implements LocalVarOperator { } public void updateType() { - if (jode.Decompiler.isTypeDebugging) - System.err.println("local "+local.getName()+" changed: " + if (Decompiler.isTypeDebugging) + Decompiler.err.println("local "+local.getName()+" changed: " +type+" to "+local.getType() +" in "+parent); super.setType(local.getType()); @@ -59,12 +60,12 @@ implements LocalVarOperator { } 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(); } 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)); } diff --git a/jode/jode/flow/CompleteSynchronized.java b/jode/jode/flow/CompleteSynchronized.java index 163548e..e4e4ba9 100644 --- a/jode/jode/flow/CompleteSynchronized.java +++ b/jode/jode/flow/CompleteSynchronized.java @@ -18,6 +18,7 @@ */ package jode.flow; +import jode.Decompiler; import jode.decompiler.*; public class CompleteSynchronized { @@ -48,8 +49,8 @@ public class CompleteSynchronized { return false; } - if (jode.Decompiler.isVerbose) - System.err.print('s'); + if (Decompiler.isVerbose) + Decompiler.err.print('s'); synBlock.isEntered = true; synBlock.moveDefinitions(last.outer,last); diff --git a/jode/jode/flow/CreateConstantArray.java b/jode/jode/flow/CreateConstantArray.java index d88df9b..3512662 100644 --- a/jode/jode/flow/CreateConstantArray.java +++ b/jode/jode/flow/CreateConstantArray.java @@ -18,6 +18,7 @@ */ package jode.flow; +import jode.Decompiler; import jode.decompiler.*; import jode.Type; @@ -96,8 +97,8 @@ public class CreateConstantArray { if (arraylength <= index) return false; - if (jode.Decompiler.isVerbose) - System.err.print('a'); + if (Decompiler.isVerbose) + Decompiler.err.print('a'); ConstantArrayOperator cao = new ConstantArrayOperator(newArrayOp.getType(), diff --git a/jode/jode/flow/CreateExpression.java b/jode/jode/flow/CreateExpression.java index 3cb152a..727836d 100644 --- a/jode/jode/flow/CreateExpression.java +++ b/jode/jode/flow/CreateExpression.java @@ -18,6 +18,7 @@ */ package jode.flow; +import jode.Decompiler; import jode.decompiler.*; /** @@ -110,8 +111,8 @@ public class CreateExpression { sequBlock = (SequentialBlock)sequBlock.outer; } - if(jode.Decompiler.isVerbose) - System.err.print('x'); + if(Decompiler.isVerbose) + Decompiler.err.print('x'); Expression newExpr; if (params == 1 && op instanceof NopOperator) { diff --git a/jode/jode/flow/CreateForInitializer.java b/jode/jode/flow/CreateForInitializer.java index dfcf2be..6e6ed6d 100644 --- a/jode/jode/flow/CreateForInitializer.java +++ b/jode/jode/flow/CreateForInitializer.java @@ -18,6 +18,7 @@ */ package jode.flow; +import jode.Decompiler; import jode.decompiler.*; public class CreateForInitializer { @@ -43,8 +44,8 @@ public class CreateForInitializer { || !forBlock.conditionMatches(init)) return false; - if (jode.Decompiler.isVerbose) - System.err.print('f'); + if (Decompiler.isVerbose) + Decompiler.err.print('f'); forBlock.setInit((InstructionBlock) sequBlock.subBlocks[0]); return true; diff --git a/jode/jode/flow/CreateIfThenElseOperator.java b/jode/jode/flow/CreateIfThenElseOperator.java index 6706744..b0c7a53 100644 --- a/jode/jode/flow/CreateIfThenElseOperator.java +++ b/jode/jode/flow/CreateIfThenElseOperator.java @@ -18,6 +18,7 @@ */ package jode.flow; +import jode.Decompiler; import jode.Type; import jode.decompiler.*; @@ -62,8 +63,8 @@ public class CreateIfThenElseOperator { | !createFunnyHelper(trueDest, falseDest, ifBlock.elseBlock)) return false; - if (jode.Decompiler.isVerbose) - System.err.print('?'); + if (Decompiler.isVerbose) + Decompiler.err.print('?'); IfThenElseOperator iteo = new IfThenElseOperator(Type.tBoolean); ((InstructionBlock)ifBlock.thenBlock).setInstruction @@ -217,8 +218,8 @@ public class CreateIfThenElseOperator { return false; e[0] = ifBlock.cond; - if (jode.Decompiler.isVerbose) - System.err.print('?'); + if (Decompiler.isVerbose) + Decompiler.err.print('?'); thenBlock.flowBlock.removeSuccessor(thenBlock.jump); thenBlock.removeJump(); diff --git a/jode/jode/flow/FlowBlock.java b/jode/jode/flow/FlowBlock.java index dbaf031..97d8d46 100644 --- a/jode/jode/flow/FlowBlock.java +++ b/jode/jode/flow/FlowBlock.java @@ -519,10 +519,10 @@ public class FlowBlock { this.gen.unionExact(successor.gen); if (Decompiler.debugInOut) { - System.err.println("UpdateInOut: gens : "+gens); - System.err.println(" kills: "+kills); - System.err.println(" s.in : "+successor.in); - System.err.println(" in : "+in); + Decompiler.err.println("UpdateInOut: gens : "+gens); + Decompiler.err.println(" kills: "+kills); + Decompiler.err.println(" s.in : "+successor.in); + Decompiler.err.println(" in : "+in); } } @@ -643,16 +643,16 @@ public class FlowBlock { /* Update the in/out-Vectors now */ updateInOut(succ, jumps); if (Decompiler.isFlowDebugging) - System.err.println("before Optimize: "+this); + Decompiler.err.println("before Optimize: "+this); /* Try to eliminate as many jumps as possible. */ jumps = optimizeJumps(jumps, succ); if (Decompiler.isFlowDebugging) - System.err.println("before Remaining: "+this); + Decompiler.err.println("before Remaining: "+this); resolveRemaining(jumps); if (Decompiler.isFlowDebugging) - System.err.println("after Optimize: "+this); + Decompiler.err.println("after Optimize: "+this); /* Now unify the blocks. */ @@ -952,7 +952,7 @@ public class FlowBlock { public void doTransformations() { if (Decompiler.isFlowDebugging) - System.err.println("before Transformation: "+this); + Decompiler.err.println("before Transformation: "+this); while (lastModified instanceof SequentialBlock) { if (!lastModified.getSubBlocks()[0].doTransformations()) @@ -962,7 +962,7 @@ public class FlowBlock { /* empty */; 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) { if (Decompiler.debugAnalyze) - System.err.println("analyze("+start+", "+end+")"); + Decompiler.err.println("analyze("+start+", "+end+")"); boolean changed = false; @@ -1023,10 +1023,10 @@ public class FlowBlock { if (doT2(start, end)) { if (Decompiler.isFlowDebugging) - System.err.println("after T2: "+this); + Decompiler.err.println("after T2: "+this); if (Decompiler.debugAnalyze) - System.err.println("T2("+addr+","+(addr+length) + Decompiler.err.println("T2("+addr+","+(addr+length) +") succeeded"); /* T2 transformation succeeded. This may * make another T1 analysis in the previous @@ -1043,7 +1043,7 @@ public class FlowBlock { * Finish this analyzation. */ if (Decompiler.debugAnalyze) - System.err.println + Decompiler.err.println ("No more successors applicable: " + start + " - " + end + "; " + addr + " - " + (addr+length)); @@ -1058,7 +1058,7 @@ public class FlowBlock { changed = true; if (Decompiler.isFlowDebugging) - System.err.println("after T1: "+this); + Decompiler.err.println("after T1: "+this); break; } @@ -1072,7 +1072,7 @@ public class FlowBlock { ((FlowBlock)enum.nextElement()).addr; if (predAddr < start || predAddr >= end) { if (Decompiler.debugAnalyze) - System.err.println + Decompiler.err.println ("breaking analyze(" + start + ", " + end + "); " + addr + " - " + (addr+length)); diff --git a/jode/jode/flow/RemoveEmpty.java b/jode/jode/flow/RemoveEmpty.java index adb8f04..6c58f46 100644 --- a/jode/jode/flow/RemoveEmpty.java +++ b/jode/jode/flow/RemoveEmpty.java @@ -18,6 +18,7 @@ */ package jode.flow; +import jode.Decompiler; import jode.decompiler.*; public class RemoveEmpty { @@ -49,8 +50,8 @@ public class RemoveEmpty { /* XXX check if blocks may be swapped * (there mustn't be side effects in one of them). */ - System.err.println("WARNING: this program contains a SWAP " - +"opcode and may not be translated correctly."); + Decompiler.err.println("WARNING: this program contains a SWAP " + +"opcode and may not be translated correctly."); if (block1.getInstruction().isVoid() || block2.getInstruction().isVoid()) diff --git a/jode/jode/flow/TransformConstructors.java b/jode/jode/flow/TransformConstructors.java index 2db2c32..7546587 100644 --- a/jode/jode/flow/TransformConstructors.java +++ b/jode/jode/flow/TransformConstructors.java @@ -36,7 +36,7 @@ public class TransformConstructors { StructuredBlock[] sb = new StructuredBlock[constrCount]; for (int i=0; i< constrCount; ) { sb[i] = cons[i].getMethodHeader().block; -// System.err.println("constr "+i+": "+sb[i]); +// Decompiler.err.println("constr "+i+": "+sb[i]); if (!isStatic) { InstructionBlock ib; if (sb[i] instanceof InstructionBlock) @@ -64,7 +64,7 @@ public class TransformConstructors { /* This constructor calls another constructor, so we * can skip it. */ -// System.err.println("skipping this()"); +// Decompiler.err.println("skipping this()"); cons[i] = cons[--constrCount]; continue; } @@ -78,7 +78,7 @@ public class TransformConstructors { sb[i] = sb[i].getSubBlocks()[1]; else sb[i] = null; -// System.err.println("normal constructor"); +// Decompiler.err.println("normal constructor"); } i++; } @@ -107,16 +107,16 @@ public class TransformConstructors { if (!expr.isConstant()) { -// System.err.println("not constant: "+expr); +// Decompiler.err.println("not constant: "+expr); break big_loop; } -// System.err.println("field "+pfo.getFieldName()+ " = "+expr); +// Decompiler.err.println("field "+pfo.getFieldName()+ " = "+expr); if (!isStatic && !(((ComplexExpression)instr).getSubExpressions()[0] .toString().equals("this"))) { -// System.err.println("not this: "+instr); +// Decompiler.err.println("not this: "+instr); break big_loop; } @@ -126,14 +126,14 @@ public class TransformConstructors { : sb[i]; if (!(ib instanceof InstructionBlock) || !((InstructionBlock)ib).getInstruction().equals(instr)) { -// System.err.println("constr "+i+" differs: "+ib); +// Decompiler.err.println("constr "+i+" differs: "+ib); break big_loop; } } if (!clazzAnalyzer.setFieldInitializer(pfo.getFieldName(), expr)) { -// System.err.println("setField failed"); +// Decompiler.err.println("setField failed"); break big_loop; } @@ -146,7 +146,7 @@ public class TransformConstructors { } for (int i=0; i< constrCount; i++) if (sb[i] == null) { -// System.err.println("constr "+i+" is over"); +// Decompiler.err.println("constr "+i+" is over"); break big_loop; } } diff --git a/jode/jode/flow/TransformExceptionHandlers.java b/jode/jode/flow/TransformExceptionHandlers.java index f046d41..62ccb3d 100644 --- a/jode/jode/flow/TransformExceptionHandlers.java +++ b/jode/jode/flow/TransformExceptionHandlers.java @@ -18,6 +18,7 @@ */ package jode.flow; import jode.AssertError; +import jode.Decompiler; import jode.Type; import jode.LocalInfo; import jode.decompiler.*; @@ -139,10 +140,10 @@ public class TransformExceptionHandlers { tryFlow.in.unionExact(catchFlow.in); tryFlow.gen.unionExact(catchFlow.gen); - if (jode.Decompiler.debugInOut) { - System.err.println("UpdateInOutCatch: gens : "+gens); - System.err.println(" s.in : "+catchFlow.in); - System.err.println(" in : "+tryFlow.in); + if (Decompiler.debugInOut) { + Decompiler.err.println("UpdateInOutCatch: gens : "+gens); + Decompiler.err.println(" s.in : "+catchFlow.in); + Decompiler.err.println(" in : "+tryFlow.in); } } @@ -832,8 +833,8 @@ public class TransformExceptionHandlers { int endHandler = (i< count-1 && endPCs[i+1] > handlerPCs[i]) ? endPCs[i+1] : Integer.MAX_VALUE; - if (jode.Decompiler.debugAnalyze) - System.err.println("analyzeCatch(" + startPCs[i] + ", " + if (Decompiler.debugAnalyze) + Decompiler.err.println("analyzeCatch(" + startPCs[i] + ", " + endPCs[i] + ", " +handlerPCs[i] + ")"); FlowBlock tryFlow = flows[startPCs[i]]; while (tryFlow.analyze(startPCs[i], handlerPCs[i])); @@ -873,8 +874,8 @@ public class TransformExceptionHandlers { analyzeCatchBlock(jode.Type.tObject, tryFlow, catchFlow); tryFlow.checkConsistent(); - if (jode.Decompiler.debugAnalyze) - System.err.println("analyzeCatch(" + tryFlow.addr + ", " + if (Decompiler.debugAnalyze) + Decompiler.err.println("analyzeCatch(" + tryFlow.addr + ", " + (tryFlow.addr + tryFlow.length) + ") done."); } diff --git a/jode/jode/flow/VariableSet.java b/jode/jode/flow/VariableSet.java index df5cd08..d1ac8a3 100644 --- a/jode/jode/flow/VariableSet.java +++ b/jode/jode/flow/VariableSet.java @@ -54,7 +54,7 @@ public class VariableSet implements Cloneable { size += count; if (size > locals.length) { int nextSize = locals.length * 2; -// System.err.println("wanted: "+size+" next: "+nextSize); +// Decompiler.err.println("wanted: "+size+" next: "+nextSize); LocalInfo[] newLocals = new LocalInfo[nextSize > size ? nextSize : size]; System.arraycopy(locals, 0, newLocals, 0, count); diff --git a/jode/jode/obfuscator/ClassBundle.java b/jode/jode/obfuscator/ClassBundle.java index 52520a2..0e936bb 100644 --- a/jode/jode/obfuscator/ClassBundle.java +++ b/jode/jode/obfuscator/ClassBundle.java @@ -31,7 +31,7 @@ public class ClassBundle { public void loadClass(ClassInfo clazz) { if (loadedClasses.get(clazz.getName()) != null) { - System.err.println("warning: ignoring double class: " + Decompiler.err.println("warning: ignoring double class: " + clazz.getName()); return; } diff --git a/jode/jode/obfuscator/Main.java b/jode/jode/obfuscator/Main.java index b5f2b81..6dffdbf 100644 --- a/jode/jode/obfuscator/Main.java +++ b/jode/jode/obfuscator/Main.java @@ -20,16 +20,18 @@ package jode; import jode.bytecode.ClassInfo; import jode.obfuscator.*; import java.util.Vector; +import java.lang.reflect.Modifier; public class Obfuscator { public static boolean isVerbose = false; public static boolean isDebugging = false; - public static final int PRESERVE_PRIVATE = 0; // does this make sense? - public static final int PRESERVE_PACKAGE = 1; - public static final int PRESERVE_PROTECTED = 2; - public static final int PRESERVE_PUBLIC = 3; - public static final int PRESERVE_NONE = 4; + public static final int PRESERVE_NONE = 0; + public static final int PRESERVE_PUBLIC = Modifier.PUBLIC; + public static final int PRESERVE_PROTECTED = + PRESERVE_PUBLIC | Modifier.PROTECTED; + public static final int PRESERVE_PACKAGE = + PRESERVE_PROTECTED | Modifier.PRIVATE; //XXX public static final int RENAME_STRONG = 0; public static final int RENAME_WEAK = 1; @@ -38,42 +40,40 @@ public class Obfuscator { public static final int RENAME_TABLE = 4; public static void usage() { - System.err.println("usage: jode.Obfuscator flags* [class | package]*"); - System.err.println("\t[-v] "+"Verbose output"); - System.err.println("\t[-debug] "+"Debugging"); - System.err.println("\t[-nostrip] "+ + Decompiler.err.println("usage: jode.Obfuscator flags* [class | package]*"); + Decompiler.err.println("\t[-v] "+"Verbose output"); + Decompiler.err.println("\t[-debug] "+"Debugging"); + Decompiler.err.println("\t[-nostrip] "+ "Don't strip not needed methods"); - System.err.println("\t[-sourcepath] "+ + Decompiler.err.println("\t[-sourcepath] "+ "Colon-separated list of source-file directory"); - System.err.println("\t[-d ] "+ + Decompiler.err.println("\t[-d ] "+ "Destination directory for output classes"); - System.err.println("Preserve options: "); - System.err.println("\t[-private] "+ - "Preserve all private members"); - System.err.println("\t[-package] "+ + Decompiler.err.println("Preserve options: "); + Decompiler.err.println("\t[-package] "+ "Preserve all package members"); - System.err.println("\t[-protected] "+ + Decompiler.err.println("\t[-protected] "+ "Preserve all protected members"); - System.err.println("\t[-public] "+ + Decompiler.err.println("\t[-public] "+ "Preserve all public members"); - System.err.println("\t[-class ] "+ + Decompiler.err.println("\t[-class ] "+ "Preserve only the given class (allowed multiple times"); - System.err.println("\t[-method ] "+ + Decompiler.err.println("\t[-method ] "+ "Preserve only the given metod (allowed multiple times"); - System.err.println("Obfuscating options: "); - System.err.println("\t[-strong] "+ + Decompiler.err.println("Obfuscating options: "); + Decompiler.err.println("\t[-strong] "+ "Rename identifiers to random number/letters"); - System.err.println("\t[-weak] "+ + Decompiler.err.println("\t[-weak] "+ "Rename to random, but legal java identifier"); - System.err.println("\t[-unique] "+ + Decompiler.err.println("\t[-unique] "+ "Rename to unique legal java identifier"); - System.err.println("\t[-none] "+ + Decompiler.err.println("\t[-none] "+ "Don't rename any method."); - System.err.println("\t[-table ] "+ + Decompiler.err.println("\t[-table ] "+ "Read translation table from file"); - System.err.println("\t[-revtable ] "+ + Decompiler.err.println("\t[-revtable ] "+ "Write reversed translation table to file"); } @@ -107,8 +107,6 @@ public class Obfuscator { destPath = params[++i]; /* Preserve options */ - else if (params[i].equals("-private")) - preserve = PRESERVE_PRIVATE; else if (params[i].equals("-package")) preserve = PRESERVE_PACKAGE; else if (params[i].equals("-protected")) @@ -145,13 +143,13 @@ public class Obfuscator { break; } else { if (!params[i].startsWith("-h")) - System.err.println("Unknown option: "+params[i]); + Decompiler.err.println("Unknown option: "+params[i]); usage(); return; } } if (i == params.length) { - System.err.println("No package or classes specified."); + Decompiler.err.println("No package or classes specified."); usage(); return; } diff --git a/jode/jode/type/Type.java b/jode/jode/type/Type.java index 5fc9999..edef4e3 100644 --- a/jode/jode/type/Type.java +++ b/jode/jode/type/Type.java @@ -397,7 +397,7 @@ public class Type { if (result == tError) { boolean oldTypeDebugging = Decompiler.isTypeDebugging; Decompiler.isTypeDebugging = true; - System.err.println("intersecting "+ this +" and "+ type + Decompiler.err.println("intersecting "+ this +" and "+ type + " to <" + bottom + "," + top + ">" + " to "); Decompiler.isTypeDebugging = oldTypeDebugging; @@ -405,10 +405,10 @@ public class Type { throw new AssertError("type error"); } else if (Decompiler.isTypeDebugging) { if (this.equals(type)) { -// System.err.println("intersecting identical: "+this); +// Decompiler.err.println("intersecting identical: "+this); // Thread.dumpStack(); } else - System.err.println("intersecting "+ this +" and "+ type + + Decompiler.err.println("intersecting "+ this +" and "+ type + " to " + result); }