From b5e342cca353401d840c565d8f1bbdf84fa8266a Mon Sep 17 00:00:00 2001 From: Rajiv Date: Tue, 6 Oct 2020 14:03:44 +0530 Subject: [PATCH] Added jinsight.jar location to ContextualModuleLoader --- .../jinsight/ContextualModuleLoader.java | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/src/main/java/ai/apptuit/metrics/jinsight/ContextualModuleLoader.java b/src/main/java/ai/apptuit/metrics/jinsight/ContextualModuleLoader.java index 59fb811..923c367 100644 --- a/src/main/java/ai/apptuit/metrics/jinsight/ContextualModuleLoader.java +++ b/src/main/java/ai/apptuit/metrics/jinsight/ContextualModuleLoader.java @@ -106,35 +106,28 @@ private static URL[] getSystemClassPath() { } ArrayList path = new ArrayList<>(); - int off; if (cp != null) { - off = 0; - + int off = 0; int next; do { next = cp.indexOf(File.pathSeparator, off); String element = next == -1 ? cp.substring(off) : cp.substring(off, next); if (!element.isEmpty()) { - URL url = toFileURL(element); - if (url != null) { + try { + URL url = (new File(element)).getCanonicalFile().toURI().toURL(); path.add(url); + } catch (IOException ignored) { + //Ignore invalid urls } } off = next + 1; } while (next != -1); } + path.add(ContextualModuleLoader.class.getProtectionDomain().getCodeSource().getLocation()); return path.toArray(new URL[0]); } - private static URL toFileURL(String path) { - try { - return (new File(path)).getCanonicalFile().toURI().toURL(); - } catch (IOException e) { - return null; - } - } - public Class addClass(String name, byte[] bytes) throws ClassFormatError { Class cl = defineClass(name, bytes, 0, bytes.length);