Package org.springsource.loaded

Examples of org.springsource.loaded.TypeRegistry


   * introduce unexpected (but correct) behaviour.
   */
  @Test
  public void constructorsAndFinalFields() throws Exception {
    String caller = "ctors.Finals";
    TypeRegistry r = getTypeRegistry(caller);
    ReloadableType rcaller = r.addType(caller, loadBytesForClass(caller));
    Result res = null;

    // Use the code 'untouched'
    Object callerInstance = rcaller.getClazz().newInstance();
    res = runOnInstance(rcaller.getClazz(), callerInstance, "getValue");
View Full Code Here


  @Test
  public void newConstructors2() throws Exception {
    String caller = "ctors.CallerB";
    String callee = "ctors.CalleeB";
    String calleeSuper = "ctors.CalleeSuperB";
    TypeRegistry r = getTypeRegistry(caller + "," + callee + "," + calleeSuper);
    ReloadableType rcaller = r.addType(caller, loadBytesForClass(caller));
    ReloadableType rcalleeSuper = r.addType(calleeSuper, loadBytesForClass(calleeSuper));
    ReloadableType rcallee = r.addType(callee, loadBytesForClass(callee));
    Result res = null;

    // Use the code 'untouched'
    Object callerInstance = rcaller.getClazz().newInstance();
    res = runOnInstance(rcaller.getClazz(), callerInstance, "runA");
View Full Code Here

  // TODO synchronization around access to the static/instance field maps
  @Test
  public void rewriteInstanceFields() throws Exception {
    // turn off to simplify debugging verify problems:
    // GlobalConfiguration.rewriteMethodExecutions = false;
    TypeRegistry r = getTypeRegistry("data.HelloWorldFields");
    ReloadableType rtype = r.addType("data.HelloWorldFields", loadBytesForClass("data.HelloWorldFields"));
    assertEquals("Hello Andy", runUnguarded(rtype.getClazz(), "greet").stdout);

    // Just reload that same version (creates new CurrentLiveVersion)
    rtype.loadNewVersion("000", rtype.bytesInitial);
    assertEquals("Hello Andy", runUnguarded(rtype.getClazz(), "greet").stdout);
View Full Code Here

    assertEquals("Hello Christian", runOnInstance(rtype.getClazz(), o, "greet").stdout);
  }

  @Test
  public void primitiveFieldRewriting() throws Exception {
    TypeRegistry r = getTypeRegistry("data.FieldsB");
    ReloadableType rtype = r.addType("data.FieldsB", loadBytesForClass("data.FieldsB"));
    Class<?> c = rtype.getClazz();
    Object instance = c.newInstance();
    assertEquals(23, runOnInstance(c, instance, "getI").returnValue);
    assertEquals("{1,2,3}", intArrayToString(runOnInstance(c, instance, "getIs").returnValue));
    assertEquals(false, runOnInstance(c, instance, "isB").returnValue);
View Full Code Here

    assertEquals("Hello", runOnInstance(c, instance, "getTheMessage").returnValue);
  }

  @Test
  public void primitiveStaticFieldRewriting() throws Exception {
    TypeRegistry r = getTypeRegistry("data.StaticFieldsB");
    ReloadableType rtype = r.addType("data.StaticFieldsB", loadBytesForClass("data.StaticFieldsB"));
    Class<?> c = rtype.getClazz();
    Object instance = c.newInstance();
    assertEquals(23, runOnInstance(c, instance, "getI").returnValue);
    assertEquals(false, runOnInstance(c, instance, "isB").returnValue);
    assertEquals("{true,false,true}", objectArrayToString(runOnInstance(c, instance, "getBs").returnValue));
View Full Code Here

  /**
   * Check the basics.
   */
  @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());
View Full Code Here

  /**
   * Check calling it, reloading it and calling the new version.
   */
  @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");
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"));
View Full Code Here

    runUnguarded(clazz, "time");
  }
 
  @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);
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);
   
   
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.