Remove java.lang.reflect code

git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@130 379699f6-c40d-0410-875b-85095c16579e
stable
jochen 26 years ago
parent 87f79ddf49
commit 1172c72832
  1. 20
      jode/jode/bytecode/SearchPath.java
  2. 38
      jode/jode/decompiler/ClassAnalyzer.java
  3. 42
      jode/jode/decompiler/CodeAnalyzer.java
  4. 2
      jode/jode/decompiler/FieldAnalyzer.java
  5. 69
      jode/jode/decompiler/ImportHandler.java
  6. 6
      jode/jode/decompiler/MethodAnalyzer.java
  7. 2
      jode/jode/expr/GetFieldOperator.java
  8. 26
      jode/jode/expr/InvokeOperator.java
  9. 2
      jode/jode/expr/PutFieldOperator.java
  10. 141
      jode/jode/type/ClassInterfacesType.java
  11. 9
      jode/jode/type/MethodType.java
  12. 25
      jode/jode/type/Type.java

@ -59,6 +59,26 @@ public class SearchPath {
}
}
public boolean exists(String filename) {
for (int i=0; i<dirs.length; i++) {
if (dirs[i] == null)
continue;
if (zips[i] != null) {
ZipEntry ze = zips[i].getEntry(filename);
if (ze != null)
return true;
} else {
if (java.io.File.separatorChar != '/')
filename = filename
.replace('/', java.io.File.separatorChar);
File f = new File(dirs[i], filename);
if (f.exists())
return true;
}
}
return false;
}
/**
* Searches for a file in the search path.
* @param filename the filename. The path components should be separated

@ -19,14 +19,12 @@
package jode;
import java.lang.reflect.Modifier;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Constructor;
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.flow.TransformConstructors;
public class ClassAnalyzer implements Analyzer {
@ -35,22 +33,17 @@ public class ClassAnalyzer implements Analyzer {
MethodAnalyzer staticConstructor;
MethodAnalyzer[] constructors;
Class clazz;
ClassHierarchy clazz;
gnu.bytecode.ClassType classType;
ClassAnalyzer parent;
public ClassAnalyzer(ClassAnalyzer parent, Class clazz,
public ClassAnalyzer(ClassAnalyzer parent, ClassHierarchy clazz,
JodeEnvironment env)
{
this.parent = parent;
this.clazz = clazz;
this.env = env;
try {
this.classType = gnu.bytecode.ClassFileInput.
readClassType(env.getClassStream(clazz));
} catch (java.io.IOException ex) {
ex.printStackTrace();
}
this.classType = env.getClassType(clazz.getName());
}
public boolean setFieldInitializer(String fieldName, Expression expr) {
@ -64,7 +57,7 @@ public class ClassAnalyzer implements Analyzer {
return false;
}
public Class getClazz() {
public ClassHierarchy getClazz() {
return clazz;
}
@ -104,12 +97,12 @@ public class ClassAnalyzer implements Analyzer {
TransformConstructors.transform(this, true, new MethodAnalyzer[]
{ staticConstructor });
env.useClass(clazz);
env.useClass(clazz.getName());
if (clazz.getSuperclass() != null)
env.useClass(clazz.getSuperclass());
Class[] interfaces = clazz.getInterfaces();
env.useClass(clazz.getSuperclass().getName());
ClassHierarchy[] interfaces = clazz.getInterfaces();
for (int j=0; j< interfaces.length; j++)
env.useClass(interfaces[j]);
env.useClass(interfaces[j].getName());
}
public void dumpSource(TabbedPrintWriter writer) throws java.io.IOException
@ -124,19 +117,20 @@ public class ClassAnalyzer implements Analyzer {
writer.print(clazz.isInterface()
? ""/*interface is in modif*/
: "class ");
writer.println(env.classString(clazz));
writer.println(env.classString(clazz.getName()));
writer.tab();
Class superClazz = clazz.getSuperclass();
if (superClazz != null && superClazz != Object.class) {
writer.println("extends "+env.classString(superClazz));
ClassHierarchy superClazz = clazz.getSuperclass();
if (superClazz != null &&
superClazz != ClassHierarchy.javaLangObject) {
writer.println("extends "+env.classString(superClazz.getName()));
}
Class[] interfaces = clazz.getInterfaces();
ClassHierarchy[] interfaces = clazz.getInterfaces();
if (interfaces.length > 0) {
writer.print(clazz.isInterface() ? "extends " : "implements ");
for (int i=0; i < interfaces.length; i++) {
if (i > 0)
writer.print(", ");
writer.print(env.classString(interfaces[i]));
writer.print(env.classString(interfaces[i].getName()));
}
writer.println("");
}

@ -18,6 +18,7 @@
*/
package jode;
import jode.bytecode.ClassHierarchy;
import jode.flow.FlowBlock;
import jode.flow.TransformExceptionHandlers;
@ -182,43 +183,6 @@ public class CodeAnalyzer implements Analyzer {
methodHeader.analyze();
}
// void readCode(byte[] code, short[] handlers)
// throws ClassFormatError
// {
// FlowBlock[] instr = new FlowBlock[code.length];
// int returnCount;
// try {
// DataInputStream stream =
// new DataInputStream(new ByteArrayInputStream(code));
// for (int addr = 0; addr < code.length; ) {
// instr[addr] = Opcodes.readOpcode(addr, stream, this);
// addr = instr[addr].getNextAddr();
// }
// } catch (IOException ex) {
// throw new ClassFormatError(ex.toString());
// }
// for (int addr=0; addr<instr.length; ) {
// instr[addr].resolveJumps(instr);
// addr = instr[addr].getNextAddr();
// }
// handler = new TransformExceptionHandlers(instr);
// for (int i=0; i<handlers.length; i += 4) {
// Type type = null;
// if (handlers[i + 3 ] != 0) {
// CpoolClass cpcls = (CpoolClass)
// method.classAnalyzer.getConstant(handlers[i + 3]);
// type = Type.tClass(cpcls.getName().getString());
// }
// handler.addHandler(handlers[i + 0], handlers[i + 1],
// handlers[i + 2], type);
// }
// methodHeader = instr[0];
// }
public void analyze()
{
byte[] codeArray = code.getCode();
@ -265,7 +229,7 @@ public class CodeAnalyzer implements Analyzer {
return param[slot];
}
public void useClass(Class clazz)
public void useClass(String clazz)
{
env.useClass(clazz);
}
@ -274,7 +238,7 @@ public class CodeAnalyzer implements Analyzer {
return method.classAnalyzer.getTypeString(type);
}
public Class getClazz() {
public ClassHierarchy getClazz() {
return method.classAnalyzer.clazz;
}
}

@ -18,7 +18,7 @@
*/
package jode;
import java.lang.reflect.*;
import java.lang.reflect.Modifier;
import gnu.bytecode.Attribute;
import gnu.bytecode.MiscAttr;
import gnu.bytecode.Spy;

@ -19,6 +19,8 @@
package jode;
import java.util.*;
import jode.bytecode.ClassHierarchy;
import gnu.bytecode.ClassType;
public class JodeEnvironment {
Hashtable imports;
@ -31,16 +33,23 @@ public class JodeEnvironment {
SearchPath classPath;
JodeEnvironment(String path) {
Type.setEnvironment(this);
classPath = new SearchPath(path);
ClassHierarchy.setClassPath(classPath);
Type.setEnvironment(this);
imports = new Hashtable();
/* java.lang is always imported */
imports.put("java.lang.*", new Integer(Integer.MAX_VALUE));
}
public java.io.InputStream getClassStream(Class clazz)
throws java.io.IOException {
return classPath.getFile(clazz.getName().replace('.', '/') + ".class");
public gnu.bytecode.ClassType getClassType(String clazzName) {
try {
return gnu.bytecode.ClassFileInput.readClassType
(classPath.getFile(clazzName.replace('.', '/')
+".class"));
} catch (java.io.IOException ex) {
ex.printStackTrace();
throw new RuntimeException("Class not found.");
}
}
/**
@ -68,22 +77,9 @@ public class JodeEnvironment {
name = name.substring(pkgdelim);
if (pkg.length() != 0) {
try {
Class.forName(pkg + name);
/* UGLY: If class doesn't conflict, above
* Instruction throws an exception and we
* doesn't reach here.
* XXX - Is there a better way to do it ???
*/
// System.err.println(""+pkgName+name
// + " conflicts with "
// + pkg+name);
if (classPath.exists((pkg+name).replace('.', '/')
+ ".class"))
return true;
} catch (ClassNotFoundException ex) {
/* BTW: Exception generation is slow. I'm
* really sad that this is the default.
*/
}
}
Enumeration enum = imports.keys();
@ -94,22 +90,9 @@ public class JodeEnvironment {
importName = importName.substring
(0, importName.length()-2);
if (!importName.equals(pkgName)) {
try {
Class.forName(importName + name);
/* UGLY: If class doesn't conflict, above
* Instruction throws an exception and we
* doesn't reach here.
* XXX - Is there a better way to do it ???
*/
// System.err.println(""+pkgName+name
// + " conflicts with "
// + importName+name);
if (classPath.exists(importName.replace('.', '/')
+ ".class"))
return true;
} catch (ClassNotFoundException ex) {
/* BTW: Exception generation is slow. I'm
* really sad that this is the default.
*/
}
}
}
}
@ -189,12 +172,9 @@ public class JodeEnvironment {
public void doClass(String className)
{
Class clazz;
ClassHierarchy clazz;
try {
clazz = Class.forName(className);
} catch (ClassNotFoundException ex) {
System.err.println("Class `"+className+"' not found");
return;
clazz = ClassHierarchy.forName(className);
} catch (IllegalArgumentException ex) {
System.err.println("`"+className+"' is not a class name");
return;
@ -254,13 +234,6 @@ public class JodeEnvironment {
}
}
/* Marks the clazz as used, so that it will be imported if used often
* enough.
*/
public void useClass(Class clazz) {
useClass(clazz.getName());
}
/**
* Check if clazz is imported and maybe remove package delimiter from
* full qualified class name.
@ -303,10 +276,6 @@ public class JodeEnvironment {
return name;
}
public String classString(Class clazz) {
return classString(clazz.getName());
}
protected int loadFileFlags()
{
return 1;

@ -105,7 +105,8 @@ public class MethodAnalyzer implements Analyzer {
int offset = 0;
if (!isStatic()) {
LocalInfo clazz = code.getParamInfo(0);
clazz.setType(Type.tType(this.classAnalyzer.clazz));
clazz.setType
(Type.tClass(this.classAnalyzer.getClazz().getName()));
clazz.setName("this");
offset++;
}
@ -157,7 +158,8 @@ public class MethodAnalyzer implements Analyzer {
writer.print(""); /* static block */
else {
if (isConstructor)
writer.print(env.classString(classAnalyzer.clazz));
writer.print(env.classString(classAnalyzer.
getClazz().getName()));
else
writer.print(getReturnType().toString()
+ " " + methodName);

@ -58,7 +58,7 @@ public class GetFieldOperator extends Operator {
public String toString(String[] operands) {
return staticFlag
? (classType.equals(Type.tType(codeAnalyzer.getClazz()))
? (classType.equals(Type.tClass(codeAnalyzer.getClazz().getName()))
&& codeAnalyzer.findLocal(fieldName) == null
? fieldName
: classType.toString() + "." + fieldName)

@ -19,6 +19,7 @@
package jode;
import gnu.bytecode.CpoolRef;
import jode.bytecode.ClassHierarchy;
public final class InvokeOperator extends Operator {
CodeAnalyzer codeAnalyzer;
@ -89,34 +90,31 @@ public final class InvokeOperator extends Operator {
}
public boolean isThis() {
Class clazz = codeAnalyzer.method.classAnalyzer.getClazz();
return (classType.equals(Type.tType(clazz)));
return (classType.equals(Type.tClass(codeAnalyzer.method.
classAnalyzer.getClazz().
getName())));
}
public boolean isSuperOrThis() {
Class clazz = codeAnalyzer.method.classAnalyzer.getClazz();
while (clazz != null
&& !classType.equals(Type.tType(clazz))) {
clazz = clazz.getSuperclass();
}
return (clazz != null);
return ((ClassInterfacesType)classType).getClazz().superClassOf
(codeAnalyzer.method.classAnalyzer.getClazz());
}
public String toString(String[] operands) {
String object = null;
if (specialFlag) {
Class clazz = codeAnalyzer.method.classAnalyzer.clazz;
ClassHierarchy clazz = codeAnalyzer.getClazz();
if (operands[0].equals("this")) {
object = "";
while (clazz != null
&& !classType.equals(Type.tType(clazz))) {
&& !classType.equals(Type.tClass(clazz.getName()))) {
object = "super";
clazz = clazz.getSuperclass();
}
if (clazz == null)
object = "NON VIRTUAL this";
} else if (classType.equals(Type.tType(clazz)))
} else if (classType.equals(Type.tClass(clazz.getName())))
object = operands[0];
else
object = "NON VIRTUAL "+operands[0];
@ -124,13 +122,11 @@ public final class InvokeOperator extends Operator {
object = (object != null) ? object
: methodType.isStatic()
? (classType.equals(Type.tType(codeAnalyzer.getClazz()))
? (classType.equals(Type.tClass(codeAnalyzer.getClazz().getName()))
? ""
: classType.toString())
: (operands[0].equals("this")
? (specialFlag &&
classType.equals(Type.tType(codeAnalyzer.getClazz()
.getSuperclass()))
? (specialFlag && isSuperOrThis()
? "super"
: "")
: operands[0]);

@ -68,7 +68,7 @@ public class PutFieldOperator extends StoreInstruction {
public String getLValueString(String[] operands) {
return staticFlag
? (classType.equals(Type.tType(codeAnalyzer.getClazz()))
? (classType.equals(Type.tClass(codeAnalyzer.getClazz().getName()))
&& codeAnalyzer.findLocal(fieldName) == null
? fieldName
: classType.toString() + "." + fieldName)

@ -17,6 +17,7 @@
* $Id$
*/
package jode;
import jode.bytecode.ClassHierarchy;
import java.util.Vector;
import java.util.Stack;
@ -34,70 +35,51 @@ import java.util.Stack;
* @author Jochen Hoenicke */
public class ClassInterfacesType extends Type {
Class clazz;
Class ifaces[];
ClassHierarchy clazz;
ClassHierarchy ifaces[];
public ClassHierarchy getClazz() {
return clazz;
}
public final static Class cObject = new Object().getClass();
public ClassInterfacesType(String clazzName) {
super(TC_CLASS);
try {
Class clazz = Class.forName(clazzName);
if (clazz.isInterface()) {
this.clazz = null;
ifaces = new Class[] {clazz};
} else {
this.clazz = (clazz == cObject) ? null : clazz;
ifaces = new Class[0];
}
} catch (ClassNotFoundException ex) {
throw new AssertError(ex.toString());
ClassHierarchy clazz = ClassHierarchy.forName(clazzName);
if (clazz.isInterface()) {
this.clazz = null;
ifaces = new ClassHierarchy[] {clazz};
} else {
this.clazz =
(clazz == ClassHierarchy.javaLangObject) ? null : clazz;
ifaces = new ClassHierarchy[0];
}
}
public ClassInterfacesType(Class clazz) {
public ClassInterfacesType(ClassHierarchy clazz) {
super(TC_CLASS);
if (clazz.isInterface()) {
this.clazz = null;
ifaces = new Class[] { clazz };
ifaces = new ClassHierarchy[] { clazz };
} else {
this.clazz = (clazz == cObject) ? null : clazz;
ifaces = new Class[0];
this.clazz =
(clazz == ClassHierarchy.javaLangObject) ? null : clazz;
ifaces = new ClassHierarchy[0];
}
}
public ClassInterfacesType(Class clazz, Class[] ifaces) {
public ClassInterfacesType(ClassHierarchy clazz, ClassHierarchy[] ifaces) {
super(TC_CLASS);
this.clazz = clazz;
this.ifaces = ifaces;
}
private static Type create(Class clazz, Class[] ifaces) {
private static Type create(ClassHierarchy clazz, ClassHierarchy[] ifaces) {
/* Make sure that every {java.lang.Object} equals tObject */
if (ifaces.length == 0 && clazz == null)
return tObject;
return new ClassInterfacesType(clazz, ifaces);
}
public final static boolean superClassOf(Class parent, Class clazz) {
while (clazz != parent && clazz != null) {
clazz = clazz.getSuperclass();
}
return clazz == parent;
}
public final static boolean implementedBy(Class iface, Class clazz) {
while (clazz != iface && clazz != null) {
Class[] ifaces = clazz.getInterfaces();
for (int i=0; i< ifaces.length; i++) {
if (implementedBy(iface, ifaces[i]))
return true;
}
clazz = clazz.getSuperclass();
}
return clazz != null;
}
/**
* Create the type corresponding to the range from bottomType to
* this. Checks if the given type range may be not empty. This
@ -121,13 +103,13 @@ public class ClassInterfacesType extends Type {
/* The searched type must be a class type.
*/
if (this.ifaces.length != 0
|| !superClassOf(bottom.clazz,this.clazz))
|| !bottom.clazz.superClassOf(this.clazz))
return tError;
/* All interfaces must be implemented by this.clazz
*/
for (int i=0; i < bottom.ifaces.length; i++) {
if (!implementedBy(bottom.ifaces[i], this.clazz))
if (!bottom.ifaces[i].implementedBy(this.clazz))
return tError;
}
@ -143,10 +125,10 @@ public class ClassInterfacesType extends Type {
* classes/interfaces that implement all bottom.ifaces.
*/
Class clazz = this.clazz;
ClassHierarchy clazz = this.clazz;
if (clazz != null) {
for (int i=0; i < bottom.ifaces.length; i++) {
if (!implementedBy(bottom.ifaces[i], clazz)) {
if (!bottom.ifaces[i].implementedBy(clazz)) {
clazz = null;
break;
}
@ -163,19 +145,19 @@ public class ClassInterfacesType extends Type {
}
}
Class[] ifaces = new Class[this.ifaces.length];
ClassHierarchy[] ifaces = new ClassHierarchy[this.ifaces.length];
int count = 0;
big_loop:
for (int j=0; j < this.ifaces.length; j++) {
for (int i=0; i < bottom.ifaces.length; i++) {
if (!implementedBy(bottom.ifaces[i], this.ifaces[j]))
if (!bottom.ifaces[i].implementedBy(this.ifaces[j]))
continue big_loop;
}
ifaces[count++] = (this.ifaces[j]);
}
if (count < ifaces.length) {
Class[] shortIfaces = new Class[count];
ClassHierarchy[] shortIfaces = new ClassHierarchy[count];
System.arraycopy(ifaces, 0, shortIfaces, 0, count);
ifaces = shortIfaces;
} else if (clazz == this.clazz)
@ -184,14 +166,14 @@ public class ClassInterfacesType extends Type {
}
}
private boolean implementsAllIfaces(Class[] otherIfaces) {
private boolean implementsAllIfaces(ClassHierarchy[] otherIfaces) {
big:
for (int i=0; i < otherIfaces.length; i++) {
Class iface = otherIfaces[i];
if (clazz != null && implementedBy(iface, clazz))
ClassHierarchy iface = otherIfaces[i];
if (clazz != null && iface.implementedBy(clazz))
continue big;
for (int j=0; j < this.ifaces.length; j++) {
if (implementedBy(iface, ifaces[j]))
if (iface.implementedBy(ifaces[j]))
continue big;
}
return false;
@ -215,7 +197,7 @@ public class ClassInterfacesType extends Type {
return tError;
ClassInterfacesType other = (ClassInterfacesType) type;
Class clazz;
ClassHierarchy clazz;
/* First determine the clazz, one of the two classes must be a sub
* class of the other or null.
@ -225,9 +207,9 @@ public class ClassInterfacesType extends Type {
clazz = other.clazz;
else if (other.clazz == null)
clazz = this.clazz;
else if (superClassOf(this.clazz, other.clazz))
else if (this.clazz.superClassOf(other.clazz))
clazz = other.clazz;
else if (superClassOf(other.clazz, this.clazz))
else if (other.clazz.superClassOf(this.clazz))
clazz = this.clazz;
else
return tError;
@ -249,12 +231,12 @@ public class ClassInterfacesType extends Type {
Vector ifaces = new Vector();
big_loop_this:
for (int i=0; i< this.ifaces.length; i++) {
Class iface = this.ifaces[i];
if (clazz != null && implementedBy(iface, clazz)) {
ClassHierarchy iface = this.ifaces[i];
if (clazz != null && iface.implementedBy(clazz)) {
continue big_loop_this;
}
for (int j=0; j<other.ifaces.length; j++) {
if (implementedBy(iface, other.ifaces[j])) {
if (iface.implementedBy(other.ifaces[j])) {
continue big_loop_this;
}
}
@ -266,12 +248,13 @@ public class ClassInterfacesType extends Type {
}
big_loop_other:
for (int i=0; i< other.ifaces.length; i++) {
Class iface = other.ifaces[i];
if (clazz != null && implementedBy(iface, clazz)) {
ClassHierarchy iface = other.ifaces[i];
if (clazz != null && iface.implementedBy(clazz)) {
continue big_loop_other;
}
for (int j=0; j<ifaces.size(); j++) {
if (implementedBy(iface, (Class) ifaces.elementAt(j))) {
if (iface.implementedBy((ClassHierarchy)
ifaces.elementAt(j))) {
continue big_loop_other;
}
}
@ -282,7 +265,7 @@ public class ClassInterfacesType extends Type {
ifaces.addElement(iface);
}
Class[] ifaceArray = new Class[ifaces.size()];
ClassHierarchy[] ifaceArray = new ClassHierarchy[ifaces.size()];
ifaces.copyInto(ifaceArray);
return create(clazz, ifaceArray);
}
@ -302,7 +285,7 @@ public class ClassInterfacesType extends Type {
if (code != TC_CLASS)
return tError;
ClassInterfacesType other = (ClassInterfacesType) type;
Class clazz;
ClassHierarchy clazz;
/* First the easy part, determine the clazz */
if (this.clazz == null || other.clazz == null)
@ -311,11 +294,11 @@ public class ClassInterfacesType extends Type {
clazz = this.clazz;
while(clazz != null) {
if (superClassOf(clazz, other.clazz))
if (clazz.superClassOf(other.clazz))
break;
clazz = clazz.getSuperclass();
}
if (clazz == cObject)
if (clazz == ClassHierarchy.javaLangObject)
clazz = null;
}
@ -334,9 +317,9 @@ public class ClassInterfacesType extends Type {
Stack allIfaces = new Stack();
if (this.clazz != null) {
Class c = this.clazz;
ClassHierarchy c = this.clazz;
while (clazz != c) {
Class clazzIfaces[] = c.getInterfaces();
ClassHierarchy clazzIfaces[] = c.getInterfaces();
for (int i=0; i<clazzIfaces.length; i++)
allIfaces.push(clazzIfaces[i]);
c = c.getSuperclass();
@ -354,19 +337,19 @@ public class ClassInterfacesType extends Type {
*/
iface_loop:
while (!allIfaces.isEmpty()) {
Class iface = (Class) allIfaces.pop();
if ((clazz != null && implementedBy(iface, clazz))
ClassHierarchy iface = (ClassHierarchy) allIfaces.pop();
if ((clazz != null && iface.implementedBy(clazz))
|| ifaces.contains(iface))
/* We can skip this, as clazz or ifaces already imply it.
*/
continue iface_loop;
if (other.clazz != null && implementedBy(iface, other.clazz)) {
if (other.clazz != null && iface.implementedBy(other.clazz)) {
ifaces.addElement(iface);
continue iface_loop;
}
for (int i=0; i<other.ifaces.length; i++) {
if (implementedBy(iface, other.ifaces[i])) {
if (iface.implementedBy(other.ifaces[i])) {
ifaces.addElement(iface);
continue iface_loop;
}
@ -375,12 +358,12 @@ public class ClassInterfacesType extends Type {
/* This interface is not implemented by any of the other
* ifaces. Try its parent interfaces now.
*/
Class clazzIfaces[] = iface.getInterfaces();
ClassHierarchy clazzIfaces[] = iface.getInterfaces();
for (int i=0; i<clazzIfaces.length; i++)
allIfaces.push(clazzIfaces[i]);
}
Class[] ifaceArray = new Class[ifaces.size()];
ClassHierarchy[] ifaceArray = new ClassHierarchy[ifaces.size()];
ifaces.copyInto(ifaceArray);
return create(clazz, ifaceArray);
}
@ -391,9 +374,9 @@ public class ClassInterfacesType extends Type {
public void useType() {
if (!jode.Decompiler.isTypeDebugging) {
if (clazz != null)
env.useClass(clazz);
env.useClass(clazz.getName());
else if (ifaces.length > 0)
env.useClass(ifaces[0]);
env.useClass(ifaces[0].getName());
}
}
@ -415,11 +398,11 @@ public class ClassInterfacesType extends Type {
return sb.append("}").toString();
} else {
if (clazz != null)
return env.classString(clazz);
return env.classString(clazz.getName());
else if (ifaces.length > 0)
return env.classString(ifaces[0]);
return env.classString(ifaces[0].getName());
else
return env.classString(cObject);
return env.classString("java.lang.Object");
}
}
@ -428,13 +411,13 @@ public class ClassInterfacesType extends Type {
}
public String getDefaultName() {
Class type;
ClassHierarchy type;
if (clazz != null)
type = clazz;
else if (ifaces.length > 0)
type = ifaces[0];
else
type = cObject;
type = ClassHierarchy.javaLangObject;
String name = type.getName();
int dot = name.lastIndexOf('.');
if (dot >= 0)

@ -28,15 +28,6 @@ public class MethodType {
final Type returnType;
final boolean staticFlag;
public MethodType(boolean isStatic, Class[] argTypes, Class retType) {
this.staticFlag = isStatic;
parameterTypes = new Type[argTypes.length];
for (int i=0; i < argTypes.length; i++)
parameterTypes[i] = Type.tType(argTypes[i]);
returnType = Type.tType(retType);
}
public MethodType(boolean isStatic, String signature) {
this.staticFlag = isStatic;
int index = 1, types = 0;

@ -144,34 +144,11 @@ public class Type {
throw new AssertError("Unknown type signature: "+type);
}
public static final Type tType(Class clazz) {
if (clazz.isArray())
return tArray(tType(clazz.getComponentType()));
if (clazz.isPrimitive()) {
return clazz == Boolean.TYPE ? tBoolean
: clazz == Byte.TYPE ? tByte
: clazz == Character.TYPE ? tChar
: clazz == Short.TYPE ? tShort
: clazz == Integer.TYPE ? tInt
: clazz == Float.TYPE ? tFloat
: clazz == Long.TYPE ? tLong
: clazz == Double.TYPE ? tDouble
: clazz == Void.TYPE ? tVoid
: tError;
}
return new ClassInterfacesType(clazz);
}
public static final Type tClass(String clazzname) {
clazzname = clazzname.replace('/', '.');
Object result = classHash.get(clazzname);
if (result == null) {
try {
Class clazz = Class.forName(clazzname);
result = new ClassInterfacesType(clazzname);
} catch (ClassNotFoundException ex) {
result = new UnfoundClassType(clazzname);
}
result = new ClassInterfacesType(clazzname);
classHash.put(clazzname, result);
}
return (Type) result;

Loading…
Cancel
Save