From dfa5c727ed4ee5e7ccf14ee3ddaeeb7241dc5475 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Silva?= Date: Mon, 22 Mar 2021 18:20:32 +0000 Subject: [PATCH] Fix DynamothCodeGenesis MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: André Silva --- nopol/pom.xml | 3 --- .../repair/synthesis/DynamothCodeGenesisImpl.java | 15 +++++++++------ .../repair/synthesis/DynamothCodeGenesisTest.java | 1 + 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/nopol/pom.xml b/nopol/pom.xml index aa215eba..c3de565b 100644 --- a/nopol/pom.xml +++ b/nopol/pom.xml @@ -363,9 +363,6 @@ maven-surefire-plugin 2.18.1 - - -javaagent:lib/ - maven-resources-plugin diff --git a/nopol/src/main/java/fr/inria/lille/repair/synthesis/DynamothCodeGenesisImpl.java b/nopol/src/main/java/fr/inria/lille/repair/synthesis/DynamothCodeGenesisImpl.java index 10092ffd..cd79efbf 100644 --- a/nopol/src/main/java/fr/inria/lille/repair/synthesis/DynamothCodeGenesisImpl.java +++ b/nopol/src/main/java/fr/inria/lille/repair/synthesis/DynamothCodeGenesisImpl.java @@ -103,7 +103,7 @@ public DynamothCodeGenesisImpl(File[] projectRoots, SourceLocation location, URL this.classes = new ArrayList<>(); ClassLoader cl = ClassLoader.getSystemClassLoader(); - URL[] urls = ((URLClassLoader) cl).getURLs(); + String[] pathElements = System.getProperty("java.class.path").split(System.getProperty("path.separator")); ArrayList liClasspath = new ArrayList<>(); for (int i = 0; i < classpath.length; i++) { URL url = classpath[i]; @@ -112,11 +112,14 @@ public DynamothCodeGenesisImpl(File[] projectRoots, SourceLocation location, URL liClasspath.add(url); } } - for (int i = 0; i < urls.length; i++) { - URL url = urls[i]; - File file = new File(url.getFile()); - if (file.exists()) { - liClasspath.add(url); + for (int i = 0; i < pathElements.length; i++) { + try { + File file = new File(pathElements[i]); + if (file.exists()) { + liClasspath.add(file.toURI().toURL()); + } + } catch (Exception e) { + throw new RuntimeException(e); } } this.classpath = liClasspath.toArray(new URL[0]); diff --git a/nopol/src/test/java/fr/inria/lille/repair/synthesis/DynamothCodeGenesisTest.java b/nopol/src/test/java/fr/inria/lille/repair/synthesis/DynamothCodeGenesisTest.java index 14960aa3..73728d34 100644 --- a/nopol/src/test/java/fr/inria/lille/repair/synthesis/DynamothCodeGenesisTest.java +++ b/nopol/src/test/java/fr/inria/lille/repair/synthesis/DynamothCodeGenesisTest.java @@ -1,5 +1,6 @@ package fr.inria.lille.repair.synthesis; +import ca.cgjennings.jvm.JarLoader; import fr.inria.lille.repair.TestUtility; import fr.inria.lille.repair.common.config.NopolContext; import fr.inria.lille.repair.nopol.SourceLocation;