Commit 00afa127 authored by Yudi Zheng's avatar Yudi Zheng

ShadowClass.getShadowClass will return a ShadowClass instance that is created in the analysis VM

Bug Fixed: ShadowCommonClass.getInterfaces
parent 3bc34f8c
package ch.usi.dag.dislreserver.shadow;
import java.io.IOException;
import java.util.concurrent.ConcurrentHashMap;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.Type;
import ch.usi.dag.dislreserver.exception.DiSLREServerFatalException;
public class ShadowClassTable {
final static ShadowObject BOOTSTRAP_CLASSLOADER = new ShadowObject(0, null);
final static ShadowObject BOOTSTRAP_CLASSLOADER;
static ShadowClass JAVA_LANG_CLASS;
private static ConcurrentHashMap<ShadowObject, ConcurrentHashMap<String, byte[]>> classLoaderMap;
private static ConcurrentHashMap<Integer, ShadowClass> shadowClasses;
static {
BOOTSTRAP_CLASSLOADER = new ShadowObject(0, null);
try {
ClassReader cr = new ClassReader("java.lang.Class");
ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS
| ClassWriter.COMPUTE_FRAMES);
cr.accept(cw, ClassReader.SKIP_DEBUG | ClassReader.EXPAND_FRAMES);
JAVA_LANG_CLASS = new ShadowCommonClass(0, "Ljava/lang/Class;",
BOOTSTRAP_CLASSLOADER, null, cw.toByteArray());
} catch (IOException e) {
JAVA_LANG_CLASS = null;
}
classLoaderMap = new ConcurrentHashMap<ShadowObject, ConcurrentHashMap<String, byte[]>>();
shadowClasses = new ConcurrentHashMap<Integer, ShadowClass>();
......@@ -82,8 +100,8 @@ public class ShadowClassTable {
+ t.getClassName() + " has not been loaded");
}
klass = new ShadowCommonClass(net_ref, classSignature,
classGenericStr, loader, superClass, classCode);
klass = new ShadowCommonClass(net_ref, classSignature, loader,
superClass, classCode);
} else {
klass = new ShadowPrimitiveClass(net_ref, loader, t);
......
......@@ -24,16 +24,12 @@ class ShadowCommonClass extends ShadowClass {
private int access;
private String name;
private String classGenericStr;
ShadowCommonClass(long net_ref, String classSignature,
String classGenericStr, ShadowObject classLoader,
ShadowClass superClass, byte[] classCode) {
ShadowObject classLoader, ShadowClass superClass, byte[] classCode) {
super(net_ref, classLoader);
this.classGenericStr = classGenericStr;
this.superClass = superClass;
if (classCode == null || classCode.length == 0) {
throw new DiSLREServerFatalException("Creating class info for "
+ classSignature + " with no code provided");
......@@ -173,19 +169,7 @@ class ShadowCommonClass extends ShadowClass {
@Override
public String[] getInterfaces() {
if (isInterface()) {
return new String[] { classGenericStr };
} else {
int index = classGenericStr.indexOf(':');
if (index == -1) {
return new String[0];
} else {
String interfaces = classGenericStr.substring(index + 1);
return interfaces.split(":");
}
}
return classNode.interfaces.toArray(new String[0]);
}
@Override
......
......@@ -35,7 +35,12 @@ public class ShadowObject implements Formattable {
public ShadowClass getShadowClass () {
return shadowClass;
if (shadowClass != null) {
return shadowClass;
} else {
return ShadowClassTable.JAVA_LANG_CLASS;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment