Package org.springsource.loaded

Examples of org.springsource.loaded.ReloadableType


    // start out same as previous test, then loads a further version:
    String target = "superpkg.TargetC";
    String targetImpl = "superpkg.TargetImplC";
    String invoker = "subpkg.InvokerC";

    ReloadableType targetR = subLoader.loadAsReloadableType(target);
    ReloadableType targetImplR = subLoader.loadAsReloadableType(targetImpl);
    ReloadableType invokerR = subLoader.loadAsReloadableType(invoker);

    targetR.loadNewVersion("2", retrieveRename(target, target + "002"));
    targetImplR.loadNewVersion("2", retrieveRename(targetImpl, targetImpl + "002", target + "002:" + target));
    invokerR.loadNewVersion("2",
        retrieveRename(invoker, invoker + "003", target + "002:" + target, targetImpl + "002:" + targetImpl));

    // 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("TargetImplC002.n() running", result.stdout);

    // now new: load new version of target that is missing the method

    targetR.loadNewVersion("3", targetR.bytesInitial);
    try {
      result = runUnguarded(invokerR.getClazz(), "run");
      fail("");
    } catch (InvocationTargetException ite) {
      assertTrue(ite.getCause() instanceof NoSuchMethodError);
      assertEquals("TargetC.n()V", ite.getCause().getMessage());
    }
View Full Code Here


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

   */
  @Test
  public void basicInternalsLocalVariables() throws Exception {
    String t = "executor.TestOne";
    TypeRegistry typeRegistry = getTypeRegistry(t);
    ReloadableType rtype = typeRegistry.addType(t, loadBytesForClass(t));
    reload(rtype, "37");
    checkLocalVariables(rtype.getLatestExecutorBytes(), "foo(Lexecutor/TestOne;Ljava/lang/String;)J",
        "thiz:Lexecutor/TestOne;", "s:Ljava/lang/String;");
  }
View Full Code Here

  public void codeStructure() throws Exception {
    String tclass = "executor.TestOne";

    TypeRegistry typeRegistry = getTypeRegistry(tclass);

    ReloadableType rtype = typeRegistry.addType(tclass, loadBytesForClass(tclass));

    // Reload it (triggers creation of dispatcher/executor)
    rtype.loadNewVersion("2", rtype.bytesInitial);

    // @formatter:off
    checkType(rtype.getLatestExecutorBytes(),
        "CLASS: executor/TestOne$$E2 v50 0x0001(public) super java/lang/Object\n"+
        "SOURCE: TestOne.java null\n"+
        "FIELD 0x0001(public) i I\n"+
        "METHOD: 0x0009(public static) ___init___(Lexecutor/TestOne;)V\n"+
        "    CODE\n"+
        " L0\n"+
        "    ALOAD 0\n"+
        "    POP\n"+
        " L1\n"+
        "    ALOAD 0\n"+
        "    BIPUSH 101\n"+
        "    LDC 0\n"+
        "    LDC i\n"+
        "    INVOKESTATIC org/springsource/loaded/TypeRegistry.instanceFieldInterceptionRequired(ILjava/lang/String;)Z\n"+
        "    IFEQ L2\n"+
        "    INVOKESTATIC java/lang/Integer.valueOf(I)Ljava/lang/Integer;\n"+
        "    SWAP\n"+
        "    DUP_X1\n"+
        "    LDC i\n"+
        "    INVOKESPECIAL executor/TestOne.r$set(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/String;)V\n"+
        "    GOTO L3\n"+
        " L2\n"+
        "    PUTFIELD executor/TestOne.i I\n"+
        " L3\n"+
        "    RETURN\n"+
        " L4\n"+
        "METHOD: 0x0009(public static) foo(Lexecutor/TestOne;Ljava/lang/String;)J\n"+
        "    CODE\n"+
        " L0\n"+
        "    ALOAD 1\n"+
        "    INVOKESTATIC java/lang/Long.parseLong(Ljava/lang/String;)J\n"+
        "    LRETURN\n"+
        " L1\n"+
        "METHOD: 0x0009(public static) hashCode(Lexecutor/TestOne;)I\n"+
        "    CODE\n"+
        " L0\n"+
        "    BIPUSH 37\n"+
        "    IRETURN\n"+
        " L1\n"+
        "\n");

    Assert.assertEquals(
        " L0\n"+
        "    ALOAD 1\n"+
        "    INVOKESTATIC java/lang/Long.parseLong(Ljava/lang/String;)J\n"+
        "    LRETURN\n"+
        " L1\n",
        toStringMethod(rtype.getLatestExecutorBytes(),"foo",false));
    // @formatter:on

    // @formatter:off
    Assert.assertEquals(
        " L0\n"+
        "    BIPUSH 37\n"+
        "    IRETURN\n"+
        " L1\n",
        toStringMethod(rtype.getLatestExecutorBytes(),"hashCode",false));
    // @formatter:on
  }
