diff --git a/community-build/community-projects/PPrint b/community-build/community-projects/PPrint index 7a668f52cc19..231bc187faad 160000 --- a/community-build/community-projects/PPrint +++ b/community-build/community-projects/PPrint @@ -1 +1 @@ -Subproject commit 7a668f52cc19addd4f24e41ef11714a8e2b0e405 +Subproject commit 231bc187faad172b55af4ddc50c30228a56b2ebd diff --git a/community-build/community-projects/fansi b/community-build/community-projects/fansi index c30b5cd3cb6c..21d1db61a315 160000 --- a/community-build/community-projects/fansi +++ b/community-build/community-projects/fansi @@ -1 +1 @@ -Subproject commit c30b5cd3cb6ca94cc9f489b75b4920e8d0b71914 +Subproject commit 21d1db61a315b31636dfd6515f346454b21ac5f6 diff --git a/community-build/community-projects/geny b/community-build/community-projects/geny index f1804705fecf..03ff552cd384 160000 --- a/community-build/community-projects/geny +++ b/community-build/community-projects/geny @@ -1 +1 @@ -Subproject commit f1804705fecfd41bf4f9a2cde24b7549fd3315a5 +Subproject commit 03ff552cd3846939e1686481b3623ea6d06d1d24 diff --git a/community-build/community-projects/os-lib b/community-build/community-projects/os-lib index 36af8391f783..1a848dc584dd 160000 --- a/community-build/community-projects/os-lib +++ b/community-build/community-projects/os-lib @@ -1 +1 @@ -Subproject commit 36af8391f7836a69f6c4d0de7b41608e5b82a898 +Subproject commit 1a848dc584ddfdcf48b7075a4292e09d0b8c00e0 diff --git a/community-build/community-projects/requests-scala b/community-build/community-projects/requests-scala index 70e8c48a3d74..139dbe6418f1 160000 --- a/community-build/community-projects/requests-scala +++ b/community-build/community-projects/requests-scala @@ -1 +1 @@ -Subproject commit 70e8c48a3d74320758c0f2f876ff1e69b8061b81 +Subproject commit 139dbe6418f1ecee09b020086fc2fc9e844e57e3 diff --git a/community-build/community-projects/scas b/community-build/community-projects/scas index 1cdf2980e26a..91b1de233de7 160000 --- a/community-build/community-projects/scas +++ b/community-build/community-projects/scas @@ -1 +1 @@ -Subproject commit 1cdf2980e26a38e481ab4fd15fdc104febcfcccf +Subproject commit 91b1de233de7128e57aca1303e099b1a5499807f diff --git a/community-build/community-projects/sourcecode b/community-build/community-projects/sourcecode index 0143c7719a90..4ae2049a4d62 160000 --- a/community-build/community-projects/sourcecode +++ b/community-build/community-projects/sourcecode @@ -1 +1 @@ -Subproject commit 0143c7719a9058e3e26f4826071ea63eef109cb6 +Subproject commit 4ae2049a4d628cf85b9bf556333c9f6edb9deee5 diff --git a/community-build/community-projects/upickle b/community-build/community-projects/upickle index b22789b8b14d..b5fe468f8665 160000 --- a/community-build/community-projects/upickle +++ b/community-build/community-projects/upickle @@ -1 +1 @@ -Subproject commit b22789b8b14d21f54b2e79807dd415373bf08480 +Subproject commit b5fe468f8665b12d09a733e7a1b419cf26ad2f88 diff --git a/community-build/community-projects/utest b/community-build/community-projects/utest index d5d1482f25e9..654376f41f83 160000 --- a/community-build/community-projects/utest +++ b/community-build/community-projects/utest @@ -1 +1 @@ -Subproject commit d5d1482f25e96d315e1ba0d9404f9e0ca6bc95c1 +Subproject commit 654376f41f8380a44fdb70f693016f25633ae1be diff --git a/sbt-bridge/src/xsbt/CompilerClassLoader.java b/sbt-bridge/src/xsbt/CompilerClassLoader.java index 1ce573148e47..bd1abce4adb5 100644 --- a/sbt-bridge/src/xsbt/CompilerClassLoader.java +++ b/sbt-bridge/src/xsbt/CompilerClassLoader.java @@ -119,4 +119,4 @@ private static ClassLoader computeFixedLoader(ClassLoader bridgeLoader) { throw new RuntimeException(e); } } -} +} \ No newline at end of file diff --git a/sbt-bridge/src/xsbt/CompilerInterface.java b/sbt-bridge/src/xsbt/CompilerInterface.java index 1af338fe93de..9f09ebbdeb06 100644 --- a/sbt-bridge/src/xsbt/CompilerInterface.java +++ b/sbt-bridge/src/xsbt/CompilerInterface.java @@ -6,36 +6,50 @@ import xsbti.AnalysisCallback; import xsbti.Logger; import xsbti.Reporter; -import xsbti.Severity; import xsbti.compile.*; -import java.io.File; - -import dotty.tools.dotc.core.Contexts.ContextBase; import dotty.tools.dotc.Main; -import dotty.tools.dotc.interfaces.*; import java.lang.reflect.InvocationTargetException; -import java.net.URLClassLoader; +import java.io.File; /** * The new compiler interface is [[dotty.tools.xsbt.CompilerBridge]] that extends the new `xsbti.CompilerInterface2`. * This interface is kept for compatibility with Mill and the sbt 1.3.x series. */ public final class CompilerInterface { - public CachedCompiler newCompiler(String[] options, Output output, Logger initialLog, Reporter initialDelegate) { - // The classloader that sbt uses to load the compiler bridge is broken - // (see CompilerClassLoader#fixBridgeLoader for details). To workaround - // this we construct our own ClassLoader and then run the following code - // with it: - // new CachedCompilerImpl(options, output) + public CachedCompiler newCompiler(String[] options, Output output, Logger initialLog, Reporter initialDelegate) throws java.lang.Exception { + if(isClassLoaderValid()) { + return new CachedCompilerImpl(options, output); + } else { + initialLog.warn(() -> + "The compiler class loader is badly configured.\n" + + "Consider using a more recent version of your build tool:\n" + + " - sbt >= 1.4.0 and sbt-dotty >= 1.5.0\n" + + " - Mill >= 0.9.3-21-002361\n" + + " - Bloop >= 1.4.6-23-20a501bc" + ); + // To workaround the wrong class loader, we construct our own and run + // the following code with it: + // new CachedCompilerImpl(options, output) + try { + ClassLoader bridgeLoader = this.getClass().getClassLoader(); + ClassLoader fixedLoader = CompilerClassLoader.fixBridgeLoader(bridgeLoader); + Class cciClass = fixedLoader.loadClass("xsbt.CachedCompilerImpl"); + return (CachedCompiler) cciClass.getConstructors()[0].newInstance(options, output); + } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | InvocationTargetException e) { + throw new RuntimeException(e); + } + } + } + private boolean isClassLoaderValid() { + // Check that the `xsbti.*` classes are loaded from the same class loader in the compiler and the bridge + ClassLoader compilerClassLoader = Main.class.getClassLoader(); + Class clazz = Logger.class; try { - ClassLoader bridgeLoader = this.getClass().getClassLoader(); - ClassLoader fixedLoader = CompilerClassLoader.fixBridgeLoader(bridgeLoader); - Class cciClass = fixedLoader.loadClass("xsbt.CachedCompilerImpl"); - return (CachedCompiler) cciClass.getConstructors()[0].newInstance(options, output); - } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | InvocationTargetException e) { + return compilerClassLoader.loadClass("xsbti.Logger") == clazz; + } catch (ClassNotFoundException e) { throw new RuntimeException(e); } }