use of org.springsource.loaded.TypeRegistry 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.TypeRegistry 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.TypeRegistry 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.TypeRegistry 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.TypeRegistry 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);
}
Aggregations