diff --git a/jode/jode/bytecode/Opcodes.java b/jode/jode/bytecode/Opcodes.java index 1a629e9..aed1709 100644 --- a/jode/jode/bytecode/Opcodes.java +++ b/jode/jode/bytecode/Opcodes.java @@ -20,8 +20,7 @@ package jode; import jode.flow.*; import java.io.*; -import gnu.bytecode.CpoolRef; -import gnu.bytecode.CpoolClass; +import jode.bytecode.ConstantPool; /** * This is an abstract class which creates flow blocks for the @@ -447,7 +446,8 @@ public abstract class Opcodes { * @exception IOException if an read error occured. * @exception ClassFormatError if an invalid opcode is detected. */ - public static StructuredBlock readOpcode(int addr, DataInputStream stream, + public static StructuredBlock readOpcode(ConstantPool cpool, + int addr, DataInputStream stream, CodeAnalyzer ca) throws IOException, ClassFormatError { @@ -499,16 +499,16 @@ public abstract class Opcodes { int index = stream.readUnsignedByte(); return createNormal (ca, addr, 2, new ConstOperator - (ca.method.classAnalyzer.getConstantType(index), - ca.method.classAnalyzer.getConstantString(index))); + (cpool.getConstantType(index), + cpool.getConstantString(index))); } case opc_ldc_w: case opc_ldc2_w: { int index = stream.readUnsignedShort(); return createNormal (ca, addr, 3, new ConstOperator - (ca.method.classAnalyzer.getConstantType(index), - ca.method.classAnalyzer.getConstantString(index))); + (cpool.getConstantType(index), + cpool.getConstantString(index))); } case opc_iload: case opc_lload: case opc_fload: case opc_dload: case opc_aload: @@ -719,63 +719,41 @@ public abstract class Opcodes { (ca, addr, 1, new EmptyBlock(new Jump(-1))); case opc_getstatic: case opc_getfield: { - CpoolRef field = (CpoolRef)ca.method.classAnalyzer - .getConstant(stream.readUnsignedShort()); + String[] ref = cpool.getRef(stream.readUnsignedShort()); return createNormal (ca, addr, 3, new GetFieldOperator (ca, opcode == opc_getstatic, - Type.tClass(field.getCpoolClass().getName().getString()), - Type.tType(field.getNameAndType().getType().getString()), - field.getNameAndType().getName().getString())); + Type.tClass(ref[0]), Type.tType(ref[2]), ref[1])); } case opc_putstatic: case opc_putfield: { - CpoolRef field = (CpoolRef)ca.method.classAnalyzer - .getConstant(stream.readUnsignedShort()); + String[] ref = cpool.getRef(stream.readUnsignedShort()); return createNormal (ca, addr, 3, new PutFieldOperator (ca, opcode == opc_putstatic, - Type.tClass(field.getCpoolClass().getName().getString()), - Type.tType(field.getNameAndType().getType().getString()), - field.getNameAndType().getName().getString())); + Type.tClass(ref[0]), Type.tType(ref[2]), ref[1])); } case opc_invokevirtual: case opc_invokespecial: - case opc_invokestatic : { - CpoolRef field = (CpoolRef)ca.method.classAnalyzer - .getConstant(stream.readUnsignedShort()); - return createNormal - (ca, addr, 3, new InvokeOperator - (ca, opcode == opc_invokespecial, - Type.tClass(field.getCpoolClass() - .getName().getString()), - new MethodType(opcode == opc_invokestatic, - field.getNameAndType() - .getType().getString()), - field.getNameAndType().getName().getString())); - } + case opc_invokestatic : case opc_invokeinterface: { - CpoolRef field = (CpoolRef)ca.method.classAnalyzer.getConstant - (stream.readUnsignedShort()); - + String[] ref = cpool.getRef(stream.readUnsignedShort()); StructuredBlock block = createNormal - (ca, addr, 5, new InvokeOperator - (ca, false, - Type.tClass(field.getCpoolClass() - .getName().getString()), - new MethodType(false, field.getNameAndType() - .getType().getString()), - field.getNameAndType().getName().getString())); - int reserved = stream.readUnsignedShort(); + (ca, addr, opcode == opc_invokeinterface ? 5 : 3, + new InvokeOperator + (ca, opcode == opc_invokespecial, + Type.tClass(ref[0]), + new MethodType(opcode == opc_invokestatic, ref[2]), + ref[1])); + if (opcode == opc_invokeinterface) + stream.readUnsignedShort(); return block; } case opc_new: { - CpoolClass cpcls = (CpoolClass) - ca.method.classAnalyzer.getConstant(stream.readUnsignedShort()); - Type type = Type.tClassOrArray(cpcls.getName().getString()); + Type type = Type.tClassOrArray + (cpool.getClassName(stream.readUnsignedShort())); type.useType(); - return createNormal - (ca, addr, 3, new NewOperator(type)); + return createNormal(ca, addr, 3, new NewOperator(type)); } case opc_newarray: { Type type; @@ -796,10 +774,8 @@ public abstract class Opcodes { (ca, addr, 2, new NewArrayOperator(Type.tArray(type), 1)); } case opc_anewarray: { - CpoolClass cpcls = (CpoolClass) - ca.method.classAnalyzer.getConstant - (stream.readUnsignedShort()); - Type type = Type.tClassOrArray(cpcls.getName().getString()); + Type type = Type.tClassOrArray + (cpool.getClassName(stream.readUnsignedShort())); type.useType(); return createNormal (ca, addr, 3, new NewArrayOperator(Type.tArray(type), 1)); @@ -813,19 +789,15 @@ public abstract class Opcodes { new ThrowBlock(new NopOperator(Type.tUObject), new Jump(-1))); case opc_checkcast: { - CpoolClass cpcls = (CpoolClass) - ca.method.classAnalyzer.getConstant - (stream.readUnsignedShort()); - Type type = Type.tClassOrArray(cpcls.getName().getString()); + Type type = Type.tClassOrArray + (cpool.getClassName(stream.readUnsignedShort())); type.useType(); return createNormal (ca, addr, 3, new CheckCastOperator(type)); } case opc_instanceof: { - CpoolClass cpcls = (CpoolClass) - ca.method.classAnalyzer.getConstant - (stream.readUnsignedShort()); - Type type = Type.tClassOrArray(cpcls.getName().getString()); + Type type = Type.tClassOrArray + (cpool.getClassName(stream.readUnsignedShort())); type.useType(); return createNormal (ca, addr, 3, new InstanceOfOperator(type)); @@ -877,10 +849,8 @@ public abstract class Opcodes { } } case opc_multianewarray: { - CpoolClass cpcls = (CpoolClass) - ca.method.classAnalyzer.getConstant - (stream.readUnsignedShort()); - Type type = Type.tClassOrArray(cpcls.getName().getString()); + Type type = Type.tClassOrArray + (cpool.getClassName(stream.readUnsignedShort())); int dimension = stream.readUnsignedByte(); return createNormal (ca, addr, 4, diff --git a/jode/jode/decompiler/ClassAnalyzer.java b/jode/jode/decompiler/ClassAnalyzer.java index b4bdc43..33610f0 100644 --- a/jode/jode/decompiler/ClassAnalyzer.java +++ b/jode/jode/decompiler/ClassAnalyzer.java @@ -18,32 +18,31 @@ */ package jode; -import java.lang.reflect.Modifier; -import gnu.bytecode.ConstantPool; -import gnu.bytecode.CpoolEntry; -import gnu.bytecode.CpoolValue1; -import gnu.bytecode.CpoolValue2; -import gnu.bytecode.CpoolString; -import jode.bytecode.ClassHierarchy; +import jode.bytecode.ClassInfo; +import jode.bytecode.FieldInfo; +import jode.bytecode.MethodInfo; +import jode.bytecode.ConstantPool; +import jode.bytecode.ClassFormatException; import jode.flow.TransformConstructors; +import java.lang.reflect.Modifier; + public class ClassAnalyzer implements Analyzer { JodeEnvironment env; Analyzer[] analyzers; MethodAnalyzer staticConstructor; MethodAnalyzer[] constructors; - ClassHierarchy clazz; - gnu.bytecode.ClassType classType; + ClassInfo clazz; ClassAnalyzer parent; - public ClassAnalyzer(ClassAnalyzer parent, ClassHierarchy clazz, + public ClassAnalyzer(ClassAnalyzer parent, ClassInfo clazz, JodeEnvironment env) { + clazz.loadInfo(clazz.FULLINFO); this.parent = parent; this.clazz = clazz; this.env = env; - this.classType = env.getClassType(clazz.getName()); } public boolean setFieldInitializer(String fieldName, Expression expr) { @@ -57,7 +56,7 @@ public class ClassAnalyzer implements Analyzer { return false; } - public ClassHierarchy getClazz() { + public ClassInfo getClazz() { return clazz; } @@ -65,19 +64,27 @@ public class ClassAnalyzer implements Analyzer { int numFields = 0; int i = 0; - analyzers = new Analyzer[classType.getFieldCount() + - classType.getMethodCount()]; - for (gnu.bytecode.Field field = classType.getFields(); - field != null; field = field.getNext()) { - analyzers[i] = new FieldAnalyzer(this, field, env); + FieldInfo[] fields = clazz.getFields(); + MethodInfo[] methods = clazz.getMethods(); + if (fields == 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(); } staticConstructor = null; java.util.Vector constrVector = new java.util.Vector(); - for (gnu.bytecode.Method method = classType.getMethods(); - method != null; method = method.getNext()) { - MethodAnalyzer analyzer = new MethodAnalyzer(this, method, env); + for (int j=0; j < methods.length; j++) { + MethodAnalyzer analyzer = + new MethodAnalyzer(this, methods[j], env); analyzers[i++] = analyzer; if (analyzer.isConstructor()) { @@ -100,31 +107,33 @@ public class ClassAnalyzer implements Analyzer { env.useClass(clazz.getName()); if (clazz.getSuperclass() != null) env.useClass(clazz.getSuperclass().getName()); - ClassHierarchy[] interfaces = clazz.getInterfaces(); + ClassInfo[] interfaces = clazz.getInterfaces(); for (int j=0; j< interfaces.length; j++) env.useClass(interfaces[j].getName()); } public void dumpSource(TabbedPrintWriter writer) throws java.io.IOException { -// if (cdef.getSource() != null) -// writer.println("/* Original source: "+cdef.getSource()+" */"); - + if (analyzers == null) { + /* This means that the class could not be loaded. + * give up. + */ + return; + } String modif = Modifier.toString(clazz.getModifiers() & ~Modifier.SYNCHRONIZED); if (modif.length() > 0) writer.print(modif + " "); writer.print(clazz.isInterface() - ? ""/*interface is in modif*/ - : "class "); + ? ""/*interface is in modif*/ : "class "); writer.println(env.classString(clazz.getName())); writer.tab(); - ClassHierarchy superClazz = clazz.getSuperclass(); + ClassInfo superClazz = clazz.getSuperclass(); if (superClazz != null && - superClazz != ClassHierarchy.javaLangObject) { + superClazz != ClassInfo.javaLangObject) { writer.println("extends "+env.classString(superClazz.getName())); } - ClassHierarchy[] interfaces = clazz.getInterfaces(); + ClassInfo[] interfaces = clazz.getInterfaces(); if (interfaces.length > 0) { writer.print(clazz.isInterface() ? "extends " : "implements "); for (int i=0; i < interfaces.length; i++) { @@ -144,91 +153,8 @@ public class ClassAnalyzer implements Analyzer { writer.println("}"); } - public CpoolEntry getConstant(int i) { - return classType.getConstant(i); - } - - public Type getConstantType(int i) - throws ClassFormatError - { - CpoolEntry constant = getConstant(i); - switch(constant.getTag()) { - case ConstantPool.INTEGER: { - int value = ((CpoolValue1)constant).getValue(); - return ((value < Short.MIN_VALUE || value > Character.MAX_VALUE) - ? Type.tInt - : (value < Byte.MIN_VALUE || value > Byte.MAX_VALUE) - ? Type.tRange(Type.tInt, Type.tChar) - : Type.tUInt); - } - case ConstantPool.FLOAT : return Type.tFloat ; - case ConstantPool.LONG : return Type.tLong ; - case ConstantPool.DOUBLE : return Type.tDouble; - case ConstantPool.STRING : return Type.tString; - default: - throw new ClassFormatError("invalid constant type: " - + constant.getTag()); - } - } - - private static String quoted(String str) { - StringBuffer result = new StringBuffer("\""); - for (int i=0; i< str.length(); i++) { - char c; - switch (c = str.charAt(i)) { - case '\0': - result.append("\\0"); - break; - case '\t': - result.append("\\t"); - break; - case '\n': - result.append("\\n"); - break; - case '\r': - result.append("\\r"); - break; - case '\\': - result.append("\\\\"); - break; - case '\"': - result.append("\\\""); - break; - default: - if (c < 32) { - String oct = Integer.toOctalString(c); - result.append("\\000".substring(0, 4-oct.length())) - .append(oct); - } else if (c >= 32 && c < 127) - result.append(str.charAt(i)); - else { - String hex = Integer.toHexString(c); - result.append("\\u0000".substring(0, 6-hex.length())) - .append(hex); - } - } - } - return result.append("\"").toString(); - } - - public String getConstantString(int i) - { - CpoolEntry constant = classType.getConstant(i); - switch (constant.getTag()) { - case ConstantPool.INTEGER: - return Integer.toString(((CpoolValue1)constant).getValue()); - case ConstantPool.FLOAT: - return Float.toString - (Float.intBitsToFloat(((CpoolValue1)constant).getValue())); - case ConstantPool.LONG: - return Long.toString(((CpoolValue2)constant).getValue()); - case ConstantPool.DOUBLE: - return Double.toString - (Double.longBitsToDouble(((CpoolValue2)constant).getValue())); - case ConstantPool.STRING: - return quoted(((CpoolString)constant).getString().getString()); - } - throw new AssertError("unknown constant type"); + public ConstantPool getConstantPool() { + return clazz.getConstantPool(); } public String getTypeString(Type type) { @@ -239,4 +165,3 @@ public class ClassAnalyzer implements Analyzer { return type.toString() + " " + name; } } - diff --git a/jode/jode/decompiler/CodeAnalyzer.java b/jode/jode/decompiler/CodeAnalyzer.java index fae470a..036a7e1 100644 --- a/jode/jode/decompiler/CodeAnalyzer.java +++ b/jode/jode/decompiler/CodeAnalyzer.java @@ -18,7 +18,10 @@ */ package jode; -import jode.bytecode.ClassHierarchy; +import jode.bytecode.ClassInfo; +import jode.bytecode.ConstantPool; +import jode.bytecode.AttributeInfo; +import jode.bytecode.CodeInfo; import jode.flow.FlowBlock; import jode.flow.TransformExceptionHandlers; @@ -29,16 +32,10 @@ import java.io.DataInputStream; import java.io.ByteArrayInputStream; import java.io.IOException; -import gnu.bytecode.CodeAttr; -import gnu.bytecode.Attribute; -import gnu.bytecode.LocalVarsAttr; -import gnu.bytecode.CpoolClass; -import gnu.bytecode.Spy; - public class CodeAnalyzer implements Analyzer { FlowBlock methodHeader; - CodeAttr code; + CodeInfo code; MethodAnalyzer method; public JodeEnvironment env; @@ -52,15 +49,14 @@ public class CodeAnalyzer implements Analyzer { */ public MethodAnalyzer getMethod() {return method;} - public CodeAnalyzer(MethodAnalyzer ma, CodeAttr bc, JodeEnvironment e) + public CodeAnalyzer(MethodAnalyzer ma, CodeInfo bc, JodeEnvironment e) throws ClassFormatError { code = bc; method = ma; env = e; - LocalVarsAttr attr = - (LocalVarsAttr) Attribute.get(bc, "LocalVariableTable"); + AttributeInfo attr = code.findAttribute("LocalVariableTable"); if (attr != null) lvt = new LocalVariableTable(bc.getMaxLocals(), method.classAnalyzer, attr); @@ -81,9 +77,10 @@ public class CodeAnalyzer implements Analyzer { * @param code The code array. * @param handlers The exception handlers. */ - void readCode(byte[] code, short[] handlers) + void readCode(byte[] code, int[] handlers) throws ClassFormatError { + ConstantPool cpool = method.classAnalyzer.getConstantPool(); byte[] flags = new byte[code.length]; int[] lengths = new int[code.length]; try { @@ -101,7 +98,8 @@ public class CodeAnalyzer implements Analyzer { flags[succs[i]] |= PREDECESSORS; } } catch (IOException ex) { - throw new ClassFormatError(ex.toString()); + ex.printStackTrace(); + throw new ClassFormatError(ex.getMessage()); } for (int i=0; i mark) { System.err.print('.'); @@ -148,36 +147,34 @@ public class CodeAnalyzer implements Analyzer { } addr += lengths[addr]; } - } catch (IOException ex) { - throw new ClassFormatError(ex.toString()); - } - for (int addr=0; addr") || methodName.equals(""); - Attribute codeattr = Attribute.get(mdef, "Code"); - if (codeattr != null && codeattr instanceof CodeAttr) - code = new CodeAnalyzer(this, (CodeAttr) codeattr, env); + AttributeInfo codeattr = minfo.findAttribute("Code"); + if (codeattr != null) { + DataInputStream stream = new DataInputStream + (new ByteArrayInputStream(codeattr.getContents())); + CodeInfo codeinfo = new CodeInfo(); + try { + codeinfo.read(classAnalyzer.getConstantPool(), stream); + code = new CodeAnalyzer(this, codeinfo, env); + } catch (IOException ex) { + ex.printStackTrace(); + code = null; + } + } - Attribute excattr = Attribute.get(mdef, "Exceptions"); + AttributeInfo excattr = minfo.findAttribute("Exceptions"); if (excattr == null) { exceptions = new Type[0]; } else { - java.io.DataInputStream stream = Spy.getAttributeStream - ((MiscAttr) excattr); + DataInputStream stream = new DataInputStream + (new ByteArrayInputStream(excattr.getContents())); try { int throwCount = stream.readUnsignedShort(); this.exceptions = new Type[throwCount]; for (int t=0; t< throwCount; t++) { int idx = stream.readUnsignedShort(); - CpoolClass cpcls = (CpoolClass) - classAnalyzer.getConstant(idx); - exceptions[t] = Type.tClass(cpcls.getName().getString()); + exceptions[t] = Type.tClass(classAnalyzer.getConstantPool() + .getClassName(idx)); } - } catch (java.io.IOException ex) { + } catch (IOException ex) { throw new AssertError("exception attribute too long?"); } } @@ -133,7 +140,7 @@ public class MethodAnalyzer implements Analyzer { } public void dumpSource(TabbedPrintWriter writer) - throws java.io.IOException + throws IOException { if (Decompiler.immediateOutput && code != null) { // We do the code.analyze() here, to get diff --git a/jode/jode/expr/ConstructorOperator.java b/jode/jode/expr/ConstructorOperator.java index 8fbf78c..dc1bee6 100644 --- a/jode/jode/expr/ConstructorOperator.java +++ b/jode/jode/expr/ConstructorOperator.java @@ -18,7 +18,6 @@ */ package jode; -import gnu.bytecode.CpoolRef; public class ConstructorOperator extends Operator { MethodType methodType; diff --git a/jode/jode/expr/GetFieldOperator.java b/jode/jode/expr/GetFieldOperator.java index 89f5531..a5ee5ef 100644 --- a/jode/jode/expr/GetFieldOperator.java +++ b/jode/jode/expr/GetFieldOperator.java @@ -18,7 +18,6 @@ */ package jode; -import gnu.bytecode.CpoolRef; public class GetFieldOperator extends Operator { boolean staticFlag; diff --git a/jode/jode/expr/InvokeOperator.java b/jode/jode/expr/InvokeOperator.java index 658b668..a3304e7 100644 --- a/jode/jode/expr/InvokeOperator.java +++ b/jode/jode/expr/InvokeOperator.java @@ -18,8 +18,7 @@ */ package jode; -import gnu.bytecode.CpoolRef; -import jode.bytecode.ClassHierarchy; +import jode.bytecode.ClassInfo; public final class InvokeOperator extends Operator { CodeAnalyzer codeAnalyzer; diff --git a/jode/jode/expr/PutFieldOperator.java b/jode/jode/expr/PutFieldOperator.java index b038ff7..7ed53d8 100644 --- a/jode/jode/expr/PutFieldOperator.java +++ b/jode/jode/expr/PutFieldOperator.java @@ -18,7 +18,6 @@ */ package jode; -import gnu.bytecode.CpoolRef; public class PutFieldOperator extends StoreInstruction { CodeAnalyzer codeAnalyzer; diff --git a/jode/jode/type/ArrayType.java b/jode/jode/type/ArrayType.java index b4be2bd..dbb5790 100644 --- a/jode/jode/type/ArrayType.java +++ b/jode/jode/type/ArrayType.java @@ -116,8 +116,15 @@ public class ArrayType extends Type { return elementType.toString()+"[]"; } + private static String pluralize(String singular) { + return singular + + ((singular.endsWith("s") || singular.endsWith("x") + || singular.endsWith("sh") || singular.endsWith("ch")) + ? "es" : "s"); + } + public String getDefaultName() { - return "arr_"+elementType.getDefaultName(); + return pluralize(elementType.getDefaultName()); } public boolean equals(Object o) { diff --git a/jode/jode/type/ClassInterfacesType.java b/jode/jode/type/ClassInterfacesType.java index 16be45a..c4cb415 100644 --- a/jode/jode/type/ClassInterfacesType.java +++ b/jode/jode/type/ClassInterfacesType.java @@ -17,7 +17,7 @@ * $Id$ */ package jode; -import jode.bytecode.ClassHierarchy; +import jode.bytecode.ClassInfo; import java.util.Vector; import java.util.Stack; @@ -35,45 +35,45 @@ import java.util.Stack; * @author Jochen Hoenicke */ public class ClassInterfacesType extends Type { - ClassHierarchy clazz; - ClassHierarchy ifaces[]; + ClassInfo clazz; + ClassInfo ifaces[]; - public ClassHierarchy getClazz() { - return clazz != null ? clazz : ClassHierarchy.javaLangObject; + public ClassInfo getClazz() { + return clazz != null ? clazz : ClassInfo.javaLangObject; } public ClassInterfacesType(String clazzName) { super(TC_CLASS); - ClassHierarchy clazz = ClassHierarchy.forName(clazzName); + ClassInfo clazz = ClassInfo.forName(clazzName); if (clazz.isInterface()) { this.clazz = null; - ifaces = new ClassHierarchy[] {clazz}; + ifaces = new ClassInfo[] {clazz}; } else { this.clazz = - (clazz == ClassHierarchy.javaLangObject) ? null : clazz; - ifaces = new ClassHierarchy[0]; + (clazz == ClassInfo.javaLangObject) ? null : clazz; + ifaces = new ClassInfo[0]; } } - public ClassInterfacesType(ClassHierarchy clazz) { + public ClassInterfacesType(ClassInfo clazz) { super(TC_CLASS); if (clazz.isInterface()) { this.clazz = null; - ifaces = new ClassHierarchy[] { clazz }; + ifaces = new ClassInfo[] { clazz }; } else { this.clazz = - (clazz == ClassHierarchy.javaLangObject) ? null : clazz; - ifaces = new ClassHierarchy[0]; + (clazz == ClassInfo.javaLangObject) ? null : clazz; + ifaces = new ClassInfo[0]; } } - public ClassInterfacesType(ClassHierarchy clazz, ClassHierarchy[] ifaces) { + public ClassInterfacesType(ClassInfo clazz, ClassInfo[] ifaces) { super(TC_CLASS); this.clazz = clazz; this.ifaces = ifaces; } - private static Type create(ClassHierarchy clazz, ClassHierarchy[] ifaces) { + private static Type create(ClassInfo clazz, ClassInfo[] ifaces) { /* Make sure that every {java.lang.Object} equals tObject */ if (ifaces.length == 0 && clazz == null) return tObject; @@ -125,7 +125,7 @@ public class ClassInterfacesType extends Type { * classes/interfaces that implement all bottom.ifaces. */ - ClassHierarchy clazz = this.clazz; + ClassInfo clazz = this.clazz; if (clazz != null) { for (int i=0; i < bottom.ifaces.length; i++) { if (!bottom.ifaces[i].implementedBy(clazz)) { @@ -145,7 +145,7 @@ public class ClassInterfacesType extends Type { } } - ClassHierarchy[] ifaces = new ClassHierarchy[this.ifaces.length]; + ClassInfo[] ifaces = new ClassInfo[this.ifaces.length]; int count = 0; big_loop: for (int j=0; j < this.ifaces.length; j++) { @@ -157,7 +157,7 @@ public class ClassInterfacesType extends Type { } if (count < ifaces.length) { - ClassHierarchy[] shortIfaces = new ClassHierarchy[count]; + ClassInfo[] shortIfaces = new ClassInfo[count]; System.arraycopy(ifaces, 0, shortIfaces, 0, count); ifaces = shortIfaces; } else if (clazz == this.clazz) @@ -166,10 +166,10 @@ public class ClassInterfacesType extends Type { } } - private boolean implementsAllIfaces(ClassHierarchy[] otherIfaces) { + private boolean implementsAllIfaces(ClassInfo[] otherIfaces) { big: for (int i=0; i < otherIfaces.length; i++) { - ClassHierarchy iface = otherIfaces[i]; + ClassInfo iface = otherIfaces[i]; if (clazz != null && iface.implementedBy(clazz)) continue big; for (int j=0; j < this.ifaces.length; j++) { @@ -197,7 +197,7 @@ public class ClassInterfacesType extends Type { return tError; ClassInterfacesType other = (ClassInterfacesType) type; - ClassHierarchy clazz; + ClassInfo clazz; /* First determine the clazz, one of the two classes must be a sub * class of the other or null. @@ -231,7 +231,7 @@ public class ClassInterfacesType extends Type { Vector ifaces = new Vector(); big_loop_this: for (int i=0; i< this.ifaces.length; i++) { - ClassHierarchy iface = this.ifaces[i]; + ClassInfo iface = this.ifaces[i]; if (clazz != null && iface.implementedBy(clazz)) { continue big_loop_this; } @@ -248,12 +248,12 @@ public class ClassInterfacesType extends Type { } big_loop_other: for (int i=0; i< other.ifaces.length; i++) { - ClassHierarchy iface = other.ifaces[i]; + ClassInfo iface = other.ifaces[i]; if (clazz != null && iface.implementedBy(clazz)) { continue big_loop_other; } for (int j=0; j 0) type = ifaces[0]; else - type = ClassHierarchy.javaLangObject; + type = ClassInfo.javaLangObject; String name = type.getName(); int dot = name.lastIndexOf('.'); if (dot >= 0) diff --git a/jode/jode/type/MethodType.java b/jode/jode/type/MethodType.java index 6fddaff..5d8d127 100644 --- a/jode/jode/type/MethodType.java +++ b/jode/jode/type/MethodType.java @@ -24,12 +24,14 @@ package jode; * @author Jochen Hoenicke */ public class MethodType { + final String signature; final Type[] parameterTypes; final Type returnType; final boolean staticFlag; public MethodType(boolean isStatic, String signature) { this.staticFlag = isStatic; + this.signature = signature; int index = 1, types = 0; while (signature.charAt(index) != ')') { types++; @@ -68,16 +70,14 @@ public class MethodType { return returnType; } + public String toString() { + return signature; + } + public boolean equals(Object o) { MethodType mt; - if (!(o instanceof InvokeOperator) - || !returnType.equals((mt = (MethodType)o).returnType) - || staticFlag != mt.staticFlag - || parameterTypes.length != mt.parameterTypes.length) - return false; - for (int i=0; i