use of org.springsource.loaded.TypeDescriptor 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());
}
use of org.springsource.loaded.TypeDescriptor in project spring-loaded by spring-projects.
the class TypeDescriptorTests method complexMethodDescriptors.
@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());
}
use of org.springsource.loaded.TypeDescriptor in project spring-loaded by spring-projects.
the class TypeRegistryTests method loadingDescriptors.
@Test
public void loadingDescriptors() {
TypeRegistry typeRegistry = TypeRegistry.getTypeRegistryFor(binLoader);
TypeDescriptor jloDescriptor = typeRegistry.getDescriptorFor("java/lang/Object");
assertNotNull(jloDescriptor);
assertEquals("java/lang/Object", jloDescriptor.getName());
}
use of org.springsource.loaded.TypeDescriptor in project spring-loaded by spring-projects.
the class TypeDescriptorMethodProvider method getSuper.
@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);
}
}
}
use of org.springsource.loaded.TypeDescriptor in project spring-loaded by spring-projects.
the class TypeDescriptorMethodProvider method getDeclaredMethods.
@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));
}
}
return invokers;
}
Aggregations