From 1172c72832839452e2428cfa2923d659f0a951c9 Mon Sep 17 00:00:00 2001 From: jochen Date: Tue, 24 Nov 1998 21:23:30 +0000 Subject: [PATCH] Remove java.lang.reflect code git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@130 379699f6-c40d-0410-875b-85095c16579e --- jode/jode/bytecode/SearchPath.java | 20 ++++ jode/jode/decompiler/ClassAnalyzer.java | 38 +++--- jode/jode/decompiler/CodeAnalyzer.java | 42 +------ jode/jode/decompiler/FieldAnalyzer.java | 2 +- jode/jode/decompiler/ImportHandler.java | 69 +++-------- jode/jode/decompiler/MethodAnalyzer.java | 6 +- jode/jode/expr/GetFieldOperator.java | 2 +- jode/jode/expr/InvokeOperator.java | 26 ++--- jode/jode/expr/PutFieldOperator.java | 2 +- jode/jode/type/ClassInterfacesType.java | 141 ++++++++++------------- jode/jode/type/MethodType.java | 9 -- jode/jode/type/Type.java | 25 +--- 12 files changed, 139 insertions(+), 243 deletions(-) diff --git a/jode/jode/bytecode/SearchPath.java b/jode/jode/bytecode/SearchPath.java index 72f08e9..0b8f0aa 100644 --- a/jode/jode/bytecode/SearchPath.java +++ b/jode/jode/bytecode/SearchPath.java @@ -59,6 +59,26 @@ public class SearchPath { } } + public boolean exists(String filename) { + for (int i=0; i 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(""); } diff --git a/jode/jode/decompiler/CodeAnalyzer.java b/jode/jode/decompiler/CodeAnalyzer.java index 444dfe2..fae470a 100644 --- a/jode/jode/decompiler/CodeAnalyzer.java +++ b/jode/jode/decompiler/CodeAnalyzer.java @@ -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 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) diff --git a/jode/jode/type/MethodType.java b/jode/jode/type/MethodType.java index 7f77ef4..6fddaff 100644 --- a/jode/jode/type/MethodType.java +++ b/jode/jode/type/MethodType.java @@ -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; diff --git a/jode/jode/type/Type.java b/jode/jode/type/Type.java index f22efd4..5fc9999 100644 --- a/jode/jode/type/Type.java +++ b/jode/jode/type/Type.java @@ -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;