* build.xml: replace execon with apply.

* src/net/sf/jode/bytecode/ClassInfo.java (readAttributes):
read in signature attribute (not yet published, though).
* src/net/sf/jode/bytecode/MethodInfo.java (readAttributes):
likewise.
* src/net/sf/jode/bytecode/FieldInfo.java (readAttributes):
likewise.
* src/net/sf/jode/bytecode/ClassInfo.java (mergeModifiers):
only check the traditional modifiers for equality.
* src/net/sf/jode/bytecode/ConstantPool.java (getConstant):
Support for CLASS constants (jdk1.5) added.
* src/net/sf/jode/bytecode/BasicBlockReader.java (readCode):
opc_ldc, opc_ldc_w: Support for CLASS constants added.
* src/net/sf/jode/decompiler/Opcodes.java (addOpcode):
likewise.
* src/net/sf/jode/expr/InvokeOperator.java
(simplifyStringBuffer, simplifyString):
Also handle StringBuilder (jdk1.5).
* src/net/sf/jode/type/Type.java (tStringBuilder): new field.
* src/net/sf/jode/swingui/Main.java (main): handle debug
options.


git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@1381 379699f6-c40d-0410-875b-85095c16579e
master
hoenicke 20 years ago
parent ae5ffbf3f8
commit ec129979e1
  1. 25
      jode/ChangeLog
  2. 8
      jode/build.xml
  3. 4
      jode/src/net/sf/jode/bytecode/BasicBlockReader.java
  4. 20
      jode/src/net/sf/jode/bytecode/ClassInfo.java
  5. 13
      jode/src/net/sf/jode/bytecode/ConstantPool.java
  6. 6
      jode/src/net/sf/jode/bytecode/FieldInfo.java
  7. 6
      jode/src/net/sf/jode/bytecode/MethodInfo.java
  8. 14
      jode/src/net/sf/jode/decompiler/Opcodes.java
  9. 8
      jode/src/net/sf/jode/expr/InvokeOperator.java
  10. 6
      jode/src/net/sf/jode/swingui/Main.java
  11. 8
      jode/src/net/sf/jode/type/Type.java

@ -1,3 +1,28 @@
2004-08-05 Jochen Hoenicke <hoenicke@marge.Informatik.Uni-Oldenburg.DE>
* build.xml: replace execon with apply.
* src/net/sf/jode/bytecode/ClassInfo.java (readAttributes):
read in signature attribute (not yet published, though).
* src/net/sf/jode/bytecode/MethodInfo.java (readAttributes):
likewise.
* src/net/sf/jode/bytecode/FieldInfo.java (readAttributes):
likewise.
* src/net/sf/jode/bytecode/ClassInfo.java (mergeModifiers):
only check the traditional modifiers for equality.
* src/net/sf/jode/bytecode/ConstantPool.java (getConstant):
Support for CLASS constants (jdk1.5) added.
* src/net/sf/jode/bytecode/BasicBlockReader.java (readCode):
opc_ldc, opc_ldc_w: Support for CLASS constants added.
* src/net/sf/jode/decompiler/Opcodes.java (addOpcode):
likewise.
* src/net/sf/jode/expr/InvokeOperator.java
(simplifyStringBuffer, simplifyString):
Also handle StringBuilder (jdk1.5).
* src/net/sf/jode/type/Type.java (tStringBuilder): new field.
* src/net/sf/jode/swingui/Main.java (main): handle debug
options.
2004-01-31 Jochen Hoenicke <hoenicke@informatik.uni-oldenburg.de> 2004-01-31 Jochen Hoenicke <hoenicke@informatik.uni-oldenburg.de>
* src/net/sf/jode/jvm/SyntheticAnalyzer.java (checkGetClass): * src/net/sf/jode/jvm/SyntheticAnalyzer.java (checkGetClass):

