Serialization handling - see github issue #24
This commit is contained in:
29
testdata/src/main/java/system/Eleven.java
vendored
Normal file
29
testdata/src/main/java/system/Eleven.java
vendored
Normal 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
28
testdata/src/main/java/system/Ten.java
vendored
Normal 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();
|
||||
}
|
||||
}
|
||||
27
testdata/src/main/java/system/Thirteen.java
vendored
Normal file
27
testdata/src/main/java/system/Thirteen.java
vendored
Normal 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);
|
||||
}
|
||||
}
|
||||
27
testdata/src/main/java/system/Twelve.java
vendored
Normal file
27
testdata/src/main/java/system/Twelve.java
vendored
Normal 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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user