Skip to content

Commit 32ffcb4

Browse files
committed
Fix incremental compiler not being able to find JDK classes when compiler macros with Java 11, close #502
Motivation: Jigsaw has changed the behavior of ClassLoaders. For some reason, ScalaCompilerLoader with a null parent is able to find JDK classes on Java 8 but not on Java 11. Modification: Make the parent the root loader. Result: We can compile macros with Java 11.
1 parent 0800da4 commit 32ffcb4

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/main/java/scala_maven/ScalaCompilerLoader.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
package scala_maven;
1818

19+
import sbt.internal.inc.classpath.ClasspathUtil;
20+
1921
import java.net.URL;
2022
import java.net.URLClassLoader;
2123

@@ -25,7 +27,7 @@ public class ScalaCompilerLoader extends URLClassLoader {
2527
private final ClassLoader sbtLoader;
2628

2729
public ScalaCompilerLoader(URL[] urls, ClassLoader sbtLoader) {
28-
super(urls, null);
30+
super(urls, ClasspathUtil.rootLoader());
2931
this.sbtLoader = sbtLoader;
3032
}
3133

0 commit comments

Comments
 (0)