@ -67,25 +67,25 @@
</target> </target>
<target name="run-jcpp" depends="check-packages,check-jcpp"> <target name="run-jcpp" depends="check-packages,check-jcpp">
<execon dir="." executable="perl" parallel="true"> <apply dir="." executable="perl" parallel="true">
<arg file="${jcpp}"/> <arg file="${jcpp}"/>
<arg value="-DJDK11"/> <arg value="-DJDK11"/>
<arg value="-DCOLLECTIONS=${collections.package}"/> <arg value="-DCOLLECTIONS=${collections.package}"/>
<arg value="-DCOLLECTIONEXTRA=${collections.package}"/> <arg value="-DCOLLECTIONEXTRA=${collections.package}"/>
<arg value="-DJAVAX_SWING=${swing.package}"/> <arg value="-DJAVAX_SWING=${swing.package}"/>
<fileset dir="${src}" includes="**/*.java"/> <fileset dir="${src}" includes="**/*.java"/>
</execon> </apply>
</target> </target>
<target name="clean-jcpp" if="perl.present"> <target name="clean-jcpp" if="perl.present">
<execon dir="." executable="perl" parallel="true"> <apply dir="." executable="perl" parallel="true">
<arg file="${jcpp}"/> <arg file="${jcpp}"/>
<arg value="-DJDK12"/> <arg value="-DJDK12"/>
<arg value="-DCOLLECTIONS=java.util"/> <arg value="-DCOLLECTIONS=java.util"/>
<arg value="-DCOLLECTIONEXTRA=java.lang"/> <arg value="-DCOLLECTIONEXTRA=java.lang"/>
<arg value="-DJAVAX_SWING=javax.swing"/> <arg value="-DJAVAX_SWING=javax.swing"/>
<fileset dir="${src}" includes="**/*.java"/> <fileset dir="${src}" includes="**/*.java"/>
</execon> </apply>
</target> </target>
<!-- ********* Check Environment ******* --> <!-- ********* Check Environment ******* -->

