Fixed compile problems, but still not working

git-svn-id: https://svn.code.sf.net/p/jode/code/branches/generics@1400 379699f6-c40d-0410-875b-85095c16579e
generics
hoenicke 18 years ago
parent a5a48b3727
commit a9e2d0fdaa
  1. BIN
      jode/doc/jode-2.png
  2. 32
      jode/src/net/sf/jode/bytecode/BasicBlockReader.java
  3. 15
      jode/src/net/sf/jode/bytecode/BasicBlockWriter.java
  4. 6
      jode/src/net/sf/jode/bytecode/BasicBlocks.java
  5. 6
      jode/src/net/sf/jode/bytecode/Block.java
  6. 2
      jode/src/net/sf/jode/bytecode/ClassFormatException.java
  7. 2
      jode/src/net/sf/jode/bytecode/ClassInfo.java
  8. 3
      jode/src/net/sf/jode/bytecode/ClassPath.java
  9. 1
      jode/src/net/sf/jode/bytecode/SwitchInstruction.java
  10. 44
      jode/src/net/sf/jode/bytecode/TypeSignature.java
  11. 3
      jode/src/net/sf/jode/decompiler/Applet.java
  12. 29
      jode/src/net/sf/jode/decompiler/ClassAnalyzer.java
  13. 1
      jode/src/net/sf/jode/decompiler/Decompiler.java
  14. 4
      jode/src/net/sf/jode/decompiler/FieldAnalyzer.java
  15. 30
      jode/src/net/sf/jode/swingui/Main.java
  16. 4
      jode/src/net/sf/jode/type/ArrayType.java
  17. 17
      jode/src/net/sf/jode/type/ClassInfoType.java
  18. 23
      jode/src/net/sf/jode/type/ClassType.java
  19. 4
      jode/src/net/sf/jode/type/MultiClassType.java
  20. 4
      jode/src/net/sf/jode/type/NullType.java
  21. 84
      jode/src/net/sf/jode/type/RangeType.java
  22. 2
      jode/src/net/sf/jode/type/Type.java
  23. 99
      jode/test/CountOpcodes.java
  24. 4
      jode/test/InlineTest.java
  25. 2
      jode/test/ResolveConflicts.java
  26. 9
      jode/test/innerclasses/CheckSuperRemove.java

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.4 KiB

