@Test
public void reloadTargetInSuperloaderCallingStaticMethod() throws Exception {
String target = "superpkg.TargetB";
String invoker = "subpkg.InvokerB";
ReloadableType targetR = subLoader.loadAsReloadableType(target);
ReloadableType invokerR = subLoader.loadAsReloadableType(invoker);
targetR.loadNewVersion("2", retrieveRename(target, target + "002"));
invokerR.loadNewVersion("2", retrieveRename(invoker, invoker + "002", target + "002:" + target));
// Check the registry looks right for target
int targetId = NameRegistry.getIdFor(toSlash(target));
assertEquals(0, targetId);
TypeRegistry trtarget = TypeRegistry.getTypeRegistryFor(subLoader.getParent());
assertEquals(target, trtarget.getReloadableType(targetId).getName());
assertEquals(target, trtarget.getReloadableType(toSlash(target)).getName());
int invokerId = NameRegistry.getIdFor(toSlash(invoker));
TypeRegistry trinvokerR = TypeRegistry.getTypeRegistryFor(subLoader);
assertEquals(1, invokerId);
assertEquals(invoker, trinvokerR.getReloadableType(invokerId).getName());
assertEquals(invoker, trinvokerR.getReloadableType(toSlash(invoker)).getName());
// Now call the run() in the Invoker type, which calls 'Target.m()' where Target is in a different loader
// and has been reloaded
result = runUnguarded(invokerR.getClazz(), "run");
assertEquals("TargetB002.m() running", result.stdout);
}