View Full Code Here

  @Test
  public void secondVersion() throws Exception {
    String tclass = "executor.TestOne";
    TypeRegistry typeRegistry = getTypeRegistry(tclass);

    ReloadableType rtype = typeRegistry.addType(tclass, loadBytesForClass(tclass));

    rtype.loadNewVersion("2", retrieveRename(tclass, tclass + "2"));

    // testing executor is for second version and not first

    // @formatter:off
    checkType(rtype.getLatestExecutorBytes(),
        "CLASS: executor/TestOne$$E2 v50 0x0001(public) super java/lang/Object\n"+
        "SOURCE: TestOne2.java null\n"+
        "FIELD 0x0001(public) i I\n"+
        "METHOD: 0x0009(public static) ___init___(Lexecutor/TestOne;)V\n"+
        "    CODE\n"+
        " L0\n"+
        "    ALOAD 0\n"+
        "    POP\n"+
        "    RETURN\n"+
        " L1\n"+
        "METHOD: 0x0009(public static) foo(Lexecutor/TestOne;Ljava/lang/String;)J\n"+
        "    CODE\n"+
        " L0\n"+
        "    ALOAD 1\n"+
        "    INVOKESTATIC java/lang/Long.parseLong(Ljava/lang/String;)J\n"+
        "    LRETURN\n"+
        " L1\n"+
        "METHOD: 0x0009(public static) hashCode(Lexecutor/TestOne;)I\n"+
        "    CODE\n"+
        " L0\n"+
        "    ALOAD 0\n"+
        "    LDC 0\n"+
        "    LDC i\n"+
        "    INVOKESTATIC org/springsource/loaded/TypeRegistry.instanceFieldInterceptionRequired(ILjava/lang/String;)Z\n"+
        "    IFEQ L1\n"+
        "    DUP\n"+
        "    LDC i\n"+
        "    INVOKESPECIAL executor/TestOne.r$get(Ljava/lang/Object;Ljava/lang/String;)Ljava/lang/Object;\n"+
        "    CHECKCAST java/lang/Integer\n"+
        "    INVOKEVIRTUAL java/lang/Integer.intValue()I\n"+
        "    GOTO L2\n"+
        " L1\n"+
        "    GETFIELD executor/TestOne.i I\n"+
        " L2\n"+
        "    ICONST_2\n"+
        "    IMUL\n"+
        "    IRETURN\n"+
        " L3\n"+
        "\n");

    Assert.assertEquals(
        " L0\n"+
        "    ALOAD 1\n"+
        "    INVOKESTATIC java/lang/Long.parseLong(Ljava/lang/String;)J\n"+
        "    LRETURN\n"+
        " L1\n",
        toStringMethod(rtype.getLatestExecutorBytes(),"foo",false));
    // @formatter:on
    //
    // @formatter:off
    Assert.assertEquals(
        " L0\n"+
        "    ALOAD 0\n"+
        "    LDC 0\n"+
        "    LDC i\n"+
        "    INVOKESTATIC org/springsource/loaded/TypeRegistry.instanceFieldInterceptionRequired(ILjava/lang/String;)Z\n"+
        "    IFEQ L1\n"+
        "    DUP\n"+
        "    LDC i\n"+
        "    INVOKESPECIAL executor/TestOne.r$get(Ljava/lang/Object;Ljava/lang/String;)Ljava/lang/Object;\n"+
        "    CHECKCAST java/lang/Integer\n"+
        "    INVOKEVIRTUAL java/lang/Integer.intValue()I\n"+
        "    GOTO L2\n"+
        " L1\n"+
        "    GETFIELD executor/TestOne.i I\n"+
        " L2\n"+
        "    ICONST_2\n"+
        "    IMUL\n"+
        "    IRETURN\n"+
        " L3\n",
        toStringMethod(rtype.getLatestExecutorBytes(),"hashCode",false));
    // @formatter:on
  }
