new_decompiler_package

git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@255 379699f6-c40d-0410-875b-85095c16579e
stable
jochen 26 years ago
parent 2ddfc783b7
commit ab5f3eb09f
  1. 1
      jode/JodeAppletOneZero.java
  2. 1
      jode/jode/Decompiler.java
  3. 1
      jode/jode/JodeWindow.java
  4. 2
      jode/jode/bytecode/AttributeInfo.java
  5. 2
      jode/jode/decompiler/Analyzer.java
  6. 67
      jode/jode/decompiler/ClassAnalyzer.java
  7. 4
      jode/jode/decompiler/CodeAnalyzer.java
  8. 7
      jode/jode/decompiler/FieldAnalyzer.java
  9. 2
      jode/jode/decompiler/ImportHandler.java
  10. 4
      jode/jode/decompiler/LocalInfo.java
  11. 4
      jode/jode/decompiler/LocalVariableRangeList.java
  12. 6
      jode/jode/decompiler/LocalVariableTable.java
  13. 11
      jode/jode/decompiler/MethodAnalyzer.java
  14. 9
      jode/jode/decompiler/Opcodes.java
  15. 3
      jode/jode/decompiler/TabbedPrintWriter.java
  16. 2
      jode/jode/expr/CheckNullOperator.java
  17. 2
      jode/jode/expr/ClassFieldOperator.java
  18. 2
      jode/jode/expr/ConstantArrayOperator.java
  19. 2
      jode/jode/expr/GetFieldOperator.java
  20. 2
      jode/jode/expr/IIncOperator.java
  21. 2
      jode/jode/expr/InvokeOperator.java
  22. 2
      jode/jode/expr/LocalLoadOperator.java
  23. 2
      jode/jode/expr/LocalStoreOperator.java
  24. 2
      jode/jode/expr/LocalVarOperator.java
  25. 8
      jode/jode/expr/PutFieldOperator.java
  26. 2
      jode/jode/flow/BreakBlock.java
  27. 2
      jode/jode/flow/BreakableBlock.java
  28. 4
      jode/jode/flow/CaseBlock.java
  29. 6
      jode/jode/flow/CatchBlock.java
  30. 2
      jode/jode/flow/ConditionalBlock.java
  31. 2
      jode/jode/flow/ContinueBlock.java
  32. 2
      jode/jode/flow/CreateCheckNull.java
  33. 2
      jode/jode/flow/DescriptionBlock.java
  34. 2
      jode/jode/flow/EmptyBlock.java
  35. 2
      jode/jode/flow/FinallyBlock.java
  36. 5
      jode/jode/flow/FlowBlock.java
  37. 2
      jode/jode/flow/IfThenElseBlock.java
  38. 4
      jode/jode/flow/InstructionBlock.java
  39. 2
      jode/jode/flow/JsrBlock.java
  40. 2
      jode/jode/flow/Jump.java
  41. 4
      jode/jode/flow/LoopBlock.java
  42. 4
      jode/jode/flow/RetBlock.java
  43. 2
      jode/jode/flow/ReturnBlock.java
  44. 2
      jode/jode/flow/SequentialBlock.java
  45. 2
      jode/jode/flow/SpecialBlock.java
  46. 12
      jode/jode/flow/StructuredBlock.java
  47. 2
      jode/jode/flow/SwitchBlock.java
  48. 4
      jode/jode/flow/SynchronizedBlock.java
  49. 2
      jode/jode/flow/ThrowBlock.java
  50. 8
      jode/jode/flow/TransformConstructors.java
  51. 2
      jode/jode/flow/TransformExceptionHandlers.java
  52. 2
      jode/jode/flow/TryBlock.java
  53. 2
      jode/jode/flow/VariableSet.java
  54. 4
      jode/jode/obfuscator/ClassBundle.java
  55. 44
      jode/jode/obfuscator/ClassIdentifier.java
  56. 9
      jode/jode/obfuscator/FieldIdentifier.java
  57. 6
      jode/jode/obfuscator/Identifier.java
  58. 8
      jode/jode/obfuscator/Main.java
  59. 13
      jode/jode/obfuscator/MethodIdentifier.java
  60. 35
      jode/jode/obfuscator/PackageIdentifier.java

