Package org.springsource.loaded

Examples of org.springsource.loaded.TypeDescriptor


  @Test
  public void simpleMethodDescriptors() {
    TypeRegistry registry = getTypeRegistry("data.SimpleClass");
    byte[] bytes = loadBytesForClass("data.SimpleClass");
    TypeDescriptor typeDescriptor = new TypeDescriptorExtractor(registry).extract(bytes, true);
    assertEquals("data/SimpleClass", typeDescriptor.getName());
    assertEquals("java/lang/Object", typeDescriptor.getSupertypeName());
    assertEquals(0, typeDescriptor.getSuperinterfacesName().length);
    assertEquals(0x20, typeDescriptor.getModifiers());
    assertEquals(0, typeDescriptor.getFields().length);
    assertEquals(5, typeDescriptor.getMethods().length); // will include catchers
    assertEquals("0x1 foo()V", typeDescriptor.getMethods()[0].toString());
  }
View Full Code Here


  @Test
  public void complexMethodDescriptors() {
    TypeRegistry registry = getTypeRegistry("data.ComplexClass");
    byte[] bytes = loadBytesForClass("data.ComplexClass");
    TypeDescriptor typeDescriptor = new TypeDescriptorExtractor(registry).extract(bytes, true);
    assertEquals("data/ComplexClass", typeDescriptor.getName());
    assertEquals("data/SimpleClass", typeDescriptor.getSupertypeName());
    assertEquals(1, typeDescriptor.getSuperinterfacesName().length);
    assertEquals("java/io/Serializable", typeDescriptor.getSuperinterfacesName()[0]);
    assertEquals(0x20, typeDescriptor.getModifiers());
    assertEquals(3, typeDescriptor.getFields().length);
    assertEquals(9, typeDescriptor.getMethods().length);
    assertEquals("0x2 privateMethod()I", typeDescriptor.getMethods()[0].toString());
    assertEquals("0x1 publicMethod()Ljava/lang/String;", typeDescriptor.getMethods()[1].toString());
    assertEquals("0x0 defaultMethod()Ljava/util/List;", typeDescriptor.getMethods()[2].toString());
    assertEquals("0x0 thrower()V throws java/lang/Exception java/lang/IllegalStateException",
        typeDescriptor.getMethods()[3].toString());
  }
View Full Code Here

  @Test
  public void fieldDescriptors() {
    TypeRegistry registry = getTypeRegistry("");
    byte[] bytes = loadBytesForClass("data.SomeFields");
    TypeDescriptor typeDescriptor = new TypeDescriptorExtractor(registry).extract(bytes, false);
    FieldMember[] fields = typeDescriptor.getFields();
    assertEquals(4, fields.length);
    FieldMember privateField = fields[0];
    assertEquals(Modifier.PRIVATE, privateField.getModifiers());
    assertEquals("privateField", privateField.getName());
    assertEquals("I", privateField.getDescriptor());
View Full Code Here

  @Test
  public void constructorDescriptors() {
    TypeRegistry registry = getTypeRegistry("");
    byte[] bytes = loadBytesForClass("data.SomeConstructors");
    TypeDescriptor typeDescriptor = new TypeDescriptorExtractor(registry).extract(bytes, false);
    MethodMember[] ctors = typeDescriptor.getConstructors();
    assertEquals(3, ctors.length);

    MethodMember publicCtor = ctors[0];
    assertEquals(Modifier.PUBLIC, publicCtor.getModifiers());
    assertEquals("<init>", publicCtor.getName());
View Full Code Here

  @Test
  public void defaultConstructorDescriptor() {
    TypeRegistry registry = getTypeRegistry("");
    byte[] bytes = loadBytesForClass("data.SomeConstructors2");
    TypeDescriptor typeDescriptor = new TypeDescriptorExtractor(registry).extract(bytes, false);
    MethodMember[] ctors = typeDescriptor.getConstructors();
    assertEquals(1, ctors.length);

    MethodMember publicCtor = ctors[0];
    // visibility matches type vis (for public/default)
    assertEquals(Modifier.PUBLIC, publicCtor.getModifiers());
View Full Code Here

    String className = TARGET_PACKAGE + ".GetMethodClass";
    ReloadableType rtype = reloadableClass(className);
    reloadType(rtype, "002");

    TypeDescriptor descriptor = rtype.getLatestTypeDescriptor();
    for (MethodMember m : descriptor.getMethods()) {
      System.out.println(m);
      if (m.getName().equals("im2")) {
        return; //Fine!
      }
    }
View Full Code Here

  protected abstract Invoker invokerFor(MethodMember methodMember);

  @Override
  public List<Invoker> getDeclaredMethods() {
    TypeDescriptor typeDescriptor = getTypeDescriptor();
    MethodMember[] methods = typeDescriptor.getMethods();
    List<Invoker> invokers = new ArrayList<Invoker>();
    for (MethodMember method : methods) {
      // TODO [perf] create constant for this check?
      if (((MethodMember.BIT_CATCHER | MethodMember.BIT_SUPERDISPATCHER | MethodMember.WAS_DELETED) & method.bits) == 0) {
        invokers.add(invokerFor(method));
View Full Code Here

  }

  @Override
  public MethodProvider getSuper() {
    TypeRegistry registry = getTypeRegistry();
    TypeDescriptor typeDesc = getTypeDescriptor();
    String superName = typeDesc.getSupertypeName();
    if (superName == null) {
      //This happens only for type Object... Code unreachable unless Object is reloadable
      return null;
    } else {
      ReloadableType rsuper = registry.getReloadableType(superName);
      if (rsuper != null) {
        return MethodProvider.create(rsuper);
      } else {
        TypeDescriptor dsuper = registry.getDescriptorFor(superName);
        return MethodProvider.create(registry, dsuper);
      }
    }
  }
View Full Code Here

    if (version.equals("")) {
      bytes = loadBytesForClass(typeName);
    } else {
      bytes = retrieveRename(typeName, typeName + version);
    }
    TypeDescriptor typeDescriptor = new TypeDescriptorExtractor(tr).extract(bytes, true);
    for (MethodMember method : typeDescriptor.getMethods()) {
      sigs.add(method.getNameAndDescriptor());
    }
  }
View Full Code Here

    if (version.equals("")) {
      bytes = loadBytesForClass(typeName);
    } else {
      bytes = retrieveRename(typeName, typeName + version);
    }
    TypeDescriptor typeDescriptor = new TypeDescriptorExtractor(tr).extract(bytes, true);
    for (MethodMember method : typeDescriptor.getConstructors()) {
      sigs.add(method.getDescriptor());
    }
  }
View Full Code Here

TOP

Related Classes of org.springsource.loaded.TypeDescriptor

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.