Package org.springsource.loaded

Examples of org.springsource.loaded.ReloadableType$MergedRewrite


  public void staticInitializerReloading5() throws Exception {
    binLoader = new TestClassloaderWithRewriting();
    String t = "clinitg.Four";
    String t2 = "clinitg.FourHelper";
    TypeRegistry typeRegistry = getTypeRegistry(t);
    ReloadableType rtype = typeRegistry.addType(t, loadBytesForClass(t));
    // ReloadableType rtype2 =
    typeRegistry.addType(t2, loadBytesForClass(t2));
    typeRegistry.getClassLoader().loadClass(t); // load it but do not initialize it
    captureOn();
    byte[] renamed = retrieveRename(t, t + "2");
    rtype.loadNewVersion("2", renamed); // reload it, this will trigger initialization
    String s = captureOffReturnStdout();
    assertEquals("1a", s);

    result = runUnguarded(rtype.getClazz(), "run");
    assertEquals("1312", result.stdout);
  }
View Full Code Here


*/
public class DebuggingTests extends SpringLoadedTests {
  @Test
  public void rewrite() throws Exception {
    TypeRegistry typeRegistry = getTypeRegistry("data.HelloWorld");
    ReloadableType rtype = typeRegistry.addType("data.HelloWorld", loadBytesForClass("data.HelloWorld"));
    runUnguarded(rtype.getClazz(), "greet");

    // Just transform the existing version into a dispatcher/executor
    rtype.loadNewVersion("000", rtype.bytesInitial);
    Assert.assertEquals("Greet from HelloWorld", runUnguarded(rtype.getClazz(), "greet").stdout);

    // Load a real new version
    rtype.loadNewVersion("002", retrieveRename("data.HelloWorld", "data.HelloWorld002"));
    Assert.assertEquals("Greet from HelloWorld 2", runUnguarded(rtype.getClazz(), "greet").stdout);
    //    ClassPrinter.print(rtype.getLatestExecutorBytes());
    //    ClassPrinter.print(rtype.bytesInitial);

  }
View Full Code Here

   */
  @Test
  public void loadType() {
    TypeRegistry typeRegistry = getTypeRegistry("data.SimpleClass");
    byte[] sc = loadBytesForClass("data.SimpleClass");
    ReloadableType rtype = new ReloadableType("data.SimpleClass", sc, 1, typeRegistry, null);

    assertEquals(1, rtype.getId());
    assertEquals("data.SimpleClass", rtype.getName());
    assertEquals("data/SimpleClass", rtype.getSlashedName());
    assertNotNull(rtype.getTypeDescriptor());
    assertEquals(typeRegistry, rtype.getTypeRegistry());
  }
View Full Code Here

   */
  @Test
  public void callIt() throws Exception {
    TypeRegistry typeRegistry = getTypeRegistry("basic.Basic");
    byte[] sc = loadBytesForClass("basic.Basic");
    ReloadableType rtype = typeRegistry.addType("basic.Basic", sc);

    Class<?> simpleClass = rtype.getClazz();
    Result r = runUnguarded(simpleClass, "foo");

    r = runUnguarded(simpleClass, "getValue");
    assertEquals(5, r.returnValue);

    rtype.loadNewVersion("002", retrieveRename("basic.Basic", "basic.Basic002"));

    r = runUnguarded(simpleClass, "getValue");
    assertEquals(7, r.returnValue);
  }
View Full Code Here

