Skip to content

Commit fc28421

Browse files
committed
ClassUtils: add some explanation about performance
We may not _always_ need to include interfaces when recursively scanning for annotated methods, but for now it does not seem worth worrying over.
1 parent 0bc3575 commit fc28421

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/main/java/org/scijava/object/DefaultObjectService.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131

3232
package org.scijava.object;
3333

34-
3534
import java.util.List;
3635

3736
import org.scijava.event.EventHandler;

src/main/java/org/scijava/util/ClassUtils.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,13 @@ public static <A extends Annotation> List<Method> getAnnotatedMethods(
311311

312312
// check supertypes for annotated methods first
313313
getAnnotatedMethods(c.getSuperclass(), annotationClass, methods);
314+
// NB: In some cases, we may not need to recursively scan interfaces.
315+
// In particular, for the @EventHandler annotation, we only care about
316+
// concrete methods, not interface method declarations. So we could have
317+
// additional method signatures with a boolean toggle indicating whether
318+
// to include interfaces in the recursive scan. But initial benchmarks
319+
// suggest that the performance difference, even when creating a
320+
// full-blown Context with a large classpath, is negligible.
314321
for (final Class<?> iface : c.getInterfaces()) {
315322
getAnnotatedMethods(iface, annotationClass, methods);
316323
}

0 commit comments

Comments
 (0)