Details
-
Type: Bug
-
Status: Open
-
Priority: Major
-
Resolution: Unresolved
-
Affects Version/s: None
-
Fix Version/s: None
-
Component/s: None
-
Labels:None
-
Environment:all
Description
Code snippet from WindowScopeManager:
private static void callAnnotatedMethod(Object object, Class annotation) {
Class theClass = object.getClass();
try {
while (null != theClass) {
Method[] methods = object.getClass().getDeclaredMethods();
for (Method method : methods) {
if (method.isAnnotationPresent(annotation)) {
method.setAccessible(true);
method.invoke(object);
return;
}
}
theClass = theClass.getSuperclass();
}
} catch (Exception e) {
log.log(Level.WARNING, "Failed to invoke" + annotation + " on " + theClass, e);
}
}
This code finds annotations on a class but not on any ancestor classes.
The line:
Method[] methods = object.getClass().getDeclaredMethods();
should be replaced with:
Method[] methods = theClass.getDeclaredMethods();
private static void callAnnotatedMethod(Object object, Class annotation) {
Class theClass = object.getClass();
try {
while (null != theClass) {
Method[] methods = object.getClass().getDeclaredMethods();
for (Method method : methods) {
if (method.isAnnotationPresent(annotation)) {
method.setAccessible(true);
method.invoke(object);
return;
}
}
theClass = theClass.getSuperclass();
}
} catch (Exception e) {
log.log(Level.WARNING, "Failed to invoke" + annotation + " on " + theClass, e);
}
}
This code finds annotations on a class but not on any ancestor classes.
The line:
Method[] methods = object.getClass().getDeclaredMethods();
should be replaced with:
Method[] methods = theClass.getDeclaredMethods();
Activity
- All
- Comments
- History
- Activity
- Remote Attachments
- Subversion