From: Svjatoslav Agejenko Date: Tue, 19 Oct 2021 16:00:27 +0000 (+0300) Subject: Do not crash when class definitions are not found. X-Git-Url: http://www2.svjatoslav.eu/gitweb/?p=javainspect.git;a=commitdiff_plain;h=f9689015962218747805ab58f27dae307cd7ab89 Do not crash when class definitions are not found. --- diff --git a/src/main/java/eu/svjatoslav/inspector/java/commandline/Main.java b/src/main/java/eu/svjatoslav/inspector/java/commandline/Main.java index f8dd577..6a63588 100644 --- a/src/main/java/eu/svjatoslav/inspector/java/commandline/Main.java +++ b/src/main/java/eu/svjatoslav/inspector/java/commandline/Main.java @@ -77,8 +77,14 @@ public class Main { for (String className : getClassNamesFromJar(jarFile)) { if (configuration.isDebug()) System.out.println("Adding class to graph: " + className); - - classGraph.add(loadClassByName(classLoader, className)); + try { + classGraph.add(loadClassByName(classLoader, className)); + } catch (NoClassDefFoundError e){ + if (configuration.isDebug()) + System.out.println("Class definition was not found."); + // Sometimes referenced classes are not found in the same Jar. + // Let's ignore this and proceed with the classes that we have. + } } }