Do not crash when class definitions are not found.
[javainspect.git] / 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.
+            }
         }
     }