Serialization handling - see github issue #24

This commit is contained in:
Andy Clement
2014-03-11 12:39:34 -07:00
parent 4bd2f93d71
commit 513257a84d
27 changed files with 1704 additions and 58 deletions

View File

@@ -0,0 +1,29 @@
package system;
import java.lang.reflect.Method;
/*
* Method.invoke(instance, arguments)
*
* This test class represents a class in the system set for the VM. These classes cannot have their reflective calls directly
* intercepted because we cannot introduce dependencies on types in a lower classloader, so we have to call the reflective
* interceptor reflectively!
*/
public class Eleven {
public String runIt() throws Exception {
StringBuilder data = new StringBuilder();
Object obj = invoke(new Eleven(),12,"abc");
data.append("obj="+obj);
return "complete:" + data.toString().trim();
}
public static Object invoke(Object instance, Object... args) throws Exception {
Method m = Eleven.class.getDeclaredMethod("foo", Integer.TYPE,String.class);
return m.invoke(instance,args);
}
public String foo(int i, String s) {
return "i="+i+":s="+s;
}
}

28
testdata/src/main/java/system/Ten.java vendored Normal file
View File

@@ -0,0 +1,28 @@
package system;
import java.lang.reflect.Constructor;
/*
* Class.getDeclaredConstructors()
*
* This test class represents a class in the system set for the VM. These classes cannot have their reflective calls directly
* intercepted because we cannot introduce dependencies on types in a lower classloader, so we have to call the reflective
* interceptor reflectively!
*/
@SuppressWarnings("rawtypes")
public class Ten {
public String runIt() {
StringBuilder data = new StringBuilder();
Constructor[] constructors = cs();
data.append("constructors:null?" + (constructors == null) + " ");
if (constructors != null) {
data.append("constructors:size=" + constructors.length + " ");
}
return "complete:" + data.toString().trim();
}
public Constructor[] cs() {
return this.getClass().getDeclaredConstructors();
}
}

View File

@@ -0,0 +1,27 @@
package system;
import java.lang.reflect.Field;
/*
* Field.getLong()
*
* This test class represents a class in the system set for the VM. These classes cannot have their reflective calls directly
* intercepted because we cannot introduce dependencies on types in a lower classloader, so we have to call the reflective
* interceptor reflectively!
*/
public class Thirteen {
public long foo = 42L;
public String runIt() throws Exception {
StringBuilder data = new StringBuilder();
Object value = gf();
data.append("value="+value);
return "complete:" + data.toString().trim();
}
public Long gf() throws Exception {
Field f = Thirteen.class.getField("foo");
return f.getLong(this);
}
}

View File

@@ -0,0 +1,27 @@
package system;
import java.lang.reflect.Field;
/*
* Field.get()
*
* This test class represents a class in the system set for the VM. These classes cannot have their reflective calls directly
* intercepted because we cannot introduce dependencies on types in a lower classloader, so we have to call the reflective
* interceptor reflectively!
*/
public class Twelve {
public String foo = "abc";
public String runIt() throws Exception {
StringBuilder data = new StringBuilder();
Object value = gf();
data.append("value="+value);
return "complete:" + data.toString().trim();
}
public Object gf() throws Exception {
Field f = Twelve.class.getField("foo");
return f.get(this);
}
}