From f87980390c08cb09f20b20e6fbbeddaf4d6cf4c7 Mon Sep 17 00:00:00 2001 From: "Jurgen J. Vinju" Date: Mon, 17 Jun 2024 14:55:17 +0200 Subject: [PATCH] added target folder back to the classpath for loading Java classes --- src/org/rascalmpl/library/util/Eval.java | 2 +- src/org/rascalmpl/library/util/PathConfig.java | 4 ++++ src/org/rascalmpl/shell/ShellEvaluatorFactory.java | 2 +- .../rascalmpl/test/infrastructure/RascalJUnitTestRunner.java | 2 +- src/org/rascalmpl/uri/classloaders/PathConfigClassLoader.java | 2 +- 5 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/org/rascalmpl/library/util/Eval.java b/src/org/rascalmpl/library/util/Eval.java index 2fd9b3da09b..a73acca0f0a 100644 --- a/src/org/rascalmpl/library/util/Eval.java +++ b/src/org/rascalmpl/library/util/Eval.java @@ -243,7 +243,7 @@ public RascalRuntime(PathConfig pcfg, InputStream input, OutputStream stderr, Ou eval.addRascalSearchPath((ISourceLocation) path); } - ClassLoader cl = new SourceLocationClassLoader(pcfg.getLibs(), ShellEvaluatorFactory.class.getClassLoader()); + ClassLoader cl = new SourceLocationClassLoader(pcfg.getLibsAndTarget(), ShellEvaluatorFactory.class.getClassLoader()); eval.addClassLoader(cl); } diff --git a/src/org/rascalmpl/library/util/PathConfig.java b/src/org/rascalmpl/library/util/PathConfig.java index 960a100863a..987f056fbf2 100644 --- a/src/org/rascalmpl/library/util/PathConfig.java +++ b/src/org/rascalmpl/library/util/PathConfig.java @@ -289,6 +289,10 @@ public PathConfig addIgnoreLoc(ISourceLocation dir) throws IOException { public IList getLibs() { return vf.list(libs.toArray(new IValue[0])); } + + public IList getLibsAndTarget() { + return getLibs().append(getBin()); + } public PathConfig addLibLoc(ISourceLocation dir) throws IOException { List extendedlibs = new ArrayList(libs); diff --git a/src/org/rascalmpl/shell/ShellEvaluatorFactory.java b/src/org/rascalmpl/shell/ShellEvaluatorFactory.java index 452e536e5d9..3c42de70f8e 100644 --- a/src/org/rascalmpl/shell/ShellEvaluatorFactory.java +++ b/src/org/rascalmpl/shell/ShellEvaluatorFactory.java @@ -77,7 +77,7 @@ public static void configureProjectEvaluator(Evaluator evaluator, ISourceLocatio evaluator.addRascalSearchPath((ISourceLocation) path); } - ClassLoader cl = new SourceLocationClassLoader(pcfg.getLibs(), ShellEvaluatorFactory.class.getClassLoader()); + ClassLoader cl = new SourceLocationClassLoader(pcfg.getLibsAndTarget(), ShellEvaluatorFactory.class.getClassLoader()); evaluator.addClassLoader(cl); } diff --git a/src/org/rascalmpl/test/infrastructure/RascalJUnitTestRunner.java b/src/org/rascalmpl/test/infrastructure/RascalJUnitTestRunner.java index 4c615019d9e..d0967460517 100644 --- a/src/org/rascalmpl/test/infrastructure/RascalJUnitTestRunner.java +++ b/src/org/rascalmpl/test/infrastructure/RascalJUnitTestRunner.java @@ -111,7 +111,7 @@ public static void configureProjectEvaluator(Evaluator evaluator, ISourceLocatio evaluator.addRascalSearchPath((ISourceLocation) path); } - ClassLoader cl = new SourceLocationClassLoader(pcfg.getLibs(), ShellEvaluatorFactory.class.getClassLoader()); + ClassLoader cl = new SourceLocationClassLoader(pcfg.getLibsAndTarget(), ShellEvaluatorFactory.class.getClassLoader()); evaluator.addClassLoader(cl); } catch (AssertionError e) { diff --git a/src/org/rascalmpl/uri/classloaders/PathConfigClassLoader.java b/src/org/rascalmpl/uri/classloaders/PathConfigClassLoader.java index 561f622947a..9b9b1b89b5c 100644 --- a/src/org/rascalmpl/uri/classloaders/PathConfigClassLoader.java +++ b/src/org/rascalmpl/uri/classloaders/PathConfigClassLoader.java @@ -21,6 +21,6 @@ */ public class PathConfigClassLoader extends SourceLocationClassLoader { public PathConfigClassLoader(PathConfig pcfg, ClassLoader parent) { - super(pcfg.getLibs(), parent); + super(pcfg.getLibsAndTarget(), parent); } }