Ejemplo n.º 1
0
  /**
   * In a class loaded by the subloader, calling a new STATIC method in a class loaded by the
   * superloader.
   */
  @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);
  }
Ejemplo n.º 2
0
  /**
   * In a class loaded by the subloader, calling a new method in a class loaded by the superloader
   * using super<dot>. (ispcheck)
   */
  @Test
  public void reloadTargetInSuperLoaderCallingSuper() throws Exception {
    String top = "superpkg.TopB";
    String bot = "subpkg.BottomB";

    ReloadableType rtypeA = subLoader.loadAsReloadableType(top);
    ReloadableType rtypeB = subLoader.loadAsReloadableType(bot);

    rtypeA.loadNewVersion("2", retrieveRename(top, top + "002"));
    rtypeB.loadNewVersion("2", retrieveRename(bot, bot + "002", top + "002:" + top));

    // Check the registry looks right for Top
    int topId = NameRegistry.getIdFor("superpkg/TopB");
    TypeRegistry trTop = TypeRegistry.getTypeRegistryFor(subLoader.getParent());
    assertEquals(0, topId);
    assertEquals(top, trTop.getReloadableType(topId).getName());
    assertEquals(top, trTop.getReloadableType("superpkg/TopB").getName());

    int bottomId = NameRegistry.getIdFor("subpkg/BottomB");
    TypeRegistry trBot = TypeRegistry.getTypeRegistryFor(subLoader);
    assertEquals(1, bottomId);
    assertEquals(bot, trBot.getReloadableType(bottomId).getName());
    assertEquals(bot, trBot.getReloadableType("subpkg/BottomB").getName());

    // Now call the m() in the Bottom003 type, which calls super.newMethodOnTop()
    result = runUnguarded(rtypeB.getClazz(), "m");
    assertEquals("TopB002.m() running", result.stdout);
  }
Ejemplo n.º 3
0
  /**
   * hierarchy loaded across classloaders. <br>
   * Top - all versions have a method 'm()'. v003 has method 'newMethodOnTop()'<br>
   * Bottom - all versions have a method 'm()'. v003 version of m() calls 'super.newMethodOnTop()'
   */
  @Ignore
  // test currently failing because we cache the reloadable type descriptors in
  // TypeRegistry.getDescriptorFor()
  @Test
  public void reloadSupertypeCalledThroughSubtype() throws Exception {
    String top = "superpkg.Top";
    String bot = "subpkg.Bottom";

    ReloadableType rtypeA = subLoader.loadAsReloadableType(top);
    ReloadableType rtypeB = subLoader.loadAsReloadableType(bot);

    rtypeA.loadNewVersion("2", retrieveRename(top, top + "003"));
    rtypeB.loadNewVersion("2", retrieveRename(bot, bot + "003", top + "003:" + top));

    // Check the registry looks right for Top
    int topId = NameRegistry.getIdFor("superpkg/Top");
    TypeRegistry trTop = TypeRegistry.getTypeRegistryFor(subLoader.getParent());
    assertEquals(0, topId);
    assertEquals(top, trTop.getReloadableType(topId).getName());
    assertEquals(top, trTop.getReloadableType("superpkg/Top").getName());

    int bottomId = NameRegistry.getIdFor("subpkg/Bottom");
    TypeRegistry trBot = TypeRegistry.getTypeRegistryFor(subLoader);
    assertEquals(1, bottomId);
    assertEquals(bot, trBot.getReloadableType(bottomId).getName());
    assertEquals(bot, trBot.getReloadableType("subpkg/Bottom").getName());

    // Now call the m() in the Bottom003 type, which calls super.newMethodOnTop()
    result = runUnguarded(rtypeB.getClazz(), "m");
    assertEquals("newMethodOnTop() running", result.stdout);
  }