@ -544,7 +544,7 @@ class BasicBlockReader implements Opcodes {
case opc_ldc: { case opc_ldc: {
int index = input.readUnsignedByte(); int index = input.readUnsignedByte();
int tag = cp.getTag(index); int tag = cp.getTag(index);
if (tag != cp.STRING if (tag != cp.STRING && tag != cp.CLASS
&& tag != cp.INTEGER && tag != cp.FLOAT) && tag != cp.INTEGER && tag != cp.FLOAT)
throw new ClassFormatException throw new ClassFormatException
("wrong constant tag: "+tag); ("wrong constant tag: "+tag);
@ -556,7 +556,7 @@ class BasicBlockReader implements Opcodes {
case opc_ldc_w: { case opc_ldc_w: {
int index = input.readUnsignedShort(); int index = input.readUnsignedShort();
int tag = cp.getTag(index); int tag = cp.getTag(index);
if (tag != cp.STRING if (tag != cp.STRING && tag != cp.CLASS
&& tag != cp.INTEGER && tag != cp.FLOAT) && tag != cp.INTEGER && tag != cp.FLOAT)
throw new ClassFormatException throw new ClassFormatException
("wrong constant tag: "+tag); ("wrong constant tag: "+tag);

@ -252,6 +252,11 @@ public final class ClassInfo extends BinaryInfo implements Comparable {
private MethodInfo[] methods; private MethodInfo[] methods;
private String sourceFile; private String sourceFile;
private boolean hasInnerClassesAttr; private boolean hasInnerClassesAttr;
/**
* The type signature that also contains template information.
*/
private String signature;
private final static ClassInfo[] EMPTY_INNER = new ClassInfo[0]; private final static ClassInfo[] EMPTY_INNER = new ClassInfo[0];
@ -394,7 +399,8 @@ public final class ClassInfo extends BinaryInfo implements Comparable {
/****** READING CLASS FILES ***************************************/ /****** READING CLASS FILES ***************************************/
private static int javaModifiersToBytecode(int javaModifiers) { private static int javaModifiersToBytecode(int javaModifiers)
{
int modifiers = javaModifiers & (Modifier.FINAL int modifiers = javaModifiers & (Modifier.FINAL
| 0x20 /*ACC_SUPER*/ | 0x20 /*ACC_SUPER*/
| Modifier.INTERFACE | Modifier.INTERFACE
@ -406,7 +412,9 @@ public final class ClassInfo extends BinaryInfo implements Comparable {
return modifiers; return modifiers;
} }
private void mergeModifiers(int newModifiers) { private void mergeModifiers(int newModifiers)
throws ClassFormatException
{
if (modifiers == -1) { if (modifiers == -1) {
modifiers = newModifiers; modifiers = newModifiers;
return; return;
@ -417,18 +425,18 @@ public final class ClassInfo extends BinaryInfo implements Comparable {
} }
int oldSimple = javaModifiersToBytecode(modifiers); int oldSimple = javaModifiersToBytecode(modifiers);
if (((oldSimple ^ newModifiers) & ~0x20) == 0) { if (((oldSimple ^ newModifiers) & 0xfdf) == 0) {
modifiers |= newModifiers & 0x20; modifiers |= newModifiers & 0x20;
return; return;
} }
int newSimple = javaModifiersToBytecode(newModifiers); int newSimple = javaModifiersToBytecode(newModifiers);
if (((newSimple ^ modifiers) & ~0x20) == 0) { if (((newSimple ^ modifiers) & 0xfdf) == 0) {
modifiers = newModifiers | (modifiers & 0x20); modifiers = newModifiers | (modifiers & 0x20);
return; return;
} }
throw new ClassFormatError throw new ClassFormatException
("modifiers in InnerClass info doesn't match: " ("modifiers in InnerClass info doesn't match: "
+ modifiers + "<->" + newModifiers); + modifiers + "<->" + newModifiers);
} }
@ -566,6 +574,8 @@ public final class ClassInfo extends BinaryInfo implements Comparable {
if (length != 0) if (length != 0)
throw new ClassFormatException throw new ClassFormatException
("Deprecated attribute has wrong length"); ("Deprecated attribute has wrong length");
} else if (name.equals("Signature")) {
signature = cp.getUTF8(input.readUnsignedShort());
} else } else
super.readAttribute(name, length, cp, input, howMuch); super.readAttribute(name, length, cp, input, howMuch);
} }

@ -151,12 +151,15 @@ public class ConstantPool {
if (i == 0) if (i == 0)
throw new ClassFormatException("null constant"); throw new ClassFormatException("null constant");
switch (tags[i]) { switch (tags[i]) {
case ConstantPool.INTEGER: case INTEGER:
case ConstantPool.FLOAT: case FLOAT:
case ConstantPool.LONG: case LONG:
case ConstantPool.DOUBLE: case DOUBLE:
return constants[i]; return constants[i];
case ConstantPool.STRING: case CLASS:
return Reference.getReference(getClassType(i),
"class", "Ljava/lang/Class;");
case STRING:
return getUTF8(indices1[i]); return getUTF8(indices1[i]);
} }
throw new ClassFormatException("Tag mismatch: "+tags[i]); throw new ClassFormatException("Tag mismatch: "+tags[i]);

@ -67,6 +67,10 @@ public final class FieldInfo extends BinaryInfo implements Comparable {
Object constant; Object constant;
boolean syntheticFlag; boolean syntheticFlag;
boolean deprecatedFlag; boolean deprecatedFlag;
/**
* The type signature that also contains template information.
*/
private String signature;
/** /**
* Creates a new empty field info. * Creates a new empty field info.
@ -109,6 +113,8 @@ public final class FieldInfo extends BinaryInfo implements Comparable {
if (length != 0) if (length != 0)
throw new ClassFormatException throw new ClassFormatException
("Deprecated attribute has wrong length"); ("Deprecated attribute has wrong length");
} else if (name.equals("Signature")) {
signature = cp.getUTF8(input.readUnsignedShort());
} else } else
super.readAttribute(name, length, cp, input, howMuch); super.readAttribute(name, length, cp, input, howMuch);
} }

@ -71,6 +71,10 @@ public final class MethodInfo extends BinaryInfo implements Comparable {
String[] exceptions; String[] exceptions;
boolean syntheticFlag; boolean syntheticFlag;
boolean deprecatedFlag; boolean deprecatedFlag;
/**
* The type signature that also contains template information.
*/
private String signature;
public MethodInfo() { public MethodInfo() {
} }
@ -106,6 +110,8 @@ public final class MethodInfo extends BinaryInfo implements Comparable {
if (length != 0) if (length != 0)
throw new ClassFormatException throw new ClassFormatException
("Deprecated attribute has wrong length"); ("Deprecated attribute has wrong length");
} else if (name.equals("Signature")) {
signature = cp.getUTF8(input.readUnsignedShort());
} else } else
super.readAttribute(name, length, cp, input, howMuch); super.readAttribute(name, length, cp, input, howMuch);
} }

@ -147,9 +147,17 @@ public abstract class Opcodes implements net.sf.jode.bytecode.Opcodes {
break; break;
case opc_ldc: case opc_ldc:
case opc_ldc2_w: case opc_ldc2_w:
flow.appendBlock {
(createNormal(ma, instr, Expression expr;
new ConstOperator(instr.getConstant()))); if (instr.getConstant() instanceof Reference) {
Reference ref = (Reference) instr.getConstant();
expr = new ClassFieldOperator
(Type.tType(cp, ref.getClazz()));
} else {
expr = new ConstOperator(instr.getConstant());
}
flow.appendBlock(createNormal(ma, instr, expr));
}
break; break;
case opc_iload: case opc_lload: case opc_iload: case opc_lload:
case opc_fload: case opc_dload: case opc_aload: { case opc_fload: case opc_dload: case opc_aload: {

@ -517,7 +517,8 @@ public final class InvokeOperator extends Operator
} }
public Expression simplifyStringBuffer() { public Expression simplifyStringBuffer() {
if (getClassType().equals(Type.tStringBuffer)) { if (getClassType().equals(Type.tStringBuffer)
|| getClassType().equals(Type.tStringBuilder)) {
if (isConstructor() if (isConstructor()
&& subExpressions[0] instanceof NewOperator) { && subExpressions[0] instanceof NewOperator) {
if (methodType.getParameterTypes().length == 0) if (methodType.getParameterTypes().length == 0)
@ -548,7 +549,7 @@ public final class InvokeOperator extends Operator
Expression secondOp = subExpressions[1]; Expression secondOp = subExpressions[1];
Type[] paramTypes = new Type[] { Type[] paramTypes = new Type[] {
Type.tStringBuffer, secondOp.getType().getCanonic() getClassType(), secondOp.getType().getCanonic()
}; };
if (needsCast(1, paramTypes)) { if (needsCast(1, paramTypes)) {
Type castType = methodType.getParameterTypes()[0]; Type castType = methodType.getParameterTypes()[0];
@ -568,7 +569,8 @@ public final class InvokeOperator extends Operator
public Expression simplifyString() { public Expression simplifyString() {
if (getMethodName().equals("toString") if (getMethodName().equals("toString")
&& !isStatic() && !isStatic()
&& getClassType().equals(Type.tStringBuffer) && (getClassType().equals(Type.tStringBuffer)
|| getClassType().equals(Type.tStringBuilder))
&& subExpressions.length == 1) { && subExpressions.length == 1) {
Expression simple = subExpressions[0].simplifyStringBuffer(); Expression simple = subExpressions[0].simplifyStringBuffer();
if (simple != null) if (simple != null)

@ -436,7 +436,11 @@ public class Main
|| params[i].equals("--cp") || params[i].equals("--cp")
|| params[i].equals("-c")) || params[i].equals("-c"))
cp = params[++i]; cp = params[++i];
else if (params[i].startsWith("-")) { else if (params[i].equals("--debug")
|| params[i].equals("--D")) {
String arg = params[++i];
GlobalOptions.setDebugging(arg);
} else if (params[i].startsWith("-")) {
if (!params[i].equals("--help") if (!params[i].equals("--help")
&& !params[i].equals("-h")) && !params[i].equals("-h"))
System.err.println("Unknown option: "+params[i]); System.err.println("Unknown option: "+params[i]);

@ -192,6 +192,14 @@ public class Type {
tSystemClass("java.lang.StringBuffer", tSystemClass("java.lang.StringBuffer",
tObject, new ClassType[] { tSerializable }, tObject, new ClassType[] { tSerializable },
true, false); true, false);
/**
* This type represents the singleton set containing
* <code>java.lang.StringBuffer</code>.
*/
public static final SystemClassType tStringBuilder =
tSystemClass("java.lang.StringBuilder",
tObject, new ClassType[] { tSerializable },
true, false);
/** /**
* This type represents the singleton set containing * This type represents the singleton set containing
* <code>java.lang.Class</code>. * <code>java.lang.Class</code>.

Loading…
Cancel
Save