View Full Code Here

   */
  @Test
  public void typeLevelAnnotations() {
    String t = "executor.A";
    TypeRegistry typeRegistry = getTypeRegistry(t);
    ReloadableType rtype = typeRegistry.addType(t, loadBytesForClass(t));
    reload(rtype, "2");
    Class<?> clazz = rtype.getLatestExecutorClass();
    Assert.assertEquals(Utils.getExecutorName(t, "2"), clazz.getName());
    Annotation[] annos = clazz.getAnnotations();
    Assert.assertNotNull(annos);
    Assert.assertEquals(1, annos.length);
  }
View Full Code Here

   */
  @Test
  public void typeLevelAnnotations2() {
    String t = "executor.A";
    TypeRegistry typeRegistry = getTypeRegistry(t);
    ReloadableType rtype = typeRegistry.addType(t, loadBytesForClass(t));
    rtype.loadNewVersion("2", retrieveRename(t, t + "2"));
    Class<?> clazz = rtype.getLatestExecutorClass();
    Assert.assertEquals(Utils.getExecutorName(t, "2"), clazz.getName());
    Annotation[] annos = clazz.getAnnotations();
    Assert.assertNotNull(annos);
    Assert.assertEquals(2, annos.length);
    Set<String> s = new HashSet<String>();
View Full Code Here

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

  @Test
  public void methodLevelAnnotationsOnInterfaces() throws Exception {
    String t = "executor.I";
    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/I;)V", "@common.Marker()");
    checkAnnotations(rtype.getLatestExecutorBytes(), "m2(Lexecutor/I;)V");
    rtype.loadNewVersion("39", retrieveRename("executor.I", "executor.I2"));
    checkAnnotations(rtype.getLatestExecutorBytes(), "m(Lexecutor/I;)V");
    checkAnnotations(rtype.getLatestExecutorBytes(), "m2(Lexecutor/I;)V", "@common.Marker()", "@common.Anno(id=abc)");
    Method m = rtype.getLatestExecutorClass().getDeclaredMethod("m2", rtype.getClazz());
    assertEquals("@common.Marker()", m.getAnnotations()[0].toString());
    assertIsOneOfThese(printAnnotation(m.getAnnotations()[1]),"@common.Anno(someValue=37, longValue=2, id=abc)", "@common.Anno(longValue=2, someValue=37, id=abc)");
  }
View Full Code Here

  @Test
  public void methodLevelAnnotationsOnInterfaces2() throws Exception {
    String t = "reflection.methodannotations.InterfaceTarget";
    TypeRegistry typeRegistry = getTypeRegistry(t);
    ReloadableType rtype = typeRegistry.addType(t, loadBytesForClass(t));
    checkAnnotations(rtype.bytesLoaded, "privMethod()V", "@reflection.AnnoT3(value=Foo)");
    reload(rtype, "37");
    checkAnnotations(rtype.getLatestExecutorBytes(), "privMethod(Lreflection/methodannotations/InterfaceTarget;)V",
        "@reflection.AnnoT3(value=Foo)");
    rtype.loadNewVersion("39", retrieveRename(t, t + "002"));
    checkAnnotations(rtype.getLatestExecutorBytes(), "privMethod(Lreflection/methodannotations/InterfaceTarget;)V",
        "@reflection.AnnoT3(value=Bar)");
    Method m = rtype.getLatestExecutorClass().getDeclaredMethod("privMethod", rtype.getClazz());
    assertEquals("@reflection.AnnoT3(value=Bar)", m.getAnnotations()[0].toString());
  }
View Full Code Here

TOP

Related Classes of org.springsource.loaded.ReloadableType

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.