use of org.springsource.loaded.CurrentLiveVersion in project spring-loaded by spring-projects.
the class ReflectiveInterceptor method jlClassGetDeclaredAnnotations.
/**
* Called to satisfy an invocation of java.lang.Class.getDeclaredAnnotations().
*
* @param clazz the class upon which the original call was being invoked
* @return array of annotations on the class
*/
public static Annotation[] jlClassGetDeclaredAnnotations(Class<?> clazz) {
if (TypeRegistry.nothingReloaded) {
return clazz.getDeclaredAnnotations();
}
ReloadableType rtype = getReloadableTypeIfHasBeenReloaded(clazz);
if (rtype == null) {
return clazz.getDeclaredAnnotations();
}
CurrentLiveVersion clv = rtype.getLiveVersion();
return clv.getExecutorClass().getDeclaredAnnotations();
}
use of org.springsource.loaded.CurrentLiveVersion in project spring-loaded by spring-projects.
the class ReflectiveInterceptor method jlrConstructorIsAnnotationPresent.
public static boolean jlrConstructorIsAnnotationPresent(Constructor<?> c, Class<? extends Annotation> annotType) {
ReloadableType rtype = getReloadableTypeIfHasBeenReloaded(c.getDeclaringClass());
if (rtype == null) {
//Nothing special to be done
return c.isAnnotationPresent(annotType);
} else {
// Constructor could have changed...
CurrentLiveVersion clv = rtype.getLiveVersion();
Method executor = clv.getExecutorMethod(rtype.getCurrentConstructor(Type.getConstructorDescriptor(c)));
return executor.isAnnotationPresent(annotType);
}
}
use of org.springsource.loaded.CurrentLiveVersion 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.CurrentLiveVersion in project spring-loaded by spring-projects.
the class ReflectiveInterceptor method jlrFieldGetDeclaredAnnotations.
public static Annotation[] jlrFieldGetDeclaredAnnotations(Field field) {
ReloadableType rtype = getReloadableTypeIfHasBeenReloaded(field.getDeclaringClass());
if (rtype == null) {
//Nothing special to be done
return field.getDeclaredAnnotations();
} else {
// Field could have changed...
CurrentLiveVersion clv = rtype.getLiveVersion();
Field executor;
try {
executor = clv.getExecutorField(field.getName());
return executor.getAnnotations();
} catch (Exception e) {
throw new IllegalStateException(e);
}
}
}
use of org.springsource.loaded.CurrentLiveVersion 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;
}
}
Aggregations