Package org.springsource.loaded

Examples of org.springsource.loaded.TypeRegistry$BsmInfo


  // Looking at a type with only a default ctor (so didn't originally declare anything)
  @Test
  public void constructorReloadingDefault() throws Exception {
    String t = "ctors.Default";
    TypeRegistry r = getTypeRegistry(t);
    ReloadableType rtype = r.addType(t, loadBytesForClass(t));
    MethodMember[] ctor = rtype.getLatestTypeDescriptor().getConstructors();
    assertEquals(1, ctor.length); // Only the ctor in the original type is in the descriptor
    assertEquals("0x1 <init>()V", ctor[0].toString());
    // There are in fact two constructors, one is our special one
    result = runConstructor(rtype.getClazz(), magicDescriptorForGeneratedCtors, new Object[] { null });
View Full Code Here


  // Tests for reloading the body of an existing constructor
  @Test
  public void constructorReloading() throws Exception {
    String t = "ctors.One";
    TypeRegistry r = getTypeRegistry(t);
    ReloadableType rtype = r.addType(t, loadBytesForClass(t));

    result = runConstructor(rtype.getClazz(), "");
    assertEquals("Hello Andy", result.stdout);
    assertEquals(rtype.getClazz().getName(), result.returnValue.getClass().getName());
View Full Code Here

  // similar to previous but constructor takes a parameter
  @Test
  public void constructorReloading2() throws Exception {
    String t = "ctors.Two";
    TypeRegistry r = getTypeRegistry(t);
    ReloadableType rtype = r.addType(t, loadBytesForClass(t));

    result = runConstructor(rtype.getClazz(), "java.lang.String", "Wibble");
    assertEquals("Wibble", result.stdout);
    assertEquals(rtype.getClazz().getName(), result.returnValue.getClass().getName());
View Full Code Here

   */
  @Test
  public void annotation() throws Exception {
    String a = "annos.SimpleAnnotation";
    String b = "annos.AnnotatedType";
    TypeRegistry r = getTypeRegistry(a + "," + b);
    ReloadableType annotationType = r.addType(a, loadBytesForClass(a));
    ReloadableType annotatedType = r.addType(b, loadBytesForClass(b));

    assertNull(annotationType);
    result = runUnguarded(annotatedType.getClazz(), "printit");
    assertEquals("@annos.SimpleAnnotation(value=hello)", result.stdout);

View Full Code Here

   * Testing reflective field access when the field flips from static to non-static.
   */
  @Test
  public void reflectiveFieldGet() throws Exception {
    String a = "reflect.FieldAccessing";
    TypeRegistry r = getTypeRegistry(a);
    ReloadableType type = r.addType(a, loadBytesForClass(a));

    Object o = type.getClazz().newInstance();

    // Access the fields
    result = runOnInstance(type.getClazz(), o, "geti");
View Full Code Here

   * Testing reflective field access when the field flips from static to non-static.
   */
  @Test
  public void reflectiveFieldSet() throws Exception {
    String a = "reflect.FieldWriting";
    TypeRegistry r = getTypeRegistry(a);
    ReloadableType type = r.addType(a, loadBytesForClass(a));

    Object o = type.getClazz().newInstance();

    // Access the fields
    result = runOnInstance(type.getClazz(), o, "seti", 123);
View Full Code Here

  // test that also relies on correct dispatch to super constructors to do things
  @Test
  public void constructorReloading3() throws Exception {
    String t = "ctors.Three";
    String st = "ctors.SuperThree";
    TypeRegistry r = getTypeRegistry(t + ",ctors.SuperThree");

    ReloadableType supertype = r.addType("ctors.SuperThree", loadBytesForClass("ctors.SuperThree"));
    ReloadableType rtype = r.addType(t, loadBytesForClass(t));

    result = runConstructor(rtype.getClazz(), "");
    assertEquals("Hello from SuperThree.Hello from Three.", result.stderr);
    assertEquals(rtype.getClazz().getName(), result.returnValue.getClass().getName());
View Full Code Here

  // Now looking at simply changing what fields we initialize in a ctor - the simplest case really
  @Test
  public void constructorReloading4() throws Exception {
    String theType = "ctors.Setter";
    TypeRegistry r = getTypeRegistry(theType);
    ReloadableType rtype = r.addType(theType, loadBytesForClass(theType));

    result = runConstructor(rtype.getClazz(), "");
    Result res = runOnInstance(rtype.getClazz(), result.returnValue, "getInteger");
    assertEquals(1, ((Integer) res.returnValue).intValue());
    res = runOnInstance(rtype.getClazz(), result.returnValue, "getString");
View Full Code Here

  @Test
  public void constructorReloading5() throws Exception {
    String supertype = "ctors.A";
    String subtype = "ctors.B";
    TypeRegistry r = getTypeRegistry(supertype + "," + subtype);
    ReloadableType rsupertype = r.addType(supertype, loadBytesForClass(supertype));
    ReloadableType rsubtype = r.addType(subtype, loadBytesForClass(subtype));
    Result res = null;

    // Use the code 'untouched'
    result = runConstructor(rsubtype.getClazz(), "int", 3);
    res = runOnInstance(rsubtype.getClazz(), result.returnValue, "getString");
View Full Code Here

  // Looking at how constructors get rewritten when the target did not originally declare the constructor
  @Test
  public void newConstructors() throws Exception {
    String caller = "ctors.Caller";
    String callee = "ctors.Callee";
    TypeRegistry r = getTypeRegistry(caller + "," + callee);
    ReloadableType rcaller = r.addType(caller, loadBytesForClass(caller));
    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

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.