@ -2,6 +2,7 @@ package jode;
import java.applet.*;
import java.awt.*;
import java.io.*;
import jode.decompiler.TabbedPrintWriter;
public class JodeAppletOneZero extends Applet implements Runnable {

@ -19,6 +19,7 @@
package jode;
import java.io.*;
import jode.decompiler.TabbedPrintWriter;
public class Decompiler {
public final static String version = "0.99";

@ -3,6 +3,7 @@ import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import jode.decompiler.TabbedPrintWriter;
public class JodeWindow
implements ActionListener, Runnable

@ -17,7 +17,7 @@
* $Id$
*/
package jode.bytecode;
import jode.TabbedPrintWriter;
import jode.decompiler.TabbedPrintWriter;
import java.io.*;
import java.lang.reflect.Modifier;

@ -17,7 +17,7 @@
* $Id$
*/
package jode;
package jode.decompiler;
public interface Analyzer {
public void analyze();

@ -17,20 +17,22 @@
* $Id$
*/
package jode;
package jode.decompiler;
import jode.*;
import jode.bytecode.ClassInfo;
import jode.bytecode.FieldInfo;
import jode.bytecode.MethodInfo;
import jode.bytecode.ConstantPool;
import jode.bytecode.ClassFormatException;
import jode.decompiler.Expression;
import jode.expr.Expression;
import jode.flow.TransformConstructors;
import java.lang.reflect.Modifier;
public class ClassAnalyzer implements Analyzer {
JodeEnvironment env;
Analyzer[] analyzers;
FieldAnalyzer[] fields;
MethodAnalyzer[] methods;
MethodAnalyzer staticConstructor;
MethodAnalyzer[] constructors;
@ -46,14 +48,14 @@ public class ClassAnalyzer implements Analyzer {
this.env = env;
}
public boolean setFieldInitializer(String fieldName, Expression expr) {
for (int i=0; i< analyzers.length; i++) {
if (analyzers[i] instanceof FieldAnalyzer) {
FieldAnalyzer field = (FieldAnalyzer) analyzers[i];
if (field.getName().equals(fieldName))
return field.setInitializer(expr);
}
public boolean setFieldInitializer(String fieldName, Type fieldType,
Expression expr) {
for (int i=0; i< fields.length; i++) {
if (fields[i].getName().equals(fieldName)
&& fields[i].getType().isOfType(fieldType))
return fields[i].setInitializer(expr);
}
System.err.println("Can't find field "+fieldType+" "+fieldName+".");
return false;
}
@ -65,37 +67,42 @@ public class ClassAnalyzer implements Analyzer {
int numFields = 0;
int i = 0;
FieldInfo[] fields = clazz.getFields();
MethodInfo[] methods = clazz.getMethods();
if (fields == null) {
FieldInfo[] finfos = clazz.getFields();
MethodInfo[] minfos = clazz.getMethods();
if (finfos == null) {
/* This means that the class could not be loaded.
* give up.
*/
return;
}
analyzers = new Analyzer[fields.length +
methods.length];
for (int j=0; j < fields.length; j++) {
analyzers[i] = new FieldAnalyzer(this, fields[j], env);
analyzers[i++].analyze();
fields = new FieldAnalyzer[finfos.length];
methods = new MethodAnalyzer[minfos.length];
for (int j=0; j < finfos.length; j++) {
fields[j] = new FieldAnalyzer(this, finfos[j], env);
fields[j].analyze();
}
staticConstructor = null;
java.util.Vector constrVector = new java.util.Vector();
for (int j=0; j < methods.length; j++) {
MethodAnalyzer analyzer =
new MethodAnalyzer(this, methods[j], env);
analyzers[i++] = analyzer;
methods[j] = new MethodAnalyzer(this, minfos[j], env);
if (analyzer.isConstructor()) {
if (analyzer.isStatic())
staticConstructor = analyzer;
if (methods[j].isConstructor()) {
if (methods[j].isStatic())
staticConstructor = methods[j];
else
constrVector.addElement(analyzer);
constrVector.addElement(methods[j]);
}
analyzer.analyze();
// First analyze only synthetic methods.
if (methods[j].isSynthetic())
methods[j].analyze();
}
for (int j=0; j < methods.length; j++) {
// Now analyze the remaining methods
if (!methods[j].isSynthetic())
methods[j].analyze();
}
constructors = new MethodAnalyzer[constrVector.size()];
if (constructors.length > 0) {
constrVector.copyInto(constructors);
@ -115,7 +122,7 @@ public class ClassAnalyzer implements Analyzer {
public void dumpSource(TabbedPrintWriter writer) throws java.io.IOException
{
if (analyzers == null) {
if (fields == null) {
/* This means that the class could not be loaded.
* give up.
*/
@ -148,8 +155,10 @@ public class ClassAnalyzer implements Analyzer {
writer.openBrace();
writer.tab();
for (int i=0; i< analyzers.length; i++)
analyzers[i].dumpSource(writer);
for (int i=0; i< fields.length; i++)
fields[i].dumpSource(writer);
for (int i=0; i< methods.length; i++)
methods[i].dumpSource(writer);
writer.untab();
writer.closeBrace();
}

@ -17,12 +17,12 @@
* $Id$
*/
package jode;
package jode.decompiler;
import jode.*;
import jode.bytecode.ClassInfo;
import jode.bytecode.ConstantPool;
import jode.bytecode.AttributeInfo;
import jode.bytecode.CodeInfo;
import jode.expr.Opcodes;
import jode.flow.FlowBlock;
import jode.flow.TransformExceptionHandlers;

@ -17,8 +17,9 @@
* $Id$
*/
package jode;
package jode.decompiler;
import java.lang.reflect.Modifier;
import jode.*;
import jode.bytecode.FieldInfo;
import jode.bytecode.AttributeInfo;
import jode.bytecode.ClassFormatException;
@ -69,6 +70,10 @@ public class FieldAnalyzer implements Analyzer {
return fieldName;
}
public Type getType() {
return type;
}
public boolean setInitializer(Expression expr) {
expr.makeInitializer();
if (constant != null)

@ -19,6 +19,8 @@
package jode;
import java.util.*;
import jode.decompiler.TabbedPrintWriter;
import jode.decompiler.ClassAnalyzer;
import jode.bytecode.ClassInfo;
import java.io.IOException;

@ -17,9 +17,11 @@
* $Id$
*/
package jode;
package jode.decompiler;
import java.util.Enumeration;
import java.util.Vector;
import jode.Decompiler;
import jode.Type;
import jode.expr.LocalVarOperator;
/**

@ -17,7 +17,9 @@
* $Id$
*/
package jode;
package jode.decompiler;
import jode.Decompiler;
import jode.Type;
public class LocalVariableRangeList {

@ -17,10 +17,12 @@
* $Id$
*/
package jode;
package jode.decompiler;
import java.io.*;
import jode.Decompiler;
import jode.Type;
import jode.bytecode.AttributeInfo;
import jode.bytecode.ConstantPool;
import java.io.*;
public class LocalVariableTable {
LocalVariableRangeList[] locals;

@ -17,10 +17,11 @@
* $Id$
*/
package jode;
package jode.decompiler;
import jode.bytecode.MethodInfo;
import jode.bytecode.AttributeInfo;
import jode.bytecode.CodeInfo;
import jode.*;
import java.lang.reflect.Modifier;
import java.io.*;
@ -30,6 +31,7 @@ public class MethodAnalyzer implements Analyzer {
CodeAnalyzer code = null;
ClassAnalyzer classAnalyzer;
boolean isConstructor;
boolean isSynthetic;
int modifiers;
String methodName;
MethodType methodType;
@ -44,6 +46,7 @@ public class MethodAnalyzer implements Analyzer {
this.methodName = minfo.getName();
this.isConstructor =
methodName.equals("<init>") || methodName.equals("<clinit>");
this.isSynthetic = (minfo.findAttribute("Synthetic") != null);
AttributeInfo codeattr = minfo.findAttribute("Code");
if (codeattr != null) {
@ -91,6 +94,10 @@ public class MethodAnalyzer implements Analyzer {
return methodType.isStatic();
}
public boolean isSynthetic() {
return isSynthetic;
}
public int getParamCount() {
int count = isStatic() ? 0 : 1;
Type[] paramTypes = methodType.getParameterTypes();
@ -130,7 +137,7 @@ public class MethodAnalyzer implements Analyzer {
if (!isConstructor)
methodType.getReturnType().useType();
if (!Decompiler.immediateOutput) {
if (!Decompiler.immediateOutput || isSynthetic) {
if (Decompiler.isVerbose)
Decompiler.err.print(methodName+": ");
code.analyze();

@ -17,11 +17,10 @@
* $Id$
*/
package jode.expr;
import jode.CodeAnalyzer;
import jode.LocalInfo;
package jode.decompiler;
import jode.Type;
import jode.MethodType;
import jode.expr.*;
import jode.flow.*;
import jode.bytecode.*;
import java.io.*;
@ -56,8 +55,8 @@ public abstract class Opcodes implements jode.bytecode.Opcodes {
};
private static StructuredBlock createNormal(CodeAnalyzer ca,
int addr, int length,
Expression instr)
int addr, int length,
Expression instr)
{
return new InstructionBlock(instr, new Jump(addr+length));
}

@ -17,8 +17,9 @@
* $Id$
*/
package jode;
package jode.decompiler;
import java.io.*;
import jode.Decompiler;
public class TabbedPrintWriter {
boolean atbol;

@ -19,7 +19,7 @@
package jode.expr;
import jode.Type;
import jode.LocalInfo;
import jode.decompiler.LocalInfo;
/**
* This is a pseudo operator, which represents the check against null

@ -19,7 +19,7 @@
package jode.expr;
import jode.Type;
import jode.CodeAnalyzer;
import jode.decompiler.CodeAnalyzer;
public class ClassFieldOperator extends NoArgOperator {
Type classType;

@ -17,7 +17,7 @@
* $Id$
*/
package jode.decompiler;
package jode.expr;
import jode.Type;
import jode.ArrayType;

@ -19,7 +19,7 @@
package jode.expr;
import jode.Type;
import jode.CodeAnalyzer;
import jode.decompiler.CodeAnalyzer;
public class GetFieldOperator extends Operator {
boolean staticFlag;

@ -19,7 +19,7 @@
package jode.expr;
import jode.Type;
import jode.LocalInfo;
import jode.decompiler.LocalInfo;
public class IIncOperator extends NoArgOperator
implements LocalVarOperator, CombineableOperator {

@ -18,7 +18,7 @@
*/
package jode.expr;
import jode.CodeAnalyzer;
import jode.decompiler.CodeAnalyzer;
import jode.MethodType;
import jode.Type;
import jode.bytecode.ClassInfo;

@ -20,7 +20,7 @@
package jode.expr;
import jode.Decompiler;
import jode.Type;
import jode.LocalInfo;
import jode.decompiler.LocalInfo;
public class LocalLoadOperator extends ConstOperator
implements LocalVarOperator {

@ -19,7 +19,7 @@
package jode.expr;
import jode.Type;
import jode.LocalInfo;
import jode.decompiler.LocalInfo;
public class LocalStoreOperator extends StoreInstruction
implements LocalVarOperator {

@ -19,7 +19,7 @@
package jode.expr;
import jode.Type;
import jode.LocalInfo;
import jode.decompiler.LocalInfo;
public interface LocalVarOperator {
public boolean isRead();

@ -19,12 +19,13 @@
package jode.expr;
import jode.Type;
import jode.CodeAnalyzer;
import jode.decompiler.CodeAnalyzer;
public class PutFieldOperator extends StoreInstruction {
CodeAnalyzer codeAnalyzer;
boolean staticFlag;
String fieldName;
Type fieldType;
Type classType;
public PutFieldOperator(CodeAnalyzer codeAnalyzer, boolean staticFlag,
@ -33,6 +34,7 @@ public class PutFieldOperator extends StoreInstruction {
this.codeAnalyzer = codeAnalyzer;
this.staticFlag = staticFlag;
this.fieldName = fieldName;
this.fieldType = type;
this.classType = classType;
if (staticFlag)
classType.useType();
@ -46,6 +48,10 @@ public class PutFieldOperator extends StoreInstruction {
return fieldName;
}
public Type getFieldType() {
return fieldType;
}
public boolean matches(Operator loadop) {
return loadop instanceof GetFieldOperator
&& ((GetFieldOperator)loadop).classType.equals(classType)

@ -16,7 +16,7 @@
* $Id$
*/
package jode.flow;
import jode.TabbedPrintWriter;
import jode.decompiler.TabbedPrintWriter;
/**
*

@ -16,7 +16,7 @@
* $Id$
*/
package jode.flow;
import jode.TabbedPrintWriter;
import jode.decompiler.TabbedPrintWriter;
/**
* This is a structured block, that supports break.

@ -105,7 +105,7 @@ public class CaseBlock extends StructuredBlock {
public void makeDeclaration(VariableSet done) {
java.util.Enumeration enum = allUsed.elements();
while (enum.hasMoreElements()) {
jode.LocalInfo li = (jode.LocalInfo) enum.nextElement();
jode.decompiler.LocalInfo li = (jode.decompiler.LocalInfo) enum.nextElement();
if (!done.contains(li)) {
wantBraces = true;
break;
@ -123,7 +123,7 @@ public class CaseBlock extends StructuredBlock {
: new StructuredBlock[0];
}
public void dumpInstruction(jode.TabbedPrintWriter writer)
public void dumpInstruction(jode.decompiler.TabbedPrintWriter writer)
throws java.io.IOException
{
if (isDefault) {

@ -18,7 +18,7 @@
*/
package jode.flow;
import jode.Type;
import jode.LocalInfo;
import jode.decompiler.LocalInfo;
/**
*
@ -91,7 +91,7 @@ public class CatchBlock extends StructuredBlock {
* @param writer The tabbed print writer, where we print to.
* @param local The local that should be declared.
*/
public void dumpDeclaration(jode.TabbedPrintWriter writer, LocalInfo local)
public void dumpDeclaration(jode.decompiler.TabbedPrintWriter writer, LocalInfo local)
throws java.io.IOException
{
if (local != exceptionLocal) {
@ -102,7 +102,7 @@ public class CatchBlock extends StructuredBlock {
}
}
public void dumpInstruction(jode.TabbedPrintWriter writer)
public void dumpInstruction(jode.decompiler.TabbedPrintWriter writer)
throws java.io.IOException {
writer.closeBraceContinue();
writer.print("catch ("+exceptionType.toString() + " "

@ -16,7 +16,7 @@
* $Id$
*/
package jode.flow;
import jode.TabbedPrintWriter;
import jode.decompiler.TabbedPrintWriter;
import jode.expr.Expression;
import jode.expr.LocalVarOperator;

@ -16,7 +16,7 @@
* $Id$
*/
package jode.flow;
import jode.TabbedPrintWriter;
import jode.decompiler.TabbedPrintWriter;
/**
*

@ -20,7 +20,7 @@
package jode.flow;
import jode.expr.*;
import jode.Type;
import jode.LocalInfo;
import jode.decompiler.LocalInfo;
public class CreateCheckNull {

@ -18,7 +18,7 @@
*/
package jode.flow;
import jode.TabbedPrintWriter;
import jode.decompiler.TabbedPrintWriter;
/**
* This is a block which contains a comment/description of what went

@ -18,7 +18,7 @@
*/
package jode.flow;
import jode.TabbedPrintWriter;
import jode.decompiler.TabbedPrintWriter;
/**
* This is the structured block for an empty block.

@ -44,7 +44,7 @@ public class FinallyBlock extends CatchBlock {
return null;
}
public void dumpInstruction(jode.TabbedPrintWriter writer)
public void dumpInstruction(jode.decompiler.TabbedPrintWriter writer)
throws java.io.IOException {
writer.closeBraceContinue();
writer.print("finally");

@ -19,7 +19,10 @@
package jode.flow;
import java.util.*;
import jode.*;
import jode.Decompiler;
import jode.AssertError;
import jode.decompiler.TabbedPrintWriter;
import jode.decompiler.CodeAnalyzer;
import jode.expr.Expression;
import jode.expr.CombineableOperator;

@ -16,7 +16,7 @@
* $Id$
*/
package jode.flow;
import jode.TabbedPrintWriter;
import jode.decompiler.TabbedPrintWriter;
import jode.expr.Expression;
/**

@ -16,8 +16,8 @@
* $Id$
*/
package jode.flow;
import jode.TabbedPrintWriter;
import jode.LocalInfo;
import jode.decompiler.TabbedPrintWriter;
import jode.decompiler.LocalInfo;
import jode.expr.ComplexExpression;
import jode.expr.Expression;
import jode.expr.LocalStoreOperator;

@ -63,7 +63,7 @@ public class JsrBlock extends StructuredBlock {
return new StructuredBlock[] { innerBlock };
}
public void dumpInstruction(jode.TabbedPrintWriter writer)
public void dumpInstruction(jode.decompiler.TabbedPrintWriter writer)
throws java.io.IOException
{
writer.println("JSR");

@ -85,7 +85,7 @@ public class Jump {
* dumpInstruction afterwards.
* @param writer The tabbed print writer, where we print to.
*/
public void dumpSource(jode.TabbedPrintWriter writer)
public void dumpSource(jode.decompiler.TabbedPrintWriter writer)
throws java.io.IOException
{
if (jode.Decompiler.debugInOut) {

@ -18,9 +18,9 @@
*/
package jode.flow;
import jode.TabbedPrintWriter;
import jode.decompiler.TabbedPrintWriter;
import jode.Type;
import jode.LocalInfo;
import jode.decompiler.LocalInfo;
import jode.expr.Expression;
import jode.expr.ConstOperator;
import jode.expr.LocalStoreOperator;

@ -17,7 +17,7 @@
* $Id$
*/
package jode.flow;
import jode.LocalInfo;
import jode.decompiler.LocalInfo;
/**
* This block represents a ret instruction. A ret instruction is
@ -46,7 +46,7 @@ public class RetBlock extends StructuredBlock {
gen.addElement(local);
}
public void dumpInstruction(jode.TabbedPrintWriter writer)
public void dumpInstruction(jode.decompiler.TabbedPrintWriter writer)
throws java.io.IOException
{
writer.println("RET "+local);

@ -18,7 +18,7 @@
*/
package jode.flow;
import jode.TabbedPrintWriter;
import jode.decompiler.TabbedPrintWriter;
import jode.expr.Expression;
/**

@ -16,7 +16,7 @@
* $Id$
*/
package jode.flow;
import jode.TabbedPrintWriter;
import jode.decompiler.TabbedPrintWriter;
/**
* A sequential block combines exactly two structured blocks to a new

@ -16,7 +16,7 @@
* $Id$
*/
package jode.flow;
import jode.TabbedPrintWriter;
import jode.decompiler.TabbedPrintWriter;
import jode.Decompiler;
import jode.expr.*;

@ -18,9 +18,9 @@
*/
package jode.flow;
import jode.TabbedPrintWriter;
import jode.AssertError;
import jode.LocalInfo;
import jode.decompiler.TabbedPrintWriter;
import jode.decompiler.LocalInfo;
/**
* A structured block is the building block of the source programm.
@ -473,7 +473,7 @@ public abstract class StructuredBlock {
* dumpInstruction afterwards.
* @param writer The tabbed print writer, where we print to.
*/
public void dumpSource(jode.TabbedPrintWriter writer)
public void dumpSource(jode.decompiler.TabbedPrintWriter writer)
throws java.io.IOException
{
if (declare != null) {
@ -499,7 +499,7 @@ public abstract class StructuredBlock {
* @param writer The tabbed print writer, where we print to.
* @param local The local that should be declared.
*/
public void dumpDeclaration(jode.TabbedPrintWriter writer, LocalInfo local)
public void dumpDeclaration(jode.decompiler.TabbedPrintWriter writer, LocalInfo local)
throws java.io.IOException
{
writer.println(local.getType().toString() + " "
@ -516,8 +516,8 @@ public abstract class StructuredBlock {
public String toString() {
try {
java.io.StringWriter strw = new java.io.StringWriter();
jode.TabbedPrintWriter writer =
new jode.TabbedPrintWriter(strw);
jode.decompiler.TabbedPrintWriter writer =
new jode.decompiler.TabbedPrintWriter(strw);
writer.println(super.toString());
writer.tab();
dumpSource(writer);

@ -18,7 +18,7 @@
*/
package jode.flow;
import jode.TabbedPrintWriter;
import jode.decompiler.TabbedPrintWriter;
import jode.expr.Expression;
/**

@ -17,8 +17,8 @@
* $Id$
*/
package jode.flow;
import jode.LocalInfo;
import jode.TabbedPrintWriter;
import jode.decompiler.LocalInfo;
import jode.decompiler.TabbedPrintWriter;
import jode.expr.Expression;
/**

@ -18,7 +18,7 @@
*/
package jode.flow;
import jode.TabbedPrintWriter;
import jode.decompiler.TabbedPrintWriter;
import jode.expr.Expression;
/**

@ -17,7 +17,8 @@
* $Id$
*/
package jode.flow;
import jode.ClassAnalyzer;
import jode.decompiler.ClassAnalyzer;
import jode.decompiler.MethodAnalyzer;
import jode.expr.*;
/**
@ -28,7 +29,7 @@ public class TransformConstructors {
public static void transform(ClassAnalyzer clazzAnalyzer,
boolean isStatic,
jode.MethodAnalyzer[] cons) {
MethodAnalyzer[] cons) {
if (cons.length == 0)
return;
@ -132,7 +133,8 @@ public class TransformConstructors {
}
if (!clazzAnalyzer.setFieldInitializer(pfo.getFieldName(), expr)) {
if (!clazzAnalyzer.setFieldInitializer(pfo.getFieldName(),
pfo.getFieldType(), expr)) {
// Decompiler.err.println("setField failed");
break big_loop;
}

@ -20,7 +20,7 @@ package jode.flow;
import jode.AssertError;
import jode.Decompiler;
import jode.Type;
import jode.LocalInfo;
import jode.decompiler.LocalInfo;
import jode.expr.*;
import java.util.Enumeration;

@ -17,7 +17,7 @@
*/
package jode.flow;
import jode.TabbedPrintWriter;
import jode.decompiler.TabbedPrintWriter;
/**
* A TryBlock is created for each exception in the

@ -16,7 +16,7 @@
* $Id$
*/
package jode.flow;
import jode.LocalInfo;
import jode.decompiler.LocalInfo;
/**
* This class represents a set of Variables, which are mainly used in

@ -67,10 +67,6 @@ public class ClassBundle {
}
}
public void strip() {
basePackage.strip();
}
public void buildTable(int renameRule) {
basePackage.buildTable(renameRule);
}

@ -216,21 +216,10 @@ public class ClassIdentifier extends Identifier {
preserveIdentifier("<init>", null);
}
public void strip() {
willStrip = true;
if (Obfuscator.isDebugging) {
for (int i=0; i < identifiers.length; i++) {
if (!identifiers[i].isReachable())
Obfuscator.err.println(identifiers[i].toString()
+ " is stripped");
}
}
}
public void buildTable(int renameRule) {
super.buildTable(renameRule);
for (int i=0; i < identifiers.length; i++)
if (!willStrip || identifiers[i].isReachable())
if (!Obfuscator.shouldStrip || identifiers[i].isReachable())
identifiers[i].buildTable(renameRule);
}
@ -238,7 +227,7 @@ public class ClassIdentifier extends Identifier {
if (getName() != getAlias())
out.println("" + getFullAlias() + " = " + getName());
for (int i=0; i < identifiers.length; i++)
if (!willStrip || identifiers[i].isReachable())
if (!Obfuscator.shouldStrip || identifiers[i].isReachable())
identifiers[i].writeTable(out);
}
@ -295,7 +284,7 @@ public class ClassIdentifier extends Identifier {
GrowableConstantPool gcp = new GrowableConstantPool();
for (int i=fieldCount; i < identifiers.length; i++)
if (!willStrip || identifiers[i].isReachable())
if (!Obfuscator.shouldStrip || identifiers[i].isReachable())
((MethodIdentifier)identifiers[i]).reserveSmallConstants(gcp);
int[] hierarchyInts;
@ -316,13 +305,13 @@ public class ClassIdentifier extends Identifier {
int methods = 0;
for (int i=0; i<fieldCount; i++) {
if (!willStrip || identifiers[i].isReachable()) {
if (!Obfuscator.shouldStrip || identifiers[i].isReachable()) {
((FieldIdentifier)identifiers[i]).fillConstantPool(gcp);
fields++;
}
}
for (int i=fieldCount; i < identifiers.length; i++) {
if (!willStrip || identifiers[i].isReachable()) {
if (!Obfuscator.shouldStrip || identifiers[i].isReachable()) {
((MethodIdentifier)identifiers[i]).fillConstantPool(gcp);
methods++;
}
@ -341,13 +330,22 @@ public class ClassIdentifier extends Identifier {
out.writeShort(hierarchyInts[i]);
out.writeShort(fields);
for (int i=0; i<fieldCount; i++)
if (!willStrip || identifiers[i].isReachable())
for (int i=0; i<fieldCount; i++) {
if (!Obfuscator.shouldStrip || identifiers[i].isReachable())
((FieldIdentifier)identifiers[i]).write(out);
else if (Obfuscator.isDebugging)
Obfuscator.err.println(identifiers[i].toString()
+ " is stripped");
}
out.writeShort(methods);
for (int i=fieldCount; i < identifiers.length; i++)
if (!willStrip || identifiers[i].isReachable())
for (int i=fieldCount; i < identifiers.length; i++) {
if (!Obfuscator.shouldStrip || identifiers[i].isReachable())
((MethodIdentifier)identifiers[i]).write(out);
else if (Obfuscator.isDebugging)
Obfuscator.err.println(identifiers[i].toString()
+ " is stripped");
}
out.writeShort(0); // no attributes;
}
@ -439,7 +437,7 @@ public class ClassIdentifier extends Identifier {
public boolean containFieldAlias(String fieldName, String typeSig) {
for (int i=0; i < fieldCount; i++) {
if ((!willStrip || identifiers[i].isReachable())
if ((!Obfuscator.shouldStrip || identifiers[i].isReachable())
&& identifiers[i].getAlias().equals(fieldName)
&& identifiers[i].getType().startsWith(typeSig))
return true;
@ -501,7 +499,7 @@ public class ClassIdentifier extends Identifier {
public Object getMethod(String methodName, String paramType) {
for (int i=fieldCount; i< identifiers.length; i++) {
if ((!willStrip || identifiers[i].isReachable())
if ((!Obfuscator.shouldStrip || identifiers[i].isReachable())
&& identifiers[i].getAlias().equals(methodName)
&& identifiers[i].getType().startsWith(paramType))
return identifiers[i];
@ -539,7 +537,7 @@ public class ClassIdentifier extends Identifier {
return null;
}
public boolean conflicting(String newAlias) {
public boolean conflicting(String newAlias, boolean strong) {
return pack.contains(newAlias);
}
}

@ -65,9 +65,12 @@ public class FieldIdentifier extends Identifier{
return "MethodIdentifier "+getFullName()+"."+getType();
}
public boolean conflicting(String newAlias) {
return clazz.containFieldAlias(newAlias, "")
|| (clazz.getMethod(newAlias, "") != null);
public boolean conflicting(String newAlias, boolean strong) {
if (strong) {
return clazz.containFieldAlias(newAlias, getType());
} else {
return clazz.containFieldAlias(newAlias, "");
}
}
int nameIndex;

@ -194,7 +194,9 @@ public abstract class Identifier {
} while (false);
Identifier ptr = this;
while (ptr != null) {
if (ptr.conflicting(newAlias.toString()))
if (ptr.conflicting(newAlias.toString(),
renameRule
== Obfuscator.RENAME_STRONG))
continue next_alias;
ptr = ptr.right;
}
@ -215,5 +217,5 @@ public abstract class Identifier {
public abstract String getType();
public abstract String getFullName();
public abstract String getFullAlias();
public abstract boolean conflicting(String newAlias);
public abstract boolean conflicting(String newAlias, boolean strong);
}

@ -27,6 +27,8 @@ public class Obfuscator {
public static boolean isVerbose = false;
public static boolean isDebugging = false;
public static boolean shouldStrip = true;
public static PrintStream err = System.err;
public static final int PRESERVE_NONE = 0;
public static final int PRESERVE_PUBLIC = Modifier.PUBLIC;
@ -83,7 +85,6 @@ public class Obfuscator {
Vector preservedIdents = new Vector();
boolean strip = true;
int preserveRule = PRESERVE_NONE;
int rename = RENAME_WEAK;
String table = null;
@ -95,7 +96,7 @@ public class Obfuscator {
else if (params[i].equals("-debug"))
isDebugging = true;
else if (params[i].equals("-nostrip"))
strip = false;
shouldStrip = false;
else if (params[i].equals("-sourcepath"))
sourcePath = params[++i];
@ -157,9 +158,6 @@ public class Obfuscator {
bundle.setPreserved(preserveRule, preservedIdents);
err.println("Renaming methods");
if (strip)
bundle.strip();
if (rename != RENAME_TABLE)
bundle.buildTable(rename);
else

@ -258,11 +258,14 @@ public class MethodIdentifier extends Identifier implements Opcodes {
return info.getType().getTypeSignature();
}
public boolean conflicting(String newAlias) {
String type = getType();
String paramType = type.substring(0, type.indexOf(')')+1);
return clazz.getMethod(newAlias, paramType) != null
|| clazz.containFieldAlias(newAlias, "");
public boolean conflicting(String newAlias, boolean strong) {
if (strong) {
return clazz.getMethod(newAlias, getType()) != null;
} else {
String type = getType();
String paramType = type.substring(0, type.indexOf(')')+1);
return clazz.getMethod(newAlias, paramType) != null;
}
}
public String toString() {

@ -31,7 +31,6 @@ public class PackageIdentifier extends Identifier {
PackageIdentifier parent;
String name;
boolean willStrip = false;
boolean loadOnDemand;
Hashtable loadedClasses;
@ -211,25 +210,6 @@ public class PackageIdentifier extends Identifier {
return className;
}
public void strip() {
willStrip = true;
Enumeration enum = loadedClasses.elements();
while (enum.hasMoreElements()) {
Identifier ident = (Identifier) enum.nextElement();
if (ident.isReachable()) {
if (ident instanceof ClassIdentifier) {
((ClassIdentifier) ident).strip();
} else
((PackageIdentifier) ident).strip();
} else {
if (Obfuscator.isDebugging)
Obfuscator.err.println("Class/Package "
+ ident.getFullName()
+ " is not reachable");
}
}
}
public void buildTable(int renameRule) {
super.buildTable(renameRule);
Enumeration enum = loadedClasses.elements();
@ -249,7 +229,7 @@ public class PackageIdentifier extends Identifier {
Enumeration enum = loadedClasses.elements();
while (enum.hasMoreElements()) {
Identifier ident = (Identifier) enum.nextElement();
if (!willStrip || ident.isReachable())
if (!Obfuscator.shouldStrip || ident.isReachable())
ident.writeTable(out);
}
}
@ -276,8 +256,13 @@ public class PackageIdentifier extends Identifier {
Enumeration enum = loadedClasses.elements();
while (enum.hasMoreElements()) {
Identifier ident = (Identifier) enum.nextElement();
if (willStrip && !ident.isReachable())
if (Obfuscator.shouldStrip && !ident.isReachable()) {
if (Obfuscator.isDebugging)
Obfuscator.err.println("Class/Package "
+ ident.getFullName()
+ " is not reachable");
continue;
}
if (ident instanceof PackageIdentifier)
((PackageIdentifier) ident)
.storeClasses(newDest);
@ -309,13 +294,15 @@ public class PackageIdentifier extends Identifier {
public boolean contains(String newAlias) {
Enumeration enum = loadedClasses.elements();
while (enum.hasMoreElements()) {
if (((Identifier)enum.nextElement()).getAlias().equals(newAlias))
Identifier ident = (Identifier)enum.nextElement();
if ((!Obfuscator.shouldStrip || ident.isReachable())
&& ident.getAlias().equals(newAlias))
return true;
}
return false;
}
public boolean conflicting(String newAlias) {
public boolean conflicting(String newAlias, boolean strong) {
return parent.contains(newAlias);
}
}

Loading…
Cancel
Save