From f73fc6a1dd56f5e65304cd679f72c8e75f58929e Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Tue, 22 Nov 2016 12:08:13 +0100 Subject: [PATCH] [java] fixes compiler module path composition (IDEA-158385) --- .../jps/incremental/java/JavaBuilder.java | 33 ++++++++++--------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/jps/jps-builders/src/org/jetbrains/jps/incremental/java/JavaBuilder.java b/jps/jps-builders/src/org/jetbrains/jps/incremental/java/JavaBuilder.java index 9551a6a5125c..07ce0360caf4 100644 --- a/jps/jps-builders/src/org/jetbrains/jps/incremental/java/JavaBuilder.java +++ b/jps/jps-builders/src/org/jetbrains/jps/incremental/java/JavaBuilder.java @@ -71,6 +71,9 @@ import java.util.concurrent.Executor; import java.util.concurrent.Future; import java.util.concurrent.atomic.AtomicReference; +import static com.intellij.util.containers.ContainerUtil.concat; +import static com.intellij.util.containers.ContainerUtil.newArrayList; + /** * @author Eugene Zhuravlev * @since 21.09.2011 @@ -394,15 +397,21 @@ public class JavaBuilder extends ModuleLevelBuilder { return true; } - if (!_platformCp.isEmpty()) { - if (hasModules) { - String text = "The project has boot classpath dependencies (" + _platformCp + "). Please convert them into regular ones."; - context.processMessage(new CompilerMessage(BUILDER_NAME, BuildMessage.Kind.ERROR, text)); - return true; - } + Collection modulePath = Collections.emptyList(); + if (hasModules) { + // in Java 9, named modules are not allowed to read classes from the classpath + // moreover, the compiler requires all transitive dependencies to be on the module path + modulePath = ProjectPaths.getCompilationModulePath(chunk, false); + classpath = Collections.emptyList(); + } - final int chunkSdkVersion = getChunkSdkVersion(chunk); - if (chunkSdkVersion >= 9) { + if (!_platformCp.isEmpty()) { + final int chunkSdkVersion; + if (hasModules) { + modulePath = newArrayList(concat(_platformCp, modulePath)); + _platformCp = Collections.emptyList(); + } + else if ((chunkSdkVersion = getChunkSdkVersion(chunk)) >= 9) { // if chunk's SDK is 9 or higher, there is no way to specify full platform classpath // because platform classes are stored in jimage binary files with unknown format. // Because of this we are clearing platform classpath so that javac will resolve against its own boot classpath @@ -428,14 +437,6 @@ public class JavaBuilder extends ModuleLevelBuilder { } } - Collection modulePath = Collections.emptyList(); - if (hasModules) { - // in Java 9, named modules are not allowed to read classes from the classpath - // moreover, the compiler requires all transitive dependencies to be on the module path - modulePath = ProjectPaths.getCompilationModulePath(chunk, false); - classpath = Collections.emptyList(); - } - final ClassProcessingConsumer classesConsumer = new ClassProcessingConsumer(context, outputSink); final boolean rc; if (!shouldForkJavac) {