String one = "basic.Basic";
String two = "basic.BasicB";
GlobalConfiguration.maxClassDefinitions = 4;
TypeRegistry typeRegistry = getTypeRegistry(one + "," + two);
ReloadableType tOne = typeRegistry.addType(one, loadBytesForClass(one));
ReloadableType tTwo = typeRegistry.addType(two, loadBytesForClass(two));
result = runUnguarded(tOne.getClazz(), "getValue");
assertEquals(5, result.returnValue);
// Should be nothing defined in the child loader
assertEquals(0, typeRegistry.getChildClassLoader().getDefinedCount());
tOne.loadNewVersion("002", retrieveRename(one, one + "002"));
// Should be dispatcher and executor for the reloaded type
assertEquals(2, typeRegistry.getChildClassLoader().getDefinedCount());
assertEquals(7, runUnguarded(tOne.getClazz(), "getValue").returnValue);
tTwo.loadNewVersion("002", tTwo.bytesInitial);
assertEquals(4, typeRegistry.getChildClassLoader().getDefinedCount());
result = runUnguarded(tOne.getClazz(), "getValue");
assertEquals(5, runUnguarded(tTwo.getClazz(), "getValue").returnValue);
Class<?> cOneExecutor = tOne.getLatestExecutorClass();
tOne.loadNewVersion("003", tOne.bytesInitial);
// Now on this reload the child classloader should be recreated as it already has more
// than 2 defined.
// Note: this will currently cause us to redefine all the reloadable types
// according to their most recent version. An optimization may be to only
// define them on demand
tTwo.loadNewVersion("002", tTwo.bytesInitial);
assertEquals(4, typeRegistry.getChildClassLoader().getDefinedCount());
assertEquals(5, runUnguarded(tTwo.getClazz(), "getValue").returnValue);
// But what about calling the older types?
assertEquals(5, runUnguarded(tOne.getClazz(), "getValue").returnValue);
if (cOneExecutor == tOne.getLatestExecutorClass()) {