use of org.springsource.loaded.TypeDescriptor in project spring-loaded by spring-projects.
the class SignatureFinder method gatherConstructorSignatures.
private void gatherConstructorSignatures(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.getConstructors()) {
sigs.add(method.getDescriptor());
}
}
use of org.springsource.loaded.TypeDescriptor in project spring-loaded by spring-projects.
the class TypeDescriptorExtractorTests method nonReloadableExtract.
@Test
public void nonReloadableExtract() {
TypeRegistry tr = getTypeRegistry("");
byte[] bytes = loadBytesForClass("java.lang.Object");
TypeDescriptor typeDescriptor = new TypeDescriptorExtractor(tr).extract(bytes, false);
System.out.println(typeDescriptor.toString());
Assert.assertEquals("java/lang/Object", typeDescriptor.getName());
Assert.assertEquals(null, typeDescriptor.getSupertypeName());
Assert.assertEquals(0, typeDescriptor.getSuperinterfacesName().length);
Assert.assertEquals(0x21, typeDescriptor.getModifiers());
Assert.assertEquals(0, typeDescriptor.getFields().length);
Assert.assertEquals(12, typeDescriptor.getMethods().length);
Assert.assertNotNull(findMethod("0x104 clone()Ljava/lang/Object; throws java/lang/CloneNotSupportedException", typeDescriptor));
}
use of org.springsource.loaded.TypeDescriptor in project spring-loaded by spring-projects.
the class TypeDescriptorExtractorTests method simpleExtractor.
/**
* Test extraction on a very simple class.
*/
@Test
public void simpleExtractor() {
TypeRegistry tr = getTypeRegistry("");
byte[] bytes = loadBytesForClass("data.SimpleClass");
TypeDescriptor typeDescriptor = new TypeDescriptorExtractor(tr).extract(bytes, true);
Assert.assertEquals("data/SimpleClass", typeDescriptor.getName());
Assert.assertEquals("java/lang/Object", typeDescriptor.getSupertypeName());
Assert.assertEquals(0, typeDescriptor.getSuperinterfacesName().length);
Assert.assertEquals(0x20, typeDescriptor.getModifiers());
Assert.assertEquals(0, typeDescriptor.getFields().length);
Assert.assertEquals(5, typeDescriptor.getMethods().length);
Assert.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 fieldDescriptors.
@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());
assertNull(privateField.getGenericSignature());
assertEquals("0x2 I privateField", privateField.toString());
FieldMember publicField = fields[1];
assertEquals(Modifier.PUBLIC, publicField.getModifiers());
assertEquals("publicField", publicField.getName());
assertEquals("Ljava/lang/String;", publicField.getDescriptor());
assertNull(publicField.getGenericSignature());
assertEquals("0x1 Ljava/lang/String; publicField", publicField.toString());
FieldMember defaultField = fields[2];
assertEquals(0, defaultField.getModifiers());
assertEquals("defaultField", defaultField.getName());
assertEquals("Ljava/util/List;", defaultField.getDescriptor());
assertEquals("Ljava/util/List<Ljava/lang/String;>;", defaultField.getGenericSignature());
assertEquals("0x0 Ljava/util/List; defaultField [Ljava/util/List<Ljava/lang/String;>;]", defaultField.toString());
FieldMember protectedField = fields[3];
assertEquals(Modifier.PROTECTED, protectedField.getModifiers());
assertEquals("protectedField", protectedField.getName());
assertEquals("Ljava/util/Map;", protectedField.getDescriptor());
assertEquals("Ljava/util/Map<Ljava/lang/String;Ljava/util/List<Ljava/lang/Integer;>;>;", protectedField.getGenericSignature());
assertEquals("0x4 Ljava/util/Map; protectedField [Ljava/util/Map<Ljava/lang/String;Ljava/util/List<Ljava/lang/Integer;>;>;]", protectedField.toString());
}
use of org.springsource.loaded.TypeDescriptor in project spring-loaded by spring-projects.
the class TypeRegistryTests method descriptorsWithCatchers2.
@Test
public void descriptorsWithCatchers2() {
// more complicated hierarchy
TypeRegistry typeRegistry = TypeRegistry.getTypeRegistryFor(binLoader);
TypeDescriptor topDescriptor = typeRegistry.getDescriptorFor("catchers/Top");
assertNotNull(topDescriptor);
// Checking no toString() catcher because Top defines a toString()
assertEquals(5, topDescriptor.getMethods().length);
// if 'Top' is not considered reloadable we will get an entry for 'foo' that is inherited from it
TypeDescriptor middleDescriptor = typeRegistry.getDescriptorFor("catchers/Middle");
assertNotNull(middleDescriptor);
assertEquals(5, middleDescriptor.getMethods().length);
TypeDescriptor bottomDescriptor = typeRegistry.getDescriptorFor("catchers/Bottom");
assertNotNull(bottomDescriptor);
System.out.println(bottomDescriptor.toString());
assertEquals(5, bottomDescriptor.getMethods().length);
}
Aggregations