|
|
@ -18,7 +18,7 @@ |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
package jode.decompiler; |
|
|
|
package jode.decompiler; |
|
|
|
import jode.*; |
|
|
|
import jode.type.*; |
|
|
|
import jode.bytecode.ClassInfo; |
|
|
|
import jode.bytecode.ClassInfo; |
|
|
|
import jode.bytecode.FieldInfo; |
|
|
|
import jode.bytecode.FieldInfo; |
|
|
|
import jode.bytecode.MethodInfo; |
|
|
|
import jode.bytecode.MethodInfo; |
|
|
@ -30,7 +30,7 @@ import java.util.NoSuchElementException; |
|
|
|
import java.lang.reflect.Modifier; |
|
|
|
import java.lang.reflect.Modifier; |
|
|
|
|
|
|
|
|
|
|
|
public class ClassAnalyzer implements Analyzer { |
|
|
|
public class ClassAnalyzer implements Analyzer { |
|
|
|
JodeEnvironment env; |
|
|
|
ImportHandler imports; |
|
|
|
FieldAnalyzer[] fields; |
|
|
|
FieldAnalyzer[] fields; |
|
|
|
MethodAnalyzer[] methods; |
|
|
|
MethodAnalyzer[] methods; |
|
|
|
MethodAnalyzer staticConstructor; |
|
|
|
MethodAnalyzer staticConstructor; |
|
|
@ -40,12 +40,12 @@ public class ClassAnalyzer implements Analyzer { |
|
|
|
ClassAnalyzer parent; |
|
|
|
ClassAnalyzer parent; |
|
|
|
|
|
|
|
|
|
|
|
public ClassAnalyzer(ClassAnalyzer parent, ClassInfo clazz, |
|
|
|
public ClassAnalyzer(ClassAnalyzer parent, ClassInfo clazz, |
|
|
|
JodeEnvironment env) |
|
|
|
ImportHandler imports) |
|
|
|
{ |
|
|
|
{ |
|
|
|
clazz.loadInfo(clazz.FULLINFO); |
|
|
|
clazz.loadInfo(clazz.FULLINFO); |
|
|
|
this.parent = parent; |
|
|
|
this.parent = parent; |
|
|
|
this.clazz = clazz; |
|
|
|
this.clazz = clazz; |
|
|
|
this.env = env; |
|
|
|
this.imports = imports; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public FieldAnalyzer getField(String fieldName, Type fieldType) { |
|
|
|
public FieldAnalyzer getField(String fieldName, Type fieldType) { |
|
|
@ -88,14 +88,14 @@ public class ClassAnalyzer implements Analyzer { |
|
|
|
fields = new FieldAnalyzer[finfos.length]; |
|
|
|
fields = new FieldAnalyzer[finfos.length]; |
|
|
|
methods = new MethodAnalyzer[minfos.length]; |
|
|
|
methods = new MethodAnalyzer[minfos.length]; |
|
|
|
for (int j=0; j < finfos.length; j++) { |
|
|
|
for (int j=0; j < finfos.length; j++) { |
|
|
|
fields[j] = new FieldAnalyzer(this, finfos[j], env); |
|
|
|
fields[j] = new FieldAnalyzer(this, finfos[j], imports); |
|
|
|
fields[j].analyze(); |
|
|
|
fields[j].analyze(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
staticConstructor = null; |
|
|
|
staticConstructor = null; |
|
|
|
java.util.Vector constrVector = new java.util.Vector(); |
|
|
|
java.util.Vector constrVector = new java.util.Vector(); |
|
|
|
for (int j=0; j < methods.length; j++) { |
|
|
|
for (int j=0; j < methods.length; j++) { |
|
|
|
methods[j] = new MethodAnalyzer(this, minfos[j], env); |
|
|
|
methods[j] = new MethodAnalyzer(this, minfos[j], imports); |
|
|
|
|
|
|
|
|
|
|
|
if (methods[j].isConstructor()) { |
|
|
|
if (methods[j].isConstructor()) { |
|
|
|
if (methods[j].isStatic()) |
|
|
|
if (methods[j].isStatic()) |
|
|
@ -121,12 +121,12 @@ public class ClassAnalyzer implements Analyzer { |
|
|
|
TransformConstructors.transform(this, true, new MethodAnalyzer[] |
|
|
|
TransformConstructors.transform(this, true, new MethodAnalyzer[] |
|
|
|
{ staticConstructor }); |
|
|
|
{ staticConstructor }); |
|
|
|
|
|
|
|
|
|
|
|
env.useClass(clazz.getName()); |
|
|
|
imports.useClass(clazz); |
|
|
|
if (clazz.getSuperclass() != null) |
|
|
|
if (clazz.getSuperclass() != null) |
|
|
|
env.useClass(clazz.getSuperclass().getName()); |
|
|
|
imports.useClass(clazz.getSuperclass()); |
|
|
|
ClassInfo[] interfaces = clazz.getInterfaces(); |
|
|
|
ClassInfo[] interfaces = clazz.getInterfaces(); |
|
|
|
for (int j=0; j< interfaces.length; j++) |
|
|
|
for (int j=0; j< interfaces.length; j++) |
|
|
|
env.useClass(interfaces[j].getName()); |
|
|
|
imports.useClass(interfaces[j]); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void dumpSource(TabbedPrintWriter writer) throws java.io.IOException |
|
|
|
public void dumpSource(TabbedPrintWriter writer) throws java.io.IOException |
|
|
@ -143,12 +143,12 @@ public class ClassAnalyzer implements Analyzer { |
|
|
|
writer.print(modif + " "); |
|
|
|
writer.print(modif + " "); |
|
|
|
writer.print(clazz.isInterface() |
|
|
|
writer.print(clazz.isInterface() |
|
|
|
? ""/*interface is in modif*/ : "class "); |
|
|
|
? ""/*interface is in modif*/ : "class "); |
|
|
|
writer.println(env.classString(clazz.getName())); |
|
|
|
writer.println(imports.getClassString(clazz)); |
|
|
|
writer.tab(); |
|
|
|
writer.tab(); |
|
|
|
ClassInfo superClazz = clazz.getSuperclass(); |
|
|
|
ClassInfo superClazz = clazz.getSuperclass(); |
|
|
|
if (superClazz != null && |
|
|
|
if (superClazz != null && |
|
|
|
superClazz != ClassInfo.javaLangObject) { |
|
|
|
superClazz != ClassInfo.javaLangObject) { |
|
|
|
writer.println("extends "+env.classString(superClazz.getName())); |
|
|
|
writer.println("extends "+imports.getClassString(superClazz)); |
|
|
|
} |
|
|
|
} |
|
|
|
ClassInfo[] interfaces = clazz.getInterfaces(); |
|
|
|
ClassInfo[] interfaces = clazz.getInterfaces(); |
|
|
|
if (interfaces.length > 0) { |
|
|
|
if (interfaces.length > 0) { |
|
|
@ -156,7 +156,7 @@ public class ClassAnalyzer implements Analyzer { |
|
|
|
for (int i=0; i < interfaces.length; i++) { |
|
|
|
for (int i=0; i < interfaces.length; i++) { |
|
|
|
if (i > 0) |
|
|
|
if (i > 0) |
|
|
|
writer.print(", "); |
|
|
|
writer.print(", "); |
|
|
|
writer.print(env.classString(interfaces[i].getName())); |
|
|
|
writer.print(imports.getClassString(interfaces[i])); |
|
|
|
} |
|
|
|
} |
|
|
|
writer.println(""); |
|
|
|
writer.println(""); |
|
|
|
} |
|
|
|
} |
|
|
|