use of org.springsource.loaded.TypeDescriptor in project spring-loaded by spring-projects.
the class InterfaceExtractorTest method varietyOfMethods.
@Test
public void varietyOfMethods() {
TypeRegistry registry = getTypeRegistry(null);
byte[] classBytes = loadBytesForClass("data.SimpleClassFour");
TypeDescriptor td = new TypeDescriptorExtractor(registry).extract(classBytes, true);
byte[] bytes = InterfaceExtractor.extract(classBytes, registry, td);
// @formatter:off
checkType(bytes, "CLASS: data/SimpleClassFour__I v50 0x0601(public abstract interface) super java/lang/Object\n" + "METHOD: 0x0401(public abstract) ___init___(Ldata/SimpleClassFour;I)V\n" + "METHOD: 0x0401(public abstract) ___init___(Ldata/SimpleClassFour;Ljava/lang/String;)V\n" + "METHOD: 0x0401(public abstract) boo(Ldata/SimpleClassFour;)V\n" + "METHOD: 0x0401(public abstract) foo(Ldata/SimpleClassFour;)V\n" + "METHOD: 0x0401(public abstract) goo(Ldata/SimpleClassFour;IDLjava/lang/String;)Ljava/lang/String;\n" + "METHOD: 0x0401(public abstract) hoo(Ldata/SimpleClassFour;J)I\n" + "METHOD: 0x0401(public abstract) woo(Ldata/SimpleClassFour;)V java/lang/RuntimeException java/lang/IllegalStateException\n" + "METHOD: 0x0401(public abstract) __execute([Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/String;)Ljava/lang/Object;\n" + "METHOD: 0x0401(public abstract) ___clinit___()V\n" + "METHOD: 0x0401(public abstract) hashCode(Ldata/SimpleClassFour;)I\n" + "METHOD: 0x0401(public abstract) equals(Ldata/SimpleClassFour;Ljava/lang/Object;)Z\n" + "METHOD: 0x0401(public abstract) clone(Ldata/SimpleClassFour;)Ljava/lang/Object; java/lang/CloneNotSupportedException\n" + "METHOD: 0x0401(public abstract) toString(Ldata/SimpleClassFour;)Ljava/lang/String;\n" + "\n");
// @formatter:on
}
use of org.springsource.loaded.TypeDescriptor in project spring-loaded by spring-projects.
the class SignatureFinder method gatherSignatures.
/**
* Gathers up all method signatures in a specific version
*
* @throws Exception
*/
private void gatherSignatures(String typeName, String version, Set<String> sigs) {
TypeRegistry tr = getTypeRegistry("");
byte[] bytes = null;
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());
}
}
use of org.springsource.loaded.TypeDescriptor in project spring-loaded by spring-projects.
the class TypeRegistryTests method descriptorsWithCatchers.
@Test
public void descriptorsWithCatchers() {
TypeRegistry typeRegistry = TypeRegistry.getTypeRegistryFor(binLoader);
TypeDescriptor dscDescriptor = typeRegistry.getDescriptorFor("data/SimpleClass");
assertNotNull(dscDescriptor);
assertEquals("data/SimpleClass", dscDescriptor.getName());
// check for a catcher
assertNotNull(findMethod("0x1 toString()Ljava/lang/String;", dscDescriptor));
}
use of org.springsource.loaded.TypeDescriptor in project spring-loaded by spring-projects.
the class TypeDescriptorTests method simpleMethodDescriptors.
@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);
// will include catchers
assertEquals(5, typeDescriptor.getMethods().length);
assertEquals("0x1 foo()V", typeDescriptor.getMethods()[0].toString());
}
use of org.springsource.loaded.TypeDescriptor in project spring-loaded by spring-projects.
the class TypeDescriptorTests method constructorDescriptors.
@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());
assertEquals("()V", publicCtor.getDescriptor());
assertNull(publicCtor.getGenericSignature());
assertEquals("0x1 <init>()V", publicCtor.toString());
MethodMember privateCtor = ctors[1];
assertEquals(Modifier.PRIVATE, privateCtor.getModifiers());
assertEquals("<init>", privateCtor.getName());
assertEquals("(Ljava/lang/String;I)V", privateCtor.getDescriptor());
assertNull(privateCtor.getGenericSignature());
assertEquals("0x2 <init>(Ljava/lang/String;I)V", privateCtor.toString());
MethodMember protCtor = ctors[2];
assertEquals(Modifier.PROTECTED, protCtor.getModifiers());
assertEquals("<init>", protCtor.getName());
assertEquals("(J)V", protCtor.getDescriptor());
assertNull(protCtor.getGenericSignature());
assertEquals("0x4 <init>(J)V", protCtor.toString());
}
Aggregations