use of org.springsource.loaded.ReloadableType in project spring-loaded by spring-projects.
the class ExecutorBuilderTests method basicExternals.
/**
* Check properties of the newly created executor.
*/
@Test
public void basicExternals() throws Exception {
String t = "executor.TestOne";
TypeRegistry typeRegistry = getTypeRegistry(t);
ReloadableType rtype = typeRegistry.addType(t, loadBytesForClass(t));
reload(rtype, "37");
Class<?> clazz = rtype.getLatestExecutorClass();
Assert.assertEquals(Utils.getExecutorName(t, "37"), clazz.getName());
Assert.assertEquals(3, clazz.getDeclaredMethods().length);
Assert.assertEquals(1, clazz.getDeclaredFields().length);
}
use of org.springsource.loaded.ReloadableType in project spring-loaded by spring-projects.
the class ExecutorBuilderTests method staticInitializerReloading4.
/**
* Type that doesn't really have a clinit
*/
@Test
public void staticInitializerReloading4() throws Exception {
String t = "clinit.Three";
TypeRegistry typeRegistry = getTypeRegistry(t);
ReloadableType rtype = typeRegistry.addType(t, loadBytesForClass(t));
result = runUnguarded(rtype.getClazz(), "run");
assertEquals("1", result.returnValue);
rtype.loadNewVersion("2", retrieveRename(t, t + "2"));
rtype.runStaticInitializer();
result = runUnguarded(rtype.getClazz(), "run");
assertEquals("1", result.returnValue);
rtype.loadNewVersion("3", retrieveRename(t, t + "3"));
rtype.runStaticInitializer();
result = runUnguarded(rtype.getClazz(), "run");
ClassPrinter.print(rtype.getLatestExecutorBytes());
assertEquals("4", result.returnValue);
}
use of org.springsource.loaded.ReloadableType in project spring-loaded by spring-projects.
the class ExecutorBuilderTests method methodLevelAnnotations.
@Test
public void methodLevelAnnotations() throws Exception {
String t = "executor.B";
TypeRegistry typeRegistry = getTypeRegistry(t);
ReloadableType rtype = typeRegistry.addType(t, loadBytesForClass(t));
reload(rtype, "37");
checkAnnotations(rtype.bytesLoaded, "m()V", "@common.Marker()");
checkAnnotations(rtype.bytesLoaded, "m2()V");
checkAnnotations(rtype.getLatestExecutorBytes(), "m(Lexecutor/B;)V", "@common.Marker()");
checkAnnotations(rtype.getLatestExecutorBytes(), "m2(Lexecutor/B;)V");
rtype.loadNewVersion("39", retrieveRename("executor.B", "executor.B2"));
checkAnnotations(rtype.getLatestExecutorBytes(), "m(Lexecutor/B;)V");
checkAnnotations(rtype.getLatestExecutorBytes(), "m2(Lexecutor/B;)V", "@common.Marker()", "@common.Anno(id=abc)");
}
use of org.springsource.loaded.ReloadableType in project spring-loaded by spring-projects.
the class CrossLoaderTests method toString.
public String toString(List<Reference<ReloadableType>> list) {
if (list == null) {
return "null";
}
StringBuilder b = new StringBuilder();
b.append("[");
for (int i = 0; i < list.size(); i++) {
if (i > 0) {
b.append(",");
}
Reference<ReloadableType> ref = list.get(i);
ReloadableType rtype = ref.get();
if (rtype != null) {
b.append(rtype.getName());
}
}
b.append("]");
return b.toString();
}
use of org.springsource.loaded.ReloadableType in project spring-loaded by spring-projects.
the class CrossLoaderTests method verifyingAssociatedTypesInfo2.
// Large scale test loading a bunch of types and verifying what happens in terms of tagging
@Test
public void verifyingAssociatedTypesInfo2() throws Exception {
// associatedtypes (top and middle) are in the super loader
// subassociatedtypes (bottom) are in the sub loader
ReloadableType bm = subLoader.loadAsReloadableType("associatedtypes.CM");
ReloadableType cm = subLoader.loadAsReloadableType("associatedtypes.CM");
assertNotNull(cm);
assertNotEquals(subLoader, cm.getClazz().getClassLoader());
ReloadableType im1 = subLoader.loadAsReloadableType("associatedtypes.IM");
assertNotNull(im1);
// Cause clinit to run so associations are setup
runUnguarded(cm.getClazz(), "run");
assertContains("associatedtypes.CM", toString(im1.getAssociatedSubtypes()));
assertFalse(cm.isAffectedByReload());
assertFalse(cm.isAffectedByReload());
assertFalse(bm.isAffectedByReload());
// Load CM again, should tag CM and IM
cm.loadNewVersion("2", cm.bytesInitial);
assertTrue(cm.isAffectedByReload());
assertTrue(im1.isAffectedByReload());
assertTrue(bm.isAffectedByReload());
}
Aggregations