Package org.springsource.loaded

Examples of org.springsource.loaded.TypeRegistry$BsmInfo


    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);
  }
View Full Code Here


    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("Target002.m() running", result.stdout);
View Full Code Here

    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);
View Full Code Here

    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);
  }
View Full Code Here

   *   subclass to have been declared initially protected).
   */

  @Test
  public void rewrite() throws Exception {
    TypeRegistry typeRegistry = getTypeRegistry("catchers.B");
    loadClass("catchers.A");
    TypeDescriptor typeDescriptor = typeRegistry.getExtractor().extract(loadBytesForClass("catchers.B"), true);
    checkDoesNotContain(typeDescriptor, "privateMethod");
    checkDoesContain(typeDescriptor, "0x1 publicMethod");
    checkDoesContain(typeDescriptor, "0x1 protectedMethod");
    checkDoesContain(typeDescriptor, "0x1 defaultMethod");

    ReloadableType rtype = typeRegistry.addType("catchers.B", loadBytesForClass("catchers.B"));

    reload(rtype, "2");
  }
View Full Code Here

   * Exercising the two codepaths for a catcher. The first 'run' will run the super version. The second 'run' will dispatch to our
   * new implementation.
   */
  @Test
  public void exerciseCatcher() throws Exception {
    TypeRegistry registry = getTypeRegistry("catchers..*");
    String a = "catchers.A";
    String b = "catchers.B";
    ReloadableType rtypeA = registry.addType(a, loadBytesForClass(a));
    ReloadableType rtypeB = registry.addType(b, loadBytesForClass(b));

    Class<?> clazz = loadit("catchers.Runner", ClassRenamer.rename("catchers.Runner", loadBytesForClass("catchers.Runner")));

    assertStartsWith("catchers.B@", runUnguarded(clazz, "runToString").returnValue);
    Assert.assertEquals(65, runUnguarded(clazz, "runPublicMethod").returnValue);
View Full Code Here

  /**
   * Now we work with a mixed hierarchy. Type X declares the methods, type Y extends X does not, type Z extends Y does.
   */
  @Test
  public void exerciseCatcher2() throws Exception {
    TypeRegistry registry = getTypeRegistry("catchers..*");

    String x = "catchers.X";
    String y = "catchers.Y";
    String z = "catchers.Z";

    ReloadableType rtypeX = registry.addType(x, loadBytesForClass(x));
    ReloadableType rtypeY = registry.addType(y, loadBytesForClass(y));
    ReloadableType rtypeZ = registry.addType(z, loadBytesForClass(z));

    Class<?> clazz = loadRunner("catchers.Runner2");

    Assert.assertEquals(1, runUnguarded(clazz, "runPublicX").returnValue);
    Assert.assertEquals(1, runUnguarded(clazz, "runPublicY").returnValue); // Y does not override
View Full Code Here

   * which would mean it cannot see a default visibility inner type. Default inner types (and default ctors) are being promoted to
   * public so that they can be seen from the other classloader - that enables the test to work.
   */
  @Test
  public void reloadDefaultVisInner() throws Exception {
    TypeRegistry typeRegistry = getTypeRegistry("inners..*");

    typeRegistry.addType("inners.One$Inner", loadBytesForClass("inners.One$Inner"));
    ReloadableType rtype = typeRegistry.addType("inners.One", loadBytesForClass("inners.One"));
    runUnguarded(rtype.getClazz(), "runner");

    rtype.loadNewVersion("2", retrieveRename("inners.One", "inners.One2", "inners.One2$Inner:inners.One$Inner"));
    runUnguarded(rtype.getClazz(), "runner");
  }
View Full Code Here

   * Similar to the first test but this is just using a regular default visibility class.
   */
  @Test
  public void reloadDefaultVisClass() throws Exception {
    String tclass = "inners.Two";
    TypeRegistry typeRegistry = getTypeRegistry("inners..*");

    typeRegistry.addType("inners.TwoDefault", loadBytesForClass("inners.TwoDefault"));
    ReloadableType rtype = typeRegistry.addType(tclass, loadBytesForClass(tclass));
    runUnguarded(rtype.getClazz(), "runner");

    rtype.loadNewVersion("2", retrieveRename(tclass, tclass + "2"));
    runUnguarded(rtype.getClazz(), "runner");
  }
View Full Code Here

   * visibility when compiled
   */
  @Test
  public void reloadPrivateVisInner() throws Exception {
    String tclass = "inners.Three";
    TypeRegistry typeRegistry = getTypeRegistry("inners..*");
   
   
    ReloadableType rtype = typeRegistry.addType(tclass, loadBytesForClass(tclass));
    runUnguarded(rtype.getClazz(), "runner");

//    ReloadableType rtypeInner =
    typeRegistry.addType("inners.Three$Inner", retrieveRename("inners.Three$Inner", "inners.Three2$Inner","inners.Three2:inners.Three"));

    rtype.loadNewVersion("2", retrieveRename(tclass, tclass + "2", "inners.Three2$Inner:inners.Three$Inner","inners.Three2:inners.Three"));
    runUnguarded(rtype.getClazz(), "runner");
  }
View Full Code Here

TOP

Related Classes of org.springsource.loaded.TypeRegistry$BsmInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.