  @Test
  public void removingStaticMethod() throws Exception {
    String t = "remote.Perf1";
    TypeRegistry typeRegistry = getTypeRegistry(t);
    byte[] sc = loadBytesForClass(t);
    ReloadableType rtype = typeRegistry.addType(t, sc);

    Class<?> clazz = rtype.getClazz();
    runUnguarded(clazz, "time");

    rtype.loadNewVersion("002", retrieveRename(t, "remote.Perf2"));

    runUnguarded(clazz, "time");
  }
View Full Code Here

  }
 
  @Test
  public void protectedFieldAccessors() throws Exception {
    TypeRegistry tr = getTypeRegistry("prot.SubOne");
    ReloadableType rtype = tr.addType("prot.SubOne", loadBytesForClass("prot.SubOne"));

    Object instance = rtype.getClazz().newInstance();

    runOnInstance(rtype.getClazz(), instance, "setPublicField", 3);
    assertEquals(3, runOnInstance(rtype.getClazz(), instance, "getPublicField").returnValue);

    runOnInstance(rtype.getClazz(), instance, "setProtectedField", 3);
    assertEquals(3, runOnInstance(rtype.getClazz(), instance, "getProtectedField").returnValue);

    runOnInstance(rtype.getClazz(), instance, "setProtectedShortField", (short) 33);
    assertEquals((short) 33, runOnInstance(rtype.getClazz(), instance, "getProtectedShortField").returnValue);

    runOnInstance(rtype.getClazz(), instance, "setProtectedByteField", (byte) 133);
    assertEquals((byte) 133, runOnInstance(rtype.getClazz(), instance, "getProtectedByteField").returnValue);

    runOnInstance(rtype.getClazz(), instance, "setProtectedCharField", (char) 12);
    assertEquals((char) 12, runOnInstance(rtype.getClazz(), instance, "getProtectedCharField").returnValue);

    runOnInstance(rtype.getClazz(), instance, "setProtectedBooleanField", true);
    assertEquals(true, runOnInstance(rtype.getClazz(), instance, "isProtectedBooleanField").returnValue);

    runOnInstance(rtype.getClazz(), instance, "setProtectedDoubleField", 3.1d);
    assertEquals(3.1d, runOnInstance(rtype.getClazz(), instance, "getProtectedDoubleField").returnValue);

    runOnInstance(rtype.getClazz(), instance, "setProtectedFloatField", 8f);
    assertEquals(8f, runOnInstance(rtype.getClazz(), instance, "getProtectedFloatField").returnValue);

    runOnInstance(rtype.getClazz(), instance, "setProtectedLongField", 888L);
    assertEquals(888L, runOnInstance(rtype.getClazz(), instance, "getProtectedLongField").returnValue);

    runOnInstance(rtype.getClazz(), instance, "setProtectedArrayOfInts", new int[] { 1, 2, 3 });
    assertEquals("[1,2,3]", toString(runOnInstance(rtype.getClazz(), instance, "getProtectedArrayOfInts").returnValue));

    runOnInstance(rtype.getClazz(), instance, "setProtectedArrayOfStrings", (Object) new String[] { "a", "b", "c" });
    assertEquals("[a,b,c]", toString(runOnInstance(rtype.getClazz(), instance, "getProtectedArrayOfStrings").returnValue));

    runOnInstance(rtype.getClazz(), instance, "setProtectedArrayOfArrayOfLongs", (Object) new long[][] { new long[] { 3L },
        new long[] { 4L, 45L }, new long[] { 7L } });
    assertEquals("[[3],[4,45],[7]]",
        toString(runOnInstance(rtype.getClazz(), instance, "getProtectedArrayOfArrayOfLongs").returnValue));

    runOnInstance(rtype.getClazz(), instance, "setProtectedStaticField", 3);
    assertEquals(3, runOnInstance(rtype.getClazz(), instance, "getProtectedStaticField").returnValue);

    rtype.loadNewVersion(rtype.bytesInitial);

    runOnInstance(rtype.getClazz(), instance, "setPublicField", 4);
    assertEquals(4, runOnInstance(rtype.getClazz(), instance, "getPublicField").returnValue);

    runOnInstance(rtype.getClazz(), instance, "setProtectedField", 3);
    assertEquals(3, runOnInstance(rtype.getClazz(), instance, "getProtectedField").returnValue);

    runOnInstance(rtype.getClazz(), instance, "setProtectedShortField", (short) 33);
    assertEquals((short) 33, runOnInstance(rtype.getClazz(), instance, "getProtectedShortField").returnValue);

    runOnInstance(rtype.getClazz(), instance, "setProtectedByteField", (byte) 133);
    assertEquals((byte) 133, runOnInstance(rtype.getClazz(), instance, "getProtectedByteField").returnValue);

    runOnInstance(rtype.getClazz(), instance, "setProtectedCharField", (char) 12);
    assertEquals((char) 12, runOnInstance(rtype.getClazz(), instance, "getProtectedCharField").returnValue);

    runOnInstance(rtype.getClazz(), instance, "setProtectedBooleanField", true);
    assertEquals(true, runOnInstance(rtype.getClazz(), instance, "isProtectedBooleanField").returnValue);

    runOnInstance(rtype.getClazz(), instance, "setProtectedDoubleField", 3.1d);
    assertEquals(3.1d, runOnInstance(rtype.getClazz(), instance, "getProtectedDoubleField").returnValue);

    runOnInstance(rtype.getClazz(), instance, "setProtectedFloatField", 8f);
    assertEquals(8f, runOnInstance(rtype.getClazz(), instance, "getProtectedFloatField").returnValue);

    runOnInstance(rtype.getClazz(), instance, "setProtectedLongField", 888L);
    assertEquals(888L, runOnInstance(rtype.getClazz(), instance, "getProtectedLongField").returnValue);

    runOnInstance(rtype.getClazz(), instance, "setProtectedArrayOfInts", new int[] { 1, 2, 3 });
    assertEquals("[1,2,3]", toString(runOnInstance(rtype.getClazz(), instance, "getProtectedArrayOfInts").returnValue));

    runOnInstance(rtype.getClazz(), instance, "setProtectedArrayOfStrings", (Object) new String[] { "a", "b", "c" });
    assertEquals("[a,b,c]", toString(runOnInstance(rtype.getClazz(), instance, "getProtectedArrayOfStrings").returnValue));

    runOnInstance(rtype.getClazz(), instance, "setProtectedArrayOfArrayOfLongs", (Object) new long[][] { new long[] { 3L },
        new long[] { 4L, 45L }, new long[] { 7L } });
    assertEquals("[[3],[4,45],[7]]",
        toString(runOnInstance(rtype.getClazz(), instance, "getProtectedArrayOfArrayOfLongs").returnValue));

    runOnInstance(rtype.getClazz(), instance, "setProtectedStaticField", 3);
    assertEquals(3, runOnInstance(rtype.getClazz(), instance, "getProtectedStaticField").returnValue);

  }
