Use gnu.bytecode directly

git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@99 379699f6-c40d-0410-875b-85095c16579e
stable
jochen 26 years ago
parent 3136614896
commit 37d77aeb6e
  1. 35
      jode/jode/decompiler/ClassAnalyzer.java

@ -18,19 +18,21 @@
*/ */
package jode; package jode;
import java.lang.reflect.*; import java.lang.reflect.Modifier;
import gnu.bytecode.ClassType; import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Constructor;
import gnu.bytecode.ConstantPool; import gnu.bytecode.ConstantPool;
import gnu.bytecode.CpoolEntry; import gnu.bytecode.CpoolEntry;
import gnu.bytecode.CpoolString;
import gnu.bytecode.CpoolValue1; import gnu.bytecode.CpoolValue1;
import gnu.bytecode.CpoolValue2; import gnu.bytecode.CpoolValue2;
import gnu.bytecode.CpoolString;
public class ClassAnalyzer implements Analyzer { public class ClassAnalyzer implements Analyzer {
JodeEnvironment env; JodeEnvironment env;
Analyzer[] analyzers; Analyzer[] analyzers;
Class clazz; Class clazz;
ClassType classType; gnu.bytecode.ClassType classType;
ClassAnalyzer parent; ClassAnalyzer parent;
public ClassAnalyzer(ClassAnalyzer parent, Class clazz, public ClassAnalyzer(ClassAnalyzer parent, Class clazz,
@ -52,25 +54,21 @@ public class ClassAnalyzer implements Analyzer {
int i = 0; int i = 0;
Field[] fields = clazz.getDeclaredFields(); Field[] fields = clazz.getDeclaredFields();
Method[] methods = clazz.getDeclaredMethods();
Constructor[] constrs = clazz.getDeclaredConstructors();
analyzers = new Analyzer[fields.length + methods.length analyzers = new Analyzer[fields.length +
+ constrs.length]; classType.getMethodCount()];
for (int j=0; j< fields.length; j++) { for (int j=0; j< fields.length; j++) {
analyzers[i] = new FieldAnalyzer(this, fields[j], env); analyzers[i] = new FieldAnalyzer(this, fields[j], env);
analyzers[i++].analyze(); analyzers[i++].analyze();
} }
for (int j=0; j< constrs.length; j++) { for (gnu.bytecode.Method method = classType.getMethods();
analyzers[i] = new MethodAnalyzer(this, constrs[j], env); method != null; method = method.getNext()) {
analyzers[i++].analyze(); analyzers[i] = new MethodAnalyzer(this, method, env);
}
for (int j=0; j< methods.length; j++) {
analyzers[i] = new MethodAnalyzer(this, methods[j], env);
analyzers[i++].analyze(); analyzers[i++].analyze();
} }
env.useClass(clazz); env.useClass(clazz);
if (clazz.getSuperclass() != null) if (clazz.getSuperclass() != null)
env.useClass(clazz.getSuperclass()); env.useClass(clazz.getSuperclass());
@ -88,7 +86,9 @@ public class ClassAnalyzer implements Analyzer {
& ~Modifier.SYNCHRONIZED); & ~Modifier.SYNCHRONIZED);
if (modif.length() > 0) if (modif.length() > 0)
writer.print(modif + " "); writer.print(modif + " ");
writer.print(clazz.isInterface() ? "interface " : "class "); writer.print(clazz.isInterface()
? ""/*interface is in modif*/
: "class ");
writer.println(env.classString(clazz)); writer.println(env.classString(clazz));
writer.tab(); writer.tab();
Class superClazz = clazz.getSuperclass(); Class superClazz = clazz.getSuperclass();
@ -115,11 +115,6 @@ public class ClassAnalyzer implements Analyzer {
writer.println("}"); writer.println("}");
} }
public ConstantPool getConstantPool() {
return classType.getConstants();
}
public CpoolEntry getConstant(int i) { public CpoolEntry getConstant(int i) {
return classType.getConstant(i); return classType.getConstant(i);
} }

Loading…
Cancel
Save