Do not crash when class definitions are not found.
authorSvjatoslav Agejenko <svjatoslav@svjatoslav.eu>
Tue, 19 Oct 2021 16:00:27 +0000 (19:00 +0300)
committerSvjatoslav Agejenko <svjatoslav@svjatoslav.eu>
Tue, 19 Oct 2021 16:00:27 +0000 (19:00 +0300)
src/main/java/eu/svjatoslav/inspector/java/commandline/Main.java

index f8dd577..6a63588 100644 (file)
@@ -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.
+            }
         }
     }