use of org.springsource.loaded.ReloadableType in project spring-loaded by spring-projects.
the class Java8Tests method lambdaInvokeVirtual.
@Test
public void lambdaInvokeVirtual() throws Exception {
String t = "basic.LambdaJ";
TypeRegistry typeRegistry = getTypeRegistry("basic..*");
// Since Foo needs promoting to public, have to ensure it is directly loaded:
ReloadableType itype = typeRegistry.addType(t + "$Foo", loadBytesForClass(t + "$Foo"));
byte[] sc = loadBytesForClass(t);
ReloadableType rtype = typeRegistry.addType(t, sc);
Class<?> simpleClass = rtype.getClazz();
Result r = runUnguarded(simpleClass, "run");
r = runUnguarded(simpleClass, "run");
assertEquals("fooa", r.returnValue);
itype.loadNewVersion("002", retrieveRename(t + "$Foo", t + "2$Foo"));
rtype.loadNewVersion("002", retrieveRename(t, t + "2", t + "2$Foo:" + t + "$Foo"));
r = runUnguarded(simpleClass, "run");
assertEquals("fooab", r.returnValue);
}
use of org.springsource.loaded.ReloadableType in project spring-loaded by spring-projects.
the class Java8Tests method lambdaA.
@Test
public void lambdaA() throws Exception {
String t = "basic.LambdaA";
TypeRegistry typeRegistry = getTypeRegistry(t);
byte[] sc = loadBytesForClass(t);
ReloadableType rtype = typeRegistry.addType(t, sc);
Class<?> simpleClass = rtype.getClazz();
Result r = runUnguarded(simpleClass, "run");
r = runUnguarded(simpleClass, "run");
assertEquals(77, r.returnValue);
rtype.loadNewVersion("002", rtype.bytesInitial);
r = runUnguarded(simpleClass, "run");
assertEquals(77, r.returnValue);
}
use of org.springsource.loaded.ReloadableType in project spring-loaded by spring-projects.
the class Java8Tests method lambdaWithNonPublicInnerInterface.
@Test
public void lambdaWithNonPublicInnerInterface() throws Exception {
String t = "basic.LambdaG";
TypeRegistry typeRegistry = getTypeRegistry("basic..*");
// Since Boo needs promoting to public, have to ensure it is directly loaded:
typeRegistry.addType(t + "$Boo", loadBytesForClass(t + "$Boo"));
byte[] sc = loadBytesForClass(t);
ReloadableType rtype = typeRegistry.addType(t, sc);
Class<?> simpleClass = rtype.getClazz();
Result r = runUnguarded(simpleClass, "run");
r = runUnguarded(simpleClass, "run");
assertEquals(99, r.returnValue);
byte[] renamed = retrieveRename(t, t + "2", t + "2$Boo:" + t + "$Boo");
rtype.loadNewVersion("002", renamed);
r = runUnguarded(simpleClass, "run");
assertEquals(44, r.returnValue);
}
use of org.springsource.loaded.ReloadableType 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.ReloadableType 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...
}
Aggregations