Commit 2cad946d authored by Lukáš Marek's avatar Lukáš Marek

Testing case for class info

parent 2a54d0ed
......@@ -346,6 +346,16 @@ static jlong get_class_loader_net_ref(jobject loader, JNIEnv * jni_env) {
// normal class loader id handling
// TODO tagging_lock has to be used around this
// we cannot use different lock because we can be called with or without
// tagging lock but we require tagging lock in get_net_reference
// assume we use class_loader_lock here
// t1 calls get_class_loader_net_ref and gets class_loader_lock
// t2 calls directly get_net_reference and gets tagging_lock
// t1 waits in get_net_reference for tagging_lock
// t2 waits in get_class_loader_net_ref
// (called from _set_net_reference_for_class) for class_loader_lock
jlong loader_id = get_net_reference(loader, jni_env);
// if spec is not set, check generated ids
......@@ -355,6 +365,8 @@ static jlong get_class_loader_net_ref(jobject loader, JNIEnv * jni_env) {
// set spec flag
net_ref_set_spec(&loader_id, 1);
// TODO set tag
}
return loader_id;
......@@ -438,6 +450,8 @@ static jlong _set_net_reference_for_class(jclass klass, JNIEnv * jni_env) {
// TODO if you do one more getObjectClass then you (maybe) get another class
// they should share same id
// - maybe solve this on server
// - you have to because Class<?> can be send first
// assign new net reference - set spec to 1 (binding send over network)
jlong net_ref = _set_net_reference(klass, jni_env, avail_object_id,
......
......@@ -34,6 +34,16 @@ public class ClassInfoResolver {
String classGenericStr, NetReference classLoaderNR, int classId,
int superClassId) {
// create asm type to get class name
Type classASMType = Type.getType(classSignature);
if (classASMType.getSort() != Type.OBJECT
&& classASMType.getSort() != Type.ARRAY) {
// TODO re ! basic types
System.out.println("Basic type not handled: " + classSignature);
return;
}
Map<String, ExtractedClassInfo> classNameMap =
classLoaderMap.get(classLoaderNR.getObjectId());
......@@ -41,9 +51,6 @@ public class ClassInfoResolver {
throw new DiSLREServerFatalException("Class loader not known");
}
// create asm type to get class name
Type classASMType = Type.getType(classSignature);
ExtractedClassInfo eci =
classNameMap.get(classASMType.getInternalName());
......@@ -53,7 +60,8 @@ public class ClassInfoResolver {
classNameMap = classLoaderMap.get(new Long(0)); // something will be there
eci = classNameMap.get(classASMType.getInternalName());
if(eci == null) {
throw new DiSLREServerFatalException("Class not known");
System.err.println("Class not known: " + classASMType.getInternalName());
return;
}
// TODO re ! replace with this
......
......@@ -88,6 +88,12 @@ public class AnalysisResolver {
Method m3 = CodeExecuted.class.getMethod("testingAdvanced",
String.class, Object.class, Class.class, int.class);
registerMethod(3, new AnalysisMethodHolder((RemoteAnalysis)i, m3));
Method m4 = CodeExecuted.class.getMethod("testingAdvanced2",
Object.class, Object.class, Object.class, Object.class,
Class.class, int.class, Class.class, int.class,
Class.class, int.class, Class.class, int.class);
registerMethod(4, new AnalysisMethodHolder((RemoteAnalysis)i, m4));
} catch (Exception e) {
e.printStackTrace();
......
package ch.usi.dag.disl.test.dispatch;
import ch.usi.dag.dislreserver.classinfo.ClassInfo;
import ch.usi.dag.dislreserver.classinfo.ClassInfoResolver;
import ch.usi.dag.dislreserver.classinfo.InvalidClass;
import ch.usi.dag.dislreserver.netreference.NetReference;
import ch.usi.dag.dislreserver.remoteanalysis.RemoteAnalysis;
......@@ -73,6 +75,46 @@ public class CodeExecuted extends RemoteAnalysis {
System.out.println("Received class id: " + classId);
}
public static void printClassInfo(ClassInfo ci) {
if(ci == null) {
System.out.println("null");
return;
}
System.out.println("sig: " + ci.getClassSignature());
System.out.println("gen: " + ci.getClassGenericStr());
}
public static void testingAdvanced2(Object o1, Object o2, Object o3,
Object o4, Class<?> class1, int cid1, Class<?> class2, int cid2,
Class<?> class3, int cid3, Class<?> class4, int cid4) {
System.out.println("* o1 class *");
printClassInfo(((NetReference)o1).getClassInfo());
System.out.println("* o2 class *");
printClassInfo(((NetReference)o2).getClassInfo());
System.out.println("* o3 class *");
printClassInfo(((NetReference)o3).getClassInfo());
System.out.println("* o4 class *");
printClassInfo(((NetReference)o3).getClassInfo());
System.out.println("* class 1 *");
printClassInfo(ClassInfoResolver.getClass(cid1));
System.out.println("* class 2 *");
printClassInfo(ClassInfoResolver.getClass(cid2));
System.out.println("* class 3 *");
printClassInfo(ClassInfoResolver.getClass(cid3));
System.out.println("* class 4 *");
printClassInfo(ClassInfoResolver.getClass(cid4));
}
public void atExit() {
System.out.println("Total number of executed bytecodes: "
+ totalExecutedBytecodes);
......
......@@ -35,7 +35,8 @@ public class CodeExecutedRE {
REDispatch.analysisEnd(sid);
}
public static void testingAdvanced(String s, Object o, Class<?> c, int classID) {
public static void testingAdvanced(String s, Object o, Class<?> c,
int classID) {
int sid = REDispatch.analysisStart(3);
......@@ -46,4 +47,26 @@ public class CodeExecutedRE {
REDispatch.analysisEnd(sid);
}
public static void testingAdvanced2(Object o1, Object o2, Object o3,
Object o4, Class<?> class1, int cid1, Class<?> class2, int cid2,
Class<?> class3, int cid3, Class<?> class4, int cid4) {
int sid = REDispatch.analysisStart(4);
REDispatch.sendObject(sid, o1);
REDispatch.sendObject(sid, o2);
REDispatch.sendObject(sid, o3);
REDispatch.sendObject(sid, o4);
REDispatch.sendClass(sid, class1);
// class_id ignored
REDispatch.sendClass(sid, class2);
// class_id ignored
REDispatch.sendClass(sid, class3);
// class_id ignored
REDispatch.sendClass(sid, class4);
// class_id ignored
REDispatch.analysisEnd(sid);
}
}
package ch.usi.dag.disl.test.dispatch;
import java.util.LinkedList;
import ch.usi.dag.disl.annotation.After;
import ch.usi.dag.disl.marker.BasicBlockMarker;
import ch.usi.dag.disl.marker.BodyMarker;
......@@ -19,5 +21,10 @@ public class DiSLClass {
100000, 10000000000L, 1.5F, 2.5);
CodeExecutedRE.testingAdvanced("ěščřžýáíé", new Object(), Object.class, 0);
CodeExecutedRE.testingAdvanced2(new LinkedList<String>(),
new LinkedList<Integer>(), new LinkedList[0], new int[0],
int[].class, 0, int.class, 0, LinkedList.class, 0,
LinkedList.class.getClass(), 0);
}
}
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