use of org.springsource.loaded.MethodMember 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.MethodMember in project spring-loaded by spring-projects.
the class TypeRewriterTests method constructorReloadingDefault.
// 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();
// Only the ctor in the original type is in the descriptor
assertEquals(1, ctor.length);
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 });
assertNotNull(result.returnValue);
}
use of org.springsource.loaded.MethodMember 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());
}
use of org.springsource.loaded.MethodMember in project spring-loaded by spring-projects.
the class TypeDescriptorTests method constructorDescriptorsAfterReloading.
@Test
public void constructorDescriptorsAfterReloading() {
TypeRegistry registry = getTypeRegistry("");
String d = "data.SomeConstructors";
ReloadableType rtype = registry.addType(d, loadBytesForClass(d));
MethodMember[] latestConstructors = rtype.getLatestTypeDescriptor().getConstructors();
assertEquals(3, latestConstructors.length);
rtype.loadNewVersion("2", retrieveRename(d, d + "002"));
latestConstructors = rtype.getLatestTypeDescriptor().getConstructors();
assertEquals(1, latestConstructors.length);
}
use of org.springsource.loaded.MethodMember in project spring-loaded by spring-projects.
the class TypeDescriptorTests method defaultConstructorDescriptor.
@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());
assertEquals("<init>", publicCtor.getName());
assertEquals("()V", publicCtor.getDescriptor());
assertNull(publicCtor.getGenericSignature());
assertEquals("0x1 <init>()V", publicCtor.toString());
}
Aggregations