View Full Code Here

  // github issue 4
  @Test
  public void invokeStaticReloading_gh4_1() throws Exception {
    TypeRegistry tr = getTypeRegistry("invokestatic..*");
    tr.addType("invokestatic.issue4.A", loadBytesForClass("invokestatic.issue4.A"));
    ReloadableType B = tr.addType("invokestatic.issue4.B", loadBytesForClass("invokestatic.issue4.B"));
   
    Result r = runUnguarded(B.getClazz(), "getMessage");
    assertEquals("String1",(String)r.returnValue);
   
   
    B.loadNewVersion(B.bytesInitial);
   
    r = runUnguarded(B.getClazz(), "getMessage");
    assertEquals("String1",(String)r.returnValue);
  }
View Full Code Here

 
  @Test
  public void invokeStaticReloading_gh4_2() throws Exception {
    TypeRegistry tr = getTypeRegistry("invokestatic..*");
    tr.addType("invokestatic.issue4.AA", loadBytesForClass("invokestatic.issue4.AA"));
    ReloadableType BB = tr.addType("invokestatic.issue4.BB", loadBytesForClass("invokestatic.issue4.BB"));
   
    Result r = runUnguarded(BB.getClazz(), "getMessage");
    assertEquals("String1",(String)r.returnValue);
   
    BB.loadNewVersion(BB.bytesInitial);

    r = runUnguarded(BB.getClazz(), "getMessage");
    assertEquals("String1",(String)r.returnValue);
  }
View Full Code Here

  }
 
  @Test
  public void invokeStaticReloading_gh4_3() throws Exception {
    TypeRegistry tr = getTypeRegistry("invokestatic..*");
    ReloadableType AAA = tr.addType("invokestatic.issue4.AAA", loadBytesForClass("invokestatic.issue4.AAA"));
    ReloadableType BBB = tr.addType("invokestatic.issue4.BBB", loadBytesForClass("invokestatic.issue4.BBB"));
   
    Result r = runUnguarded(BBB.getClazz(), "getMessage");
    assertEquals("String1",(String)r.returnValue);
   
    AAA.loadNewVersion(AAA.bytesInitial);

    r = runUnguarded(BBB.getClazz(), "getMessage");
    assertEquals("String1",(String)r.returnValue);
  }
View Full Code Here

  }
 
  @Test
  public void invokeStaticReloading_gh4_4() throws Exception {
    TypeRegistry tr = getTypeRegistry("invokestatic..*");
    ReloadableType A = tr.addType("invokestatic.issue4.A", loadBytesForClass("invokestatic.issue4.A"));
    ReloadableType B = tr.addType("invokestatic.issue4.B", loadBytesForClass("invokestatic.issue4.B"));
   
    Result r = runUnguarded(B.getClazz(), "getMessage");
    assertEquals("String1",(String)r.returnValue);

    A.loadNewVersion(A.bytesInitial);
    B.loadNewVersion(B.bytesInitial);

    r = runUnguarded(B.getClazz(), "getMessage");
    assertEquals("String1",(String)r.returnValue);
  }
View Full Code Here

TOP

Related Classes of org.springsource.loaded.ReloadableType$MergedRewrite

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.