aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/java_tools/buildjar/java/com
diff options
context:
space:
mode:
authorGravatar Liam Miller-Cushon <cushon@google.com>2015-08-20 23:58:17 +0000
committerGravatar Dmitry Lomov <dslomov@google.com>2015-08-21 09:44:05 +0000
commit7ccf8f952388f173b1baff13b5d9ed5dc6a9b323 (patch)
treec8bab20174d1791e9f3ea0fa2a5032961765f021 /src/java_tools/buildjar/java/com
parentdd9508c7bc59622b1b12d30e480bad96447ac2d7 (diff)
Fall back to transitive classpath for no.such.pkg errors.
With -XDshouldStopPolicyIfError=INIT (the default) and -XDcompilePolicy=byfile (not the default), javac will stop compiling after emitting no.such.pkg and before any missing symbol errors are reported. The reduced classpath builder needs to fall back to the transitive classpath in this case. This currently works because with -XDcompilePolicy=todo (the default), javac attributes compilation units even if they have with syntax errors to avoid "surprising existing users". [1] [1] http://hg.openjdk.java.net/jdk9/dev/langtools/file/7fd155b7041c/test/tools/javac/policy/test3/Test.java -- MOS_MIGRATED_REVID=101175706
Diffstat (limited to 'src/java_tools/buildjar/java/com')
-rw-r--r--src/java_tools/buildjar/java/com/google/devtools/build/buildjar/ReducedClasspathJavaLibraryBuilder.java9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/ReducedClasspathJavaLibraryBuilder.java b/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/ReducedClasspathJavaLibraryBuilder.java
index ebc1f0f006..1ff9886add 100644
--- a/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/ReducedClasspathJavaLibraryBuilder.java
+++ b/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/ReducedClasspathJavaLibraryBuilder.java
@@ -21,6 +21,7 @@ import com.sun.tools.javac.main.Main.Result;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
+import java.util.regex.Pattern;
/**
* A variant of SimpleJavaLibraryBuilder that attempts to reduce the compile-time classpath right
@@ -76,10 +77,14 @@ public class ReducedClasspathJavaLibraryBuilder extends SimpleJavaLibraryBuilder
}
return result;
}
-
+
+ private static final Pattern MISSING_PACKAGE =
+ Pattern.compile("error: package ([\\p{javaJavaIdentifierPart}\\.]+) does not exist");
+
private boolean hasRecognizedError(String javacOutput) {
return javacOutput.contains("error: cannot access")
|| javacOutput.contains("error: cannot find symbol")
- || javacOutput.contains("com.sun.tools.javac.code.Symbol$CompletionFailure");
+ || javacOutput.contains("com.sun.tools.javac.code.Symbol$CompletionFailure")
+ || MISSING_PACKAGE.matcher(javacOutput).find();
}
}