use of org.springsource.loaded.TypeRegistry in project spring-loaded by spring-projects.
the class InterfaceExtractorTest method varietyOfMethods.
@Test
public void varietyOfMethods() {
TypeRegistry registry = getTypeRegistry(null);
byte[] classBytes = loadBytesForClass("data.SimpleClassFour");
TypeDescriptor td = new TypeDescriptorExtractor(registry).extract(classBytes, true);
byte[] bytes = InterfaceExtractor.extract(classBytes, registry, td);
// @formatter:off
checkType(bytes, "CLASS: data/SimpleClassFour__I v50 0x0601(public abstract interface) super java/lang/Object\n" + "METHOD: 0x0401(public abstract) ___init___(Ldata/SimpleClassFour;I)V\n" + "METHOD: 0x0401(public abstract) ___init___(Ldata/SimpleClassFour;Ljava/lang/String;)V\n" + "METHOD: 0x0401(public abstract) boo(Ldata/SimpleClassFour;)V\n" + "METHOD: 0x0401(public abstract) foo(Ldata/SimpleClassFour;)V\n" + "METHOD: 0x0401(public abstract) goo(Ldata/SimpleClassFour;IDLjava/lang/String;)Ljava/lang/String;\n" + "METHOD: 0x0401(public abstract) hoo(Ldata/SimpleClassFour;J)I\n" + "METHOD: 0x0401(public abstract) woo(Ldata/SimpleClassFour;)V java/lang/RuntimeException java/lang/IllegalStateException\n" + "METHOD: 0x0401(public abstract) __execute([Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/String;)Ljava/lang/Object;\n" + "METHOD: 0x0401(public abstract) ___clinit___()V\n" + "METHOD: 0x0401(public abstract) hashCode(Ldata/SimpleClassFour;)I\n" + "METHOD: 0x0401(public abstract) equals(Ldata/SimpleClassFour;Ljava/lang/Object;)Z\n" + "METHOD: 0x0401(public abstract) clone(Ldata/SimpleClassFour;)Ljava/lang/Object; java/lang/CloneNotSupportedException\n" + "METHOD: 0x0401(public abstract) toString(Ldata/SimpleClassFour;)Ljava/lang/String;\n" + "\n");
// @formatter:on
}
use of org.springsource.loaded.TypeRegistry in project spring-loaded by spring-projects.
the class Java8Tests method lambdaWithParameter.
@Test
public void lambdaWithParameter() throws Exception {
String t = "basic.LambdaB";
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(99L, r.returnValue);
byte[] renamed = retrieveRename(t, t + "2", t + "2$Foo:" + t + "$Foo");
rtype.loadNewVersion("002", renamed);
r = runUnguarded(simpleClass, "run");
assertEquals(176L, r.returnValue);
}
use of org.springsource.loaded.TypeRegistry in project spring-loaded by spring-projects.
the class Java8Tests method streamWithLambdaInvokedVirtually.
// inner interface (for the invokeinterface BSM)
@Test
public void streamWithLambdaInvokedVirtually() throws Exception {
String t = "basic.StreamB";
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", t + "2$Foo:" + t + "$Foo");
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 lambdaWithTwoParameters.
@Test
public void lambdaWithTwoParameters() throws Exception {
String t = "basic.LambdaC";
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(6L, r.returnValue);
byte[] renamed = retrieveRename(t, t + "2", t + "2$Boo:" + t + "$Boo");
rtype.loadNewVersion("002", renamed);
r = runUnguarded(simpleClass, "run");
assertEquals(5L, r.returnValue);
}
use of org.springsource.loaded.TypeRegistry in project spring-loaded by spring-projects.
the class MethodInvokerRewriterTests method invokevirtualNonCatchersErrorScenario.
@Test
public void invokevirtualNonCatchersErrorScenario() throws Exception {
String top = "virtual.FourTop";
String bot = "virtual.FourBot";
TypeRegistry typeRegistry = getTypeRegistry(top + "," + bot);
// The first top does not define foo()
// ReloadableType topR =
typeRegistry.addType(top, loadBytesForClass(top));
ReloadableType botR = typeRegistry.addType(bot, loadBytesForClass(bot));
result = runUnguarded(botR.getClazz(), "run");
assertEquals(42, result.returnValue);
// Dont load new Top, which means the new method that the subtype will call
// will not exist
// topR.loadNewVersion(retrieveRename(top, top + "2"));
botR.loadNewVersion(retrieveRename(bot, bot + "2", top + "2:" + top));
// introduced into FourTop
try {
result = runUnguarded(botR.getClazz(), "run");
fail("Should have failed!");
} catch (InvocationTargetException ite) {
assertTrue(ite.getCause() instanceof NoSuchMethodError);
assertEquals("FourBot.bar()I", ite.getCause().getMessage());
}
}
Aggregations