From f9689015962218747805ab58f27dae307cd7ab89 Mon Sep 17 00:00:00 2001 From: Svjatoslav Agejenko Date: Tue, 19 Oct 2021 19:00:27 +0300 Subject: [PATCH] Do not crash when class definitions are not found. --- .../eu/svjatoslav/inspector/java/commandline/Main.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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. + } } } -- 2.20.1