Package org.springsource.loaded

Examples of org.springsource.loaded.TypeRegistry


  }

  @Test
  public void staticInitializerReloading1() throws Exception {
    String t = "clinitg.One";
    TypeRegistry typeRegistry = getTypeRegistry(t);
    ReloadableType rtype = typeRegistry.addType(t, loadBytesForClass(t));
    result = runUnguarded(rtype.getClazz(), "run");
    assertEquals("5", result.returnValue);
    rtype.loadNewVersion("39", retrieveRename(t, t + "2"));
    rtype.runStaticInitializer(); // call is made on reloadable type
    result = runUnguarded(rtype.getClazz(), "run");
View Full Code Here


  }

  @Test
  public void staticInitializerReloading2() throws Exception {
    String t = "clinitg.One";
    TypeRegistry typeRegistry = getTypeRegistry(t);
    ReloadableType rtype = typeRegistry.addType(t, loadBytesForClass(t));
    result = runUnguarded(rtype.getClazz(), "run");
    assertEquals("5", result.returnValue);
    rtype.loadNewVersion("39", retrieveRename(t, t + "2"));

    // use the 'new' ___clinit___ method to drive the static initializer
View Full Code Here

   */
  @Ignore
  @Test
  public void staticInitializerReloading3() throws Exception {
    String t = "clinitg.Two";
    TypeRegistry typeRegistry = getTypeRegistry(t);
    ReloadableType rtype = typeRegistry.addType(t, loadBytesForClass(t));
    result = runUnguarded(rtype.getClazz(), "run");
    assertEquals("55", result.returnValue);
    rtype.loadNewVersion("39", retrieveRename(t, t + "2"));
    rtype.runStaticInitializer();
    result = runUnguarded(rtype.getClazz(), "run");
View Full Code Here

  public void enums() throws Exception {
    binLoader = new TestClassloaderWithRewriting();
    String enumtype = "enums.WhatAnEnum";
    String intface = "enums.ExtensibleEnum";
    String runner = "enums.RunnerA";
    TypeRegistry typeRegistry = getTypeRegistry(enumtype + "," + intface + "," + runner);
//    ReloadableType rtypeIntface =
    typeRegistry.addType(intface, loadBytesForClass(intface));
    ReloadableType rtypeEnum = typeRegistry.addType(enumtype, loadBytesForClass(enumtype));
    ReloadableType rtypeRunner = typeRegistry.addType(runner, loadBytesForClass(runner));
    result = runUnguarded(rtypeRunner.getClazz(), "run");
    // ClassPrinter.print(rtypeEnum.bytesInitial);
    assertContains("[RED GREEN BLUE]", result.stdout);
    System.out.println(result);
    byte[] bs = retrieveRename(enumtype, enumtype + "2",
View Full Code Here

    binLoader = new TestClassloaderWithRewriting();
    String enumtype = "enums.WhatAnEnumB";
    String intface = "enums.ExtensibleEnumB";
    String runner = "enums.RunnerB";
    String closure = "enums.WhatAnEnumB$__clinit__closure1";
    TypeRegistry typeRegistry = getTypeRegistry(enumtype + "," + intface + "," + runner + "," + closure);
//    ReloadableType rtypeIntface =
    typeRegistry.addType(intface, loadBytesForClass(intface));
    ReloadableType rtypeClosure = typeRegistry.addType(closure, loadBytesForClass(closure));
    ReloadableType rtypeEnum = typeRegistry.addType(enumtype, loadBytesForClass(enumtype));
    ReloadableType rtypeRunner = typeRegistry.addType(runner, loadBytesForClass(runner));
    result = runUnguarded(rtypeRunner.getClazz(), "run");
    assertContains(
        "[PETS_AT_THE_DISCO 1 JUMPING_INTO_A_HOOP 2 HAVING_A_NICE_TIME 3 LIVING_ON_A_LOG 4 WHAT_DID_YOU_DO 5 UNKNOWN 0]",
        result.stdout);
View Full Code Here

   */
  @Ignore // Needs investigating...likely a change in groovy bytecode format tripping us up
  @Test
  public void staticInitializerReloading4() throws Exception {
    String t = "clinitg.Three";
    TypeRegistry typeRegistry = getTypeRegistry(t);
    ReloadableType rtype = typeRegistry.addType(t, loadBytesForClass(t));
    result = runUnguarded(rtype.getClazz(), "run");
    assertEquals("1", result.returnValue);
    rtype.loadNewVersion("2", retrieveRename(t, t + "2"));
    rtype.runStaticInitializer();
    result = runUnguarded(rtype.getClazz(), "run");
View Full Code Here

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

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

   */
  @Test
  public void staticInitializers() throws Exception {
    String t = "test.Initializers";
    String t2 = "test.SubInitializers";
    TypeRegistry r = getTypeRegistry(t + "," + t2);
    ReloadableType rtype = r.addType(t, loadBytesForClass(t));
    ReloadableType subtype = r.addType(t2, loadBytesForClass(t2));

    // Check the format of the modified static initializer
    // @formatter:off
    assertEquals(
      // initialization of reloadabletype
View Full Code Here

  @Test
  public void staticInitializersAndInterfaces() throws Exception {
    String t = "test.Interface";
    String t2 = "test.SubInterface";
    TypeRegistry r = getTypeRegistry(t + "," + t2);
    ReloadableType itype = r.addType(t, loadBytesForClass(t));
    ReloadableType subitype = r.addType(t2, loadBytesForClass(t2));

//    ClassPrinter.print(subitype.bytesLoaded);

    // An interface will get the reloadable type field
    assertEquals("0x19(public static final) r$type Lorg/springsource/loaded/ReloadableType;",
View Full Code Here

TOP

Related Classes of org.springsource.loaded.TypeRegistry

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.