Skip to content

Commit ca36271

Browse files
committed
DirectoryIndexer: be nice about classes we know nothing about
Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 3dae42b commit ca36271

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/main/java/org/scijava/annotations/DirectoryIndexer.java

+11-7
Original file line numberDiff line numberDiff line change
@@ -82,21 +82,25 @@ protected void discoverAnnotations(final File directory,
8282
discoverAnnotations(file, classNamePrefix + file.getName() + ".",
8383
loader);
8484
}
85-
else if (file.isFile()) try {
85+
else if (file.isFile()) {
8686
final String fileName = file.getName();
8787
if (!fileName.endsWith(".class")) {
8888
continue;
8989
}
9090
final String className =
9191
classNamePrefix + fileName.substring(0, fileName.length() - 6);
92-
final Class<?> clazz = loader.loadClass(className);
93-
for (final Annotation a : clazz.getAnnotations()) {
94-
add(a, className);
92+
try {
93+
final Class<?> clazz = loader.loadClass(className);
94+
for (final Annotation a : clazz.getAnnotations()) {
95+
add(a, className);
96+
}
97+
} catch (NoClassDefFoundError e) {
98+
System.err.println("Warning: could not load class '" + className + "' ("
99+
+ e.getMessage() + "); skipping");
100+
} catch (ClassNotFoundException e) {
101+
System.err.println("Warning: could not load class '" + className + "'; skipping");
95102
}
96103
}
97-
catch (ClassNotFoundException e) {
98-
throw new IOException(e);
99-
}
100104
}
101105
}
102106

0 commit comments

Comments
 (0)