Skip to content

Commit f7ba645

Browse files
committed
AppUtils: be defensive if no main class found
Otherwise, Types.location throws NPE later.
1 parent 5641c20 commit f7ba645

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ public static File getBaseDirectory(final String sysProp, final Class<?> c,
104104
// repository cache (~/.m2/repository), so the corePath will be null.
105105
// However, the classes of the launching project will be located in
106106
// target/classes, so we search up the tree from one of those.
107-
final File appPath = AppUtils.getBaseDirectory(AppUtils.getMainClass());
107+
final Class<?> mc = AppUtils.getMainClass();
108+
final File appPath = mc == null ? null : AppUtils.getBaseDirectory(mc);
108109
if (appPath != null) return appPath;
109110

110111
// last resort: use current working directory

0 commit comments

Comments
 (0)