Skip to content
This repository has been archived by the owner on Jun 3, 2024. It is now read-only.

Fixing issue Method lookup fails with generic parameter #166

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/main/java/com/ryantenney/metrics/spring/AnnotationFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@
class AnnotationFilter implements MethodFilter, FieldFilter {

private static final Logger LOG = LoggerFactory.getLogger(AnnotationFilter.class);
private static final int SYNTHETIC_METHOD_MODIFIER = 0x00001000;
private static final MethodFilter USER_DECLARED_OR_SYNTHETIC_METHODS = new MethodFilter() {
public boolean matches(Method method) {
return (method.getDeclaringClass() != Object.class);
}
};

public static final int FIELDS =
Modifier.PUBLIC | Modifier.PROTECTED | Modifier.PRIVATE |
Expand All @@ -42,7 +48,9 @@ class AnnotationFilter implements MethodFilter, FieldFilter {
Modifier.PUBLIC | Modifier.PROTECTED | Modifier.PRIVATE |
Modifier.ABSTRACT | Modifier.STATIC | Modifier.FINAL |
Modifier.SYNCHRONIZED | Modifier.NATIVE | Modifier.STRICT |
Modifier.TRANSIENT; // TRANSIENT flag is the same as the VARARGS flag
Modifier.TRANSIENT | // TRANSIENT flag is the same as the VARARGS flag
Modifier.VOLATILE | // VOLATILE flag is the same as BRIDGE flag
SYNTHETIC_METHOD_MODIFIER;

public static final int INJECTABLE_FIELDS = FIELDS ^ (FINAL | STATIC);
public static final int INSTANCE_FIELDS = FIELDS ^ STATIC;
Expand All @@ -69,7 +77,7 @@ public AnnotationFilter(final Class<? extends Annotation> clazz, final int metho

@Override
public boolean matches(Method method) {
if (USER_DECLARED_METHODS.matches(method) && method.isAnnotationPresent(clazz)) {
if(USER_DECLARED_OR_SYNTHETIC_METHODS.matches(method) && method.isAnnotationPresent(clazz)) {
if (checkModifiers(method, methodModifiers)) {
return true;
}
Expand Down