use of org.springsource.loaded.MethodMember in project spring-loaded by spring-projects.
the class ReflectiveInterceptor method isDeleted.
private static boolean isDeleted(Constructor<?> c) {
ReloadableType rtype = getReloadableTypeIfHasBeenReloaded(c.getDeclaringClass());
if (rtype == null) {
return false;
} else {
TypeDescriptor desc = rtype.getLatestTypeDescriptor();
MethodMember currentConstructor = desc.getConstructor(Type.getConstructorDescriptor(c));
if (currentConstructor == null) {
// Method not there, consider it deleted
return true;
} else {
return false;
}
}
}
use of org.springsource.loaded.MethodMember in project spring-loaded by spring-projects.
the class ReflectiveInterceptor method jlrMethodGetDeclaredAnnotations.
public static Annotation[] jlrMethodGetDeclaredAnnotations(Method method) {
ReloadableType rtype = getReloadableTypeIfHasBeenReloaded(method.getDeclaringClass());
if (rtype == null) {
//Nothing special to be done
return method.getDeclaredAnnotations();
} else {
// Method could have changed...
CurrentLiveVersion clv = rtype.getLiveVersion();
MethodMember methodMember = rtype.getCurrentMethod(method.getName(), Type.getMethodDescriptor(method));
if (MethodMember.isCatcher(methodMember)) {
if (clv.getExecutorMethod(methodMember) != null) {
throw new IllegalStateException();
}
return method.getDeclaredAnnotations();
}
Method executor = clv.getExecutorMethod(methodMember);
return executor.getAnnotations();
}
}
use of org.springsource.loaded.MethodMember in project spring-loaded by spring-projects.
the class ReflectiveInterceptor method jlrConstructorGetParameterAnnotations.
public static Annotation[][] jlrConstructorGetParameterAnnotations(Constructor<?> c) {
ReloadableType rtype = getReloadableTypeIfHasBeenReloaded(c.getDeclaringClass());
if (rtype == null) {
//Nothing special to be done
return c.getParameterAnnotations();
} else {
// Method could have changed...
CurrentLiveVersion clv = rtype.getLiveVersion();
MethodMember currentConstructor = rtype.getCurrentConstructor(Type.getConstructorDescriptor(c));
Method executor = clv.getExecutorMethod(currentConstructor);
Annotation[][] result = executor.getParameterAnnotations();
//Constructor executor methods have an extra param.
//Though extra param is added to front... annotations aren't being moved so we have to actually drop
//the *last* array element
result = Utils.arrayCopyOf(result, result.length - 1);
return result;
}
}
use of org.springsource.loaded.MethodMember in project spring-loaded by spring-projects.
the class ClassReflectionTests method testSomeBug.
@Test
public void testSomeBug() throws Exception {
reloadableClass(TARGET_PACKAGE + ".GetMethodInterface");
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")) {
//Fine!
return;
}
}
fail("There should be an im2 method");
}
use of org.springsource.loaded.MethodMember in project spring-loaded by spring-projects.
the class IncrementalTypeDescriptorTests method changedModifiers.
// More subtle changes (modifier flags)
@Test
public void changedModifiers() throws Exception {
TypeRegistry registry = getTypeRegistry("");
byte[] bytes = loadBytesForClass("typedescriptor.C");
TypeDescriptor typeDescriptor = registry.getExtractor().extract(bytes, true);
byte[] bytes2 = ClassRenamer.rename("typedescriptor.C", loadBytesForClass("typedescriptor.C2"));
TypeDescriptor typeDescriptor2 = registry.getExtractor().extract(bytes2, true);
IncrementalTypeDescriptor itd = new IncrementalTypeDescriptor(typeDescriptor);
itd.setLatestTypeDescriptor(typeDescriptor2);
System.out.println(itd.toString(true));
List<MethodMember> changed = itd.getNewOrChangedMethods();
MethodMember m = getMethod(changed, "staticMethod");
Assert.assertTrue(IncrementalTypeDescriptor.isNowNonStatic(m));
m = getMethod(changed, "instanceMethod");
Assert.assertTrue(IncrementalTypeDescriptor.isNowStatic(m));
m = getMethod(changed, "publicMethod1");
Assert.assertTrue(IncrementalTypeDescriptor.hasVisibilityChanged(m));
// TODO Not detected as protected methods always made public in reloadable types... is that OK?
// m = getMethod(changed, "publicMethod2");
// Assert.assertTrue(IncrementalTypeDescriptor.hasVisibilityChanged(m));
m = getMethod(changed, "publicMethod3");
Assert.assertTrue(IncrementalTypeDescriptor.hasVisibilityChanged(m));
}
Aggregations