use of org.springsource.loaded.test.infra.Result in project spring-loaded by spring-projects.
the class Java8Tests method streamWithLambdaInvokedVirtually2.
// not an inner interface this time (for the invokeinterface BSM)
@Test
public void streamWithLambdaInvokedVirtually2() throws Exception {
String t = "basic.StreamBB";
TypeRegistry typeRegistry = getTypeRegistry("basic..*");
byte[] sc = loadBytesForClass(t);
ReloadableType rtype = typeRegistry.addType(t, sc);
Class<?> simpleClass = rtype.getClazz();
Result r = runUnguarded(simpleClass, "run");
assertEquals(3, r.returnValue);
byte[] renamed = retrieveRename(t, t + "2");
rtype.loadNewVersion("002", renamed);
r = runUnguarded(simpleClass, "run");
assertEquals(4, r.returnValue);
}
use of org.springsource.loaded.test.infra.Result in project spring-loaded by spring-projects.
the class Java8Tests method issue104.
@Test
public void issue104() throws Exception {
String t = "bugs.Issue104";
TypeRegistry typeRegistry = getTypeRegistry(t);
byte[] sc = loadBytesForClass(t);
ReloadableType rtype = typeRegistry.addType(t, sc);
Class<?> clazz = rtype.getClazz();
@SuppressWarnings("unused") Result r = runUnguarded(clazz, "run");
r = runUnguarded(clazz, "run");
rtype.loadNewVersion("002", rtype.bytesInitial);
r = runUnguarded(clazz, "run");
// TODO should assert something but the issue is that the JVM crashes...
}
use of org.springsource.loaded.test.infra.Result in project spring-loaded by spring-projects.
the class Java8Tests method lambdaMethodReference.
// https://github.com/spring-projects/spring-loaded/issues/87
@Test
public void lambdaMethodReference() throws Exception {
String t = "basic.LambdaM";
TypeRegistry typeRegistry = getTypeRegistry("basic..*");
byte[] sc = loadBytesForClass(t);
ReloadableType rtype = typeRegistry.addType(t, sc);
Class<?> simpleClass = rtype.getClazz();
Result r = runUnguarded(simpleClass, "run");
r = runUnguarded(simpleClass, "run");
assertEquals("{5=test3}", r.returnValue);
//, t + "2$Foo:" + t + "$Foo"));
rtype.loadNewVersion("2", retrieveRename(t, t + "2"));
r = runUnguarded(simpleClass, "run");
assertEquals("{10=test3}", r.returnValue);
}
use of org.springsource.loaded.test.infra.Result in project spring-loaded by spring-projects.
the class Java8Tests method defaultMethods2.
// A class implements an interface. A default method is added to the interface on
// a reload and invoked from a reloaded version of the class.
@Ignore
@Test
public void defaultMethods2() throws Exception {
String t = "basic.DefaultMethodsI2A";
String t2 = "basic.DefaultMethodsC2A";
TypeRegistry typeRegistry = getTypeRegistry("basic..*");
byte[] ia = loadBytesForClass(t);
ReloadableType rtypeI = typeRegistry.addType(t, ia);
byte[] ca = loadBytesForClass(t2);
ReloadableType rtypeC = typeRegistry.addType(t2, ca);
Class<?> simpleClass = rtypeC.getClazz();
Result r = runUnguarded(simpleClass, "run");
r = runUnguarded(simpleClass, "run");
assertEquals(42, r.returnValue);
// byte[] renamed = retrieveRename(t, t + "2");
rtypeI.loadNewVersion("002", ia);
// ClassPrinter.print(rtypeI.getBytesLoaded());
r = runUnguarded(simpleClass, "run");
assertEquals(42, r.returnValue);
byte[] renamed = retrieveRename(t, t + "2");
rtypeI.loadNewVersion(renamed);
renamed = retrieveRename(t2, t2 + "2", t + "2:" + t);
rtypeC.loadNewVersion(renamed);
r = runUnguarded(simpleClass, "run");
assertEquals(42, r.returnValue);
assertEquals("FOO", r.stdout);
}
use of org.springsource.loaded.test.infra.Result in project spring-loaded by spring-projects.
the class MethodInvokerRewriterTests method invokevirtual2.
/**
* Two classes in a hierarchy, both reloadable. Neither of them defines a toString(), what happens as we reload
* versions of them adding then removing toString().
*/
@Test
public void invokevirtual2() throws Exception {
String caller = "virtual.CallerTwo";
String top = "virtual.CalleeTwoTop";
String bottom = "virtual.CalleeTwoBottom";
TypeRegistry typeRegistry = getTypeRegistry(top + "," + bottom);
// The first target does not define toString()
ReloadableType reloadableTop = typeRegistry.addType(top, loadBytesForClass(top));
// ReloadableType reloadableBottom =
typeRegistry.addType(bottom, loadBytesForClass(bottom));
Class<?> callerClazz = loadit(caller, loadBytesForClass(caller));
Result result = null;
result = runUnguarded(callerClazz, "runTopToString");
assertTrue(((String) result.returnValue).startsWith("virtual.CalleeTwoTop@"));
result = runUnguarded(callerClazz, "runBottomToString");
assertTrue(((String) result.returnValue).startsWith("virtual.CalleeTwoBottom@"));
reloadableTop.loadNewVersion("002", retrieveRename(top, top + "002"));
result = runUnguarded(callerClazz, "runTopToString");
assertTrue(((String) result.returnValue).startsWith("topToString"));
result = runUnguarded(callerClazz, "runBottomToString");
// still no impl in bottom, so hits top
assertTrue(((String) result.returnValue).startsWith("topToString"));
// remove it again
reloadableTop.loadNewVersion("003", retrieveRename(top, top + "003"));
result = runUnguarded(callerClazz, "runBottomToString");
assertTrue(((String) result.returnValue).startsWith("virtual.CalleeTwoBottom@"));
}
Aggregations