@ -25,9 +25,6 @@ import java.io.IOException;
import java.util.Stack;
import java.util.Vector;
import java.util.Enumeration;
///#def COLLECTIONS java.util
import java.util.Arrays;
///#enddef
/**
* This is a helper class, that contains the method to read in basic
@ -66,11 +63,6 @@ class BasicBlockReader implements Opcodes {
String name, type;
}
private class LNTEntry {
int lineNr;
int start;
}
InstrInfo[] infos;
HandlerEntry[] handlers;
BasicBlocks bb;
@ -546,8 +538,10 @@ class BasicBlockReader implements Opcodes {
case opc_ldc: {
int index = input.readUnsignedByte();
int tag = cp.getTag(index);
if (tag != cp.STRING && tag != cp.CLASS
&& tag != cp.INTEGER && tag != cp.FLOAT)
if (tag != ConstantPool.STRING
&& tag != ConstantPool.CLASS
&& tag != ConstantPool.INTEGER
&& tag != ConstantPool.FLOAT)
throw new ClassFormatException
("wrong constant tag: "+tag);
instr = new ConstantInstruction
@ -558,8 +552,10 @@ class BasicBlockReader implements Opcodes {
case opc_ldc_w: {
int index = input.readUnsignedShort();
int tag = cp.getTag(index);
if (tag != cp.STRING && tag != cp.CLASS
&& tag != cp.INTEGER && tag != cp.FLOAT)
if (tag != ConstantPool.STRING
&& tag != ConstantPool.CLASS
&& tag != ConstantPool.INTEGER
&& tag != ConstantPool.FLOAT)
throw new ClassFormatException
("wrong constant tag: "+tag);
instr = new ConstantInstruction
@ -570,7 +566,7 @@ class BasicBlockReader implements Opcodes {
case opc_ldc2_w: {
int index = input.readUnsignedShort();
int tag = cp.getTag(index);
if (tag != cp.LONG && tag != cp.DOUBLE)
if (tag != ConstantPool.LONG && tag != ConstantPool.DOUBLE)
throw new ClassFormatException
("wrong constant tag: "+tag);
instr = new ConstantInstruction
@ -680,11 +676,11 @@ class BasicBlockReader implements Opcodes {
int index = input.readUnsignedShort();
int tag = cp.getTag(index);
if (opcode < opc_invokevirtual) {
if (tag != cp.FIELDREF)
if (tag != ConstantPool.FIELDREF)
throw new ClassFormatException
("field tag mismatch: "+tag);
} else {
if (tag != cp.METHODREF)
if (tag != ConstantPool.METHODREF)
throw new ClassFormatException
("method tag mismatch: "+tag);
}
@ -704,7 +700,7 @@ class BasicBlockReader implements Opcodes {
case opc_invokeinterface: {
int index = input.readUnsignedShort();
int tag = cp.getTag(index);
if (tag != cp.INTERFACEMETHODREF)
if (tag != ConstantPool.INTERFACEMETHODREF)
throw new ClassFormatException
("interface tag mismatch: "+tag);
Reference ref = cp.getRef(index);
@ -966,8 +962,8 @@ class BasicBlockReader implements Opcodes {
int nameIndex = input.readUnsignedShort();
int typeIndex = input.readUnsignedShort();
int slot = input.readUnsignedShort();
if (nameIndex == 0 || cp.getTag(nameIndex) != cp.UTF8
|| typeIndex == 0 || cp.getTag(typeIndex) != cp.UTF8
if (nameIndex == 0 || cp.getTag(nameIndex) != ConstantPool.UTF8
|| typeIndex == 0 || cp.getTag(typeIndex) != ConstantPool.UTF8
|| slot >= maxLocals) {
// This is probably an evil lvt as created by HashJava

@ -25,8 +25,6 @@ import java.util.BitSet;
import java.util.Stack;
///#def COLLECTIONS java.util
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
///#enddef
/**
@ -382,17 +380,18 @@ class BasicBlockWriter implements Opcodes {
case opc_getfield:
case opc_putstatic:
case opc_putfield:
gcp.putRef(gcp.FIELDREF, instr.getReference());
gcp.putRef(ConstantPool.FIELDREF, instr.getReference());
length = 3;
break;
case opc_invokespecial:
case opc_invokestatic:
case opc_invokevirtual:
gcp.putRef(gcp.METHODREF, instr.getReference());
gcp.putRef(ConstantPool.METHODREF, instr.getReference());
length = 3;
break;
case opc_invokeinterface:
gcp.putRef(gcp.INTERFACEMETHODREF, instr.getReference());
gcp.putRef(ConstantPool.INTERFACEMETHODREF,
instr.getReference());
length = 5;
break;
case opc_new:
@ -880,7 +879,7 @@ class BasicBlockWriter implements Opcodes {
case opc_putstatic:
case opc_putfield:
output.writeByte(opcode);
output.writeShort(gcp.putRef(gcp.FIELDREF,
output.writeShort(gcp.putRef(ConstantPool.FIELDREF,
instr.getReference()));
break;
@ -892,13 +891,13 @@ class BasicBlockWriter implements Opcodes {
output.writeByte(opcode);
if (opcode == opc_invokeinterface) {
output.writeShort
(gcp.putRef(gcp.INTERFACEMETHODREF, ref));
(gcp.putRef(ConstantPool.INTERFACEMETHODREF, ref));
output.writeByte
(TypeSignature
.getParameterSize(ref.getType()) + 1);
output.writeByte(0);
} else
output.writeShort(gcp.putRef(gcp.METHODREF, ref));
output.writeShort(gcp.putRef(ConstantPool.METHODREF, ref));
break;
}
case opc_new:

@ -32,10 +32,6 @@ import java.util.Stack;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.NoSuchElementException;
///#enddef
///#def COLLECTIONEXTRA java.lang
import java.lang.UnsupportedOperationException;
///#enddef
/**
@ -187,8 +183,6 @@ public class BasicBlocks extends BinaryInfo implements Opcodes {
BitSet visited = new BitSet();
Stack todo = new Stack();
int[] poppush = new int[2];
startBlock.stackHeight = 0;
todo.push(startBlock);
while (!todo.isEmpty()) {

@ -20,12 +20,6 @@
package net.sf.jode.bytecode;
import java.io.PrintWriter;
///#def COLLECTIONS java.util
import java.util.Collection;
import java.util.Arrays;
import java.util.List;
import java.util.Iterator;
///#enddef
/**
* <p>Represents a single basic block. It contains a list of

@ -24,7 +24,7 @@ package net.sf.jode.bytecode;
*
* @author Jochen Hoenicke
*/
public class ClassFormatException extends java.io.IOException{
public class ClassFormatException extends java.io.IOException {
/**
* Constructs a new class format exception with the given detail
* message.

@ -19,10 +19,8 @@
package net.sf.jode.bytecode;
import net.sf.jode.GlobalOptions;
import net.sf.jode.util.UnifyHash;
import java.io.DataInputStream;
import java.io.BufferedInputStream;
import java.io.DataOutputStream;
import java.io.OutputStream;
import java.io.IOException;

@ -25,7 +25,6 @@ import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FilterInputStream;
import java.io.IOException;
import java.io.InputStream;
@ -36,7 +35,6 @@ import java.net.URLConnection;
import java.util.Enumeration;
import java.util.NoSuchElementException;
import java.util.Hashtable;
import java.util.StringTokenizer;
import java.util.Vector;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
@ -288,7 +286,6 @@ public class ClassPath {
if (!directory.endsWith(File.separator))
directory += File.separator;
final String prefix = directory;
return new Enumeration() {
int i = 0;
public boolean hasMoreElements() {

@ -18,7 +18,6 @@
*/
package net.sf.jode.bytecode;
import net.sf.jode.util.StringQuoter;
/**
* This class represents an instruction in the byte code.

@ -18,7 +18,6 @@
*/
package net.sf.jode.bytecode;
import net.sf.jode.util.UnifyHash;
///#def COLLECTIONS java.util
import java.util.Map;
///#enddef
@ -344,6 +343,49 @@ public class TypeSignature {
return methodTypeSig.substring(methodTypeSig.lastIndexOf(')')+1);
}
/**
* Gets the names and types of the generic parameters of the given type signature.
* @param typeSig the type signature.
* @return an array containing all generic parameters together with their
* type in correct order, or null if there aren't any generic parameters.
*/
public static String[] getGenericSignatures(String typeSig) {
System.err.println(typeSig);
if (typeSig.charAt(0) != '<')
return null;
int pos = 1;
int count = 0;
while (typeSig.charAt(pos) != '>') {
while (typeSig.charAt(pos) != ':')
pos++;
/* check for empty entry */
if (typeSig.charAt(pos+1) == ':')
pos++;
while (typeSig.charAt(pos) == ':') {
/* skip colon and type */
pos = skipType(typeSig, pos + 1);
}
count++;
}
String[] params = new String[count];
pos = 1;
count = 0;
while (typeSig.charAt(pos) != '>') {
int spos = pos;
while (typeSig.charAt(pos) != ':')
pos++;
/* check for empty entry */
if (typeSig.charAt(pos+1) == ':')
pos++;
while (typeSig.charAt(pos) == ':') {
/* skip colon and type */
pos = skipType(typeSig, pos + 1);
}
params[count++] = typeSig.substring(spos, pos);
}
return params;
}
/**
* Gets the names of the generic parameters of the given type signature.
* @param typeSig the type signature.

@ -24,7 +24,8 @@ import java.awt.Graphics;
import java.awt.Insets;
public class Applet extends java.applet.Applet {
private final int BORDER = 10;
private static final long serialVersionUID = -132941289170424862L;
private final int BORDER = 10;
private final int BEVEL = 2;
private Window jodeWin = new Window(this);
private Insets myInsets;

@ -21,11 +21,14 @@ package net.sf.jode.decompiler;
import net.sf.jode.GlobalOptions;
import net.sf.jode.type.MethodType;
import net.sf.jode.type.Type;
import net.sf.jode.type.GenericParameterType;
import net.sf.jode.type.ClassType;
import net.sf.jode.bytecode.ClassFormatException;
import net.sf.jode.bytecode.ClassInfo;
import net.sf.jode.bytecode.ClassPath;
import net.sf.jode.bytecode.FieldInfo;
import net.sf.jode.bytecode.MethodInfo;
import net.sf.jode.bytecode.TypeSignature;
import net.sf.jode.expr.Expression;
import net.sf.jode.expr.ThisOperator;
import net.sf.jode.flow.TransformConstructors;
@ -33,6 +36,8 @@ import net.sf.jode.flow.StructuredBlock;
import net.sf.jode.util.SimpleSet;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.Vector;
import java.util.Enumeration;
@ -96,27 +101,29 @@ public class ClassAnalyzer
throws ClassFormatException, IOException
{
clazz.load(ClassInfo.ALL);
String signatures = clazz.getSignature();
if (signatures.charAt(0) == '<') {
String[] genericSignatures = signature.getGenericNames();
String signature = clazz.getSignature();
if (signature.charAt(0) == '<') {
String[] genericSignatures = TypeSignature.getGenericSignatures(signature);
generics = new String[genericSignatures.length];
genericTypes = new Type[genericSignatures.length];
for (int i = 0; i < generics.length; i++) {
int colon = genericSignatures[i].charAt(':');
int colon = genericSignatures[i].indexOf(':');
String genName;
if (colon == -1) {
generics[i] = genericSignatures[i];
genericType[i] =
genericTypes[i] =
new GenericParameterType(genericSignatures[i],
Type.tObject,
new ClassType[0]);
} else {
generics[i] = genericSignatures[i].substring(0, colon);
String remainder = genericSignatures[i].substring(colon+1);
int nextIndex = remainder.skipType(remainder, 0);
List superClazzes;
int nextIndex = TypeSignature.skipType(remainder, 0);
List superClazzes = new ArrayList();
for (;;) {
String clazzSig = remainder.substring(0, nextIndex);
superClazzes.add(Type.tType(clazzSig));
superClazzes.add(Type.tType(clazz.getClassPath(),
clazzSig));
if (nextIndex >= remainder.length())
break;
remainder = remainder.substring(nextIndex+1);
@ -128,9 +135,9 @@ public class ClassAnalyzer
genSupClass = Type.tObject;
ClassType[] genSupIfaces = (ClassType[])
superClazzes.toArray(new ClassType[0]);
genericType[i] = new GenericParameterType(generics[i],
genSupClass,
genSupIfaces);
genericTypes[i] = new GenericParameterType(generics[i],
genSupClass,
genSupIfaces);
}
}
}

@ -24,7 +24,6 @@ import net.sf.jode.bytecode.ClassInfo;
import java.io.File;
import java.io.PrintWriter;
import java.io.Writer;
import java.io.BufferedWriter;
/**
* This is the interface that other java classes may use to decompile

@ -183,7 +183,7 @@ public class FieldAnalyzer implements Analyzer {
| Modifier.STATIC
| Modifier.FINAL);
*/
writer.startOp(writer.NO_PAREN, 0);
writer.startOp(TabbedPrintWriter.NO_PAREN, 0);
String modif = Modifier.toString(modifiedModifiers);
if (modif.length() > 0)
writer.print(modif+" ");
@ -193,7 +193,7 @@ public class FieldAnalyzer implements Analyzer {
if (constant != null) {
writer.breakOp();
writer.print(" = ");
constant.dumpExpression(writer.IMPL_PAREN, writer);
constant.dumpExpression(TabbedPrintWriter.IMPL_PAREN, writer);
}
writer.endOp();
writer.println(";");

@ -32,8 +32,6 @@ import javax.swing.tree.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.util.StringTokenizer;
import java.util.ResourceBundle;
import java.util.*;
public class Main
@ -147,8 +145,9 @@ public class Main
rightPane.setDividerSize(4);
allPane.setDividerLocation(200);
allPane.setDividerSize(4);
decompiler.setErr(new PrintWriter
(new BufferedWriter(new AreaWriter(errorArea)), true));
decompiler.setErr(new PrintWriter(System.err));
//new PrintWriter
// (new BufferedWriter(new AreaWriter(errorArea)), true));
}
public synchronized void valueChanged(TreeSelectionEvent e) {
@ -250,16 +249,19 @@ public class Main
};
try {
decompiler.decompile(lastClassName, writer, progListener);
} catch (Throwable t) {
try {
writer.write(bundle.getString("main.exception"));
PrintWriter pw = new PrintWriter(writer);
t.printStackTrace(pw);
pw.flush();
} catch (IOException ex) {
/* Shouldn't happen, complain to stderr */
ex.printStackTrace();
}
// } catch (Throwable t) {
// try {
// writer.write(bundle.getString("main.exception"));
// PrintWriter pw = new PrintWriter(writer);
// t.printStackTrace(pw);
// pw.flush();
// } catch (IOException ex) {
// /* Shouldn't happen, complain to stderr */
// ex.printStackTrace();
// }
} catch (IOException e) {
// TODO Auto-generated catch block
throw (RuntimeException) new RuntimeException().initCause(e);
} finally {
try {
writer.close();

@ -124,7 +124,7 @@ public class ArrayType extends ClassType {
* tArray(x), other -> tError
*/
if (type.getTypeCode() == TC_RANGE) {
type = ((RangeType) type).getBottom();
type = ((RangeType) type).getTop();
}
if (type == tNull)
return this;
@ -150,7 +150,7 @@ public class ArrayType extends ClassType {
* tArray(x), other -> tError
*/
if (type.getTypeCode() == TC_RANGE) {
type = ((RangeType) type).getTop();
type = ((RangeType) type).getBottom();
}
if (type == tNull)
return this;

@ -20,6 +20,8 @@
package net.sf.jode.type;
import net.sf.jode.bytecode.ClassInfo;
import net.sf.jode.bytecode.TypeSignature;
import net.sf.jode.util.SimpleMap;
import net.sf.jode.util.SimpleSet;
import net.sf.jode.GlobalOptions;
import java.lang.reflect.Modifier;
@ -30,6 +32,7 @@ import java.util.Hashtable;
///#def COLLECTIONS java.util
import java.util.Map;
import java.util.Set;
///#enddef
/**
@ -68,22 +71,24 @@ public class ClassInfoType extends ClassType {
return;
}
genInstances = generics;
genericInstances = generics;
Map genericMap = new SimpleMap();
if (generics != null) {
/* parse generic names */
String[] genNames;
if (signature.charAt(0) == '<')
genNames = TypeSignature.getGenericNames(signature);
if (genNames == null)
if (signature.charAt(0) != '<')
throw new IllegalArgumentException
("Generic parameters for non-generic class");
genNames = TypeSignature.getGenericNames(signature);
if (generics.length != genNames.length)
throw new IllegalArgumentException
("Wrong number of generic parameters");
for (int i = 0; i < generics.length; i++)
genericMap.put(genNames[i], generics[i].getTypeSignature());
}
signature = TypeSignature.mapGenerics(signature, getGenerics());
signature = TypeSignature.mapGenerics(signature, genericMap);
}
public boolean isUnknown() {

@ -18,15 +18,8 @@
*/
package net.sf.jode.type;
import java.util.Stack;
import java.util.Hashtable;
import java.util.Enumeration;
import java.io.IOException;
///#def COLLECTIONS java.util
import java.util.Collections;
import java.util.Map;
///#enddef
import java.util.Stack;
/**
* This class is the base class of all types representing a class type.<p>
@ -70,7 +63,7 @@ public abstract class ClassType extends ReferenceType {
super(typecode);
className = clazzName;
genericNames = genNames;
genericTypes = genTypes;
genericInstances = genTypes;
}
/**
@ -208,7 +201,7 @@ public abstract class ClassType extends ReferenceType {
*/
public Type getSpecializedType(Type type) {
if (type instanceof RangeType) {
type = ((RangeType) type).getBottom();
type = ((RangeType) type).getTop();
}
/* Most times (almost always) one of the two classes is
@ -238,7 +231,7 @@ public abstract class ClassType extends ReferenceType {
public Type getGeneralizedType(Type type) {
int code = type.typecode;
if (code == TC_RANGE) {
type = ((RangeType) type).getTop();
type = ((RangeType) type).getBottom();
code = type.typecode;
}
if (code == TC_NULL)
@ -270,12 +263,12 @@ public abstract class ClassType extends ReferenceType {
public String toString()
{
if (genInstances == null)
if (genericInstances == null)
return className;
StringBuffer sb = new StringBuffer(className).append('<');
String comma = "";
for (int i = 0; i < genInstances.length; i++) {
sb.append(comma).append(genInstances[i].toString());
for (int i = 0; i < genericInstances.length; i++) {
sb.append(comma).append(genericInstances[i].toString());
}
sb.append('>');
return sb.toString();
@ -289,7 +282,7 @@ public abstract class ClassType extends ReferenceType {
public Type getCastHelper(Type fromType) {
if (isInterface() || fromType == tNull
|| (fromType instanceof RangeType
&& ((RangeType)fromType).getBottom() == tNull))
&& ((RangeType)fromType).getTop() == tNull))
return null;
Type hint = fromType.getHint();
if (hint.isSuperTypeOf(this)

@ -154,7 +154,7 @@ public class MultiClassType extends ReferenceType {
*/
public Type getSpecializedType(Type type) {
if (type instanceof RangeType)
type = ((RangeType) type).getBottom();
type = ((RangeType) type).getTop();
/* Most times (almost always) one of the two types is
* already more specialized. Optimize for this case.
@ -212,7 +212,7 @@ public class MultiClassType extends ReferenceType {
*/
public Type getGeneralizedType(Type type) {
if (type instanceof RangeType)
type = ((RangeType) type).getTop();
type = ((RangeType) type).getBottom();
/* Often one of the two classes is already more generalized.
* Optimize for this case.

@ -55,7 +55,7 @@ public class NullType extends ReferenceType {
*/
public Type getGeneralizedType(Type type) {
if (type.typecode == TC_RANGE)
type = ((RangeType) type).getTop();
type = ((RangeType) type).getBottom();
if (type instanceof ReferenceType)
return type;
return tError;
@ -69,7 +69,7 @@ public class NullType extends ReferenceType {
*/
public Type getSpecializedType(Type type) {
if (type.typecode == TC_RANGE)
type = ((RangeType) type).getBottom();
type = ((RangeType) type).getTop();
if (type != tNull)
return tError;
return tNull;

@ -53,25 +53,25 @@ import java.util.Hashtable;
* @date 98/08/06 */
public class RangeType extends Type {
/**
* The bottom type set. Each type in the set represented by
* The top type set. Each type in the set represented by
* this range type can be casted to all types in bottom type.
*/
final ReferenceType bottomType;
final ReferenceType topType;
/**
* The top type set. For each type in this range type, there is a
* The bottom type set. For each type in this range type, there is a
* top type, that can be casted to this type.
*/
final ReferenceType topType;
final ReferenceType bottomType;
/**
* Create a new range type with the given bottom and top set.
*/
RangeType(ReferenceType bottomType, ReferenceType topType) {
RangeType(ReferenceType topType, ReferenceType bottomType) {
super(TC_RANGE);
if (bottomType == tNull)
throw new InternalError("bottom is NULL");
this.bottomType = bottomType;
if (topType == tNull)
throw new InternalError("top is NULL");
this.topType = topType;
this.bottomType = bottomType;
}
/**
@ -79,17 +79,17 @@ public class RangeType extends Type {
* be casted to all bottom types by a widening cast.
* @return the bottom type set
*/
ReferenceType getBottom() {
return bottomType;
ReferenceType getTop() {
return topType;
}
/**
* Returns the top type set. For each type in this range type,
* there is a top type, that can be casted to this type.
* @return the top type set
* Returns the bottom type set. For each type in this range type,
* there is a bottom type, that can be casted to this type.
* @return the bottom type set
*/
ReferenceType getTop() {
return topType;
ReferenceType getBottom() {
return bottomType;
}
@ -101,13 +101,13 @@ public class RangeType extends Type {
* @return the hint type.
*/
public Type getHint() {
Type bottomHint = bottomType.getHint();
Type topHint = topType.getHint();
Type bottomHint = bottomType.getHint();
if (topType == tNull && bottomType.equals(bottomHint))
return bottomHint;
if (bottomType == tNull && topType.equals(topHint))
return topHint;
return topHint;
return bottomHint;
}
/**
@ -116,7 +116,7 @@ public class RangeType extends Type {
* @return the canonic type.
*/
public Type getCanonic() {
return topType.getCanonic();
return bottomType.getCanonic();
}
/**
@ -125,7 +125,7 @@ public class RangeType extends Type {
* @return the set of super types.
*/
public Type getSuperType() {
return topType.getSuperType();
return bottomType.getSuperType();
}
/**
@ -134,7 +134,7 @@ public class RangeType extends Type {
* @return the set of super types.
*/
public Type getSubType() {
return tRange(bottomType, tNull);
return tRange(topType, tNull);
}
/**
@ -143,26 +143,26 @@ public class RangeType extends Type {
* @return the middle type, or null if it is not necessary.
*/
public Type getCastHelper(Type fromType) {
return topType.getCastHelper(fromType);
return bottomType.getCastHelper(fromType);
}
public String getTypeSignature() {
if (topType.isClassType() || !bottomType.isValidType())
return topType.getTypeSignature();
else
if (bottomType.isClassType() || !topType.isValidType())
return bottomType.getTypeSignature();
else
return topType.getTypeSignature();
}
public Class getTypeClass() throws ClassNotFoundException {
if (topType.isClassType() || !bottomType.isValidType())
return topType.getTypeClass();
else
if (bottomType.isClassType() || !topType.isValidType())
return bottomType.getTypeClass();
else
return topType.getTypeClass();
}
public String toString()
{
return "<" + bottomType + "-" + topType + ">";
return "<" + topType + "-" + bottomType + ">";
}
public String getDefaultName() {
@ -170,29 +170,29 @@ public class RangeType extends Type {
}
public int hashCode() {
int hashcode = topType.hashCode();
return (hashcode << 16 | hashcode >>> 16) ^ bottomType.hashCode();
int hashcode = bottomType.hashCode();
return (hashcode << 16 | hashcode >>> 16) ^ topType.hashCode();
}
public boolean equals(Object o) {
if (o instanceof RangeType) {
RangeType type = (RangeType) o;
return topType.equals(type.topType)
&& bottomType.equals(type.bottomType);
return bottomType.equals(type.bottomType)
&& topType.equals(type.topType);
}
return false;
}
public boolean containsClass(ClassInfo clazz) {
ClassType clazzType = Type.tClass(clazz, null);
if (!bottomType.maybeSuperTypeOf(clazzType))
if (!topType.maybeSuperTypeOf(clazzType))
return false;
if (topType == tNull)
if (bottomType == tNull)
return true;
if (topType instanceof ClassType)
return clazzType.maybeSuperTypeOf((ClassType) topType);
if (topType instanceof MultiClassType) {
ClassType[] classes = ((MultiClassType) topType).classes;
if (bottomType instanceof ClassType)
return clazzType.maybeSuperTypeOf((ClassType) bottomType);
if (bottomType instanceof MultiClassType) {
ClassType[] classes = ((MultiClassType) bottomType).classes;
for (int i = 0; i < classes.length; i++) {
if (clazzType.maybeSuperTypeOf(classes[i]))
return true;
@ -213,8 +213,8 @@ public class RangeType extends Type {
return this;
Type top, bottom, result;
bottom = bottomType.getSpecializedType(type);
top = topType.getGeneralizedType(type);
bottom = topType.getSpecializedType(type);
top = bottomType.getGeneralizedType(type);
if (top.equals(bottom))
result = top;
else if (top instanceof ReferenceType

@ -327,7 +327,7 @@ public class Type {
while (iter.hasNext()) {
ClassInfoType type = (ClassInfoType) iter.next();
if (type.getClassInfo() == clazzinfo
&& Arrays.equals(generics, type.genInstances))
&& Arrays.equals(generics, type.genericInstances))
return type;
}
ClassInfoType type = new ClassInfoType(clazzinfo, generics);

@ -1,99 +0,0 @@
import jode.bytecode.*;
import java.util.*;
import com.sun.java.util.collections.Iterator;
public class CountOpcodes {
static int[] opcodeCount = new int[256];
static int[] predsCount = new int[1024];
static int[] succsCount = new int[1024];
static Vector instructions = new Vector(73400);
public static void handleBytecode(BytecodeInfo bc) {
for (Iterator i = bc.getInstructions().iterator(); i.hasNext();) {
Instruction instr = (Instruction) i.next();
instructions.addElement(instr);
opcodeCount[instr.getOpcode()]++;
Instruction[] p = instr.getPreds();
if (p == null)
predsCount[0]++;
else
predsCount[p.length]++;
Instruction[] s = instr.getSuccs();
if (s == null)
succsCount[0]++;
else
succsCount[s.length]++;
}
}
public static void handlePackage(String pack) {
Enumeration subs = ClassInfo.getClassesAndPackages(pack);
while (subs.hasMoreElements()) {
String comp = (String) subs.nextElement();
String full = pack + "." + comp;
if (ClassInfo.isPackage(full))
handlePackage(full);
else {
ClassInfo clazz = ClassInfo.forName(full);
clazz.loadInfo(ClassInfo.FULLINFO);
MethodInfo[] ms = clazz.getMethods();
for (int i=0; i < ms.length; i++) {
BytecodeInfo bc = ms[i].getBytecode();
if (bc != null)
handleBytecode(bc);
}
}
}
}
public static void main(String[] params) {
ClassInfo.setClassPath(params[0]);
Runtime runtime = Runtime.getRuntime();
long free = runtime.freeMemory();
long last;
do {
last = free;
runtime.gc();
runtime.runFinalization();
free = runtime.freeMemory();
} while (free < last);
System.err.println("used before: "+(runtime.totalMemory()- free));
long time = System.currentTimeMillis();
handlePackage("com");
System.err.println("Time used: "+(System.currentTimeMillis() - time));
free = runtime.freeMemory();
do {
last = free;
runtime.gc();
runtime.runFinalization();
free = runtime.freeMemory();
} while (free < last);
System.err.println("used after: "+(runtime.totalMemory()- free));
System.err.println("instruction count: "+instructions.size());
for (int i=0; i< 256; i++) {
if (opcodeCount[i] > 0)
System.err.println("Opcode "+i+": \t ("+Opcodes.opcodeString[i]+")\t"+opcodeCount[i]);
}
int moreThanTwo = 0;
for (int i=0; i< predsCount.length; i++) {
if (predsCount[i] > 0) {
System.err.println("preds "+i+": \t"+predsCount[i]);
if (i>1)
moreThanTwo +=predsCount[i];
}
}
System.err.println("preds >2: \t"+moreThanTwo);
moreThanTwo = 0;
for (int i=0; i< succsCount.length; i++) {
if (succsCount[i] > 0) {
System.err.println("succs "+i+": \t"+succsCount[i]);
if (i>1)
moreThanTwo +=succsCount[i];
}
}
System.err.println("succs >2: \t"+moreThanTwo);
}
}

@ -23,12 +23,12 @@
* in a different package to check if inlining works over package borders.
*
* @author Jochen Hoenicke
* @see jode.test.OptimizeTest
* @see OptimizeTest
*/
public class InlineTest {
public static final int
difficultSideInline(jode.test.OptimizeTest ot, int a) {
difficultSideInline(OptimizeTest ot, int a) {
return ot.g++ + a;
}
}

@ -119,7 +119,7 @@ public class ResolveConflicts
///#endif
///#endif
///#ifdef JAVAC11
return null;
/// return null;
///#else
return ResolveConflicts.this.new Conflicts().new Inner();
///#endif

@ -5,11 +5,12 @@ public class CheckSuperRemove {
}
MyInner myInner = new MyInner();
Inner anonInner = new Inner() {
public void test() {}
};
public void test() {}
};
/*FIXME: Understand why this does not work:
MyInner anonInner2 = new MyInner() {
public void test() {}
};
public void test() {}
};*/
}
}

Loading…
Cancel
Save