diff options
author | Liam Miller-Cushon <cushon@google.com> | 2016-12-08 05:26:45 +0000 |
---|---|---|
committer | Irina Iancu <elenairina@google.com> | 2016-12-08 12:50:12 +0000 |
commit | acd0d0c8341f9044e5a79c9d1b4f3ebbb843b874 (patch) | |
tree | 2a64b779d38134739d8485bf101fb4d0925003f3 | |
parent | e26d26e81db26ab9e3e9d3b5d4602e23d9f50a60 (diff) |
Update to javac9-r3297
--
PiperOrigin-RevId: 141396618
MOS_MIGRATED_REVID=141396618
9 files changed, 38 insertions, 62 deletions
diff --git a/scripts/bootstrap/compile.sh b/scripts/bootstrap/compile.sh index 1cc59750a9..6ffd644f74 100755 --- a/scripts/bootstrap/compile.sh +++ b/scripts/bootstrap/compile.sh @@ -17,7 +17,7 @@ # Script for building bazel from scratch without bazel PROTO_FILES=$(ls src/main/protobuf/*.proto src/main/java/com/google/devtools/build/lib/buildeventstream/proto/*.proto) -LIBRARY_JARS=$(find third_party -name '*.jar' | grep -Fv /javac.jar | grep -Fv /javac7.jar | grep -Fv JavaBuilder | grep -ve third_party/grpc/grpc.*jar | tr "\n" " ") +LIBRARY_JARS=$(find third_party -name '*.jar' | grep -Fv /javac-9-dev-r3297-1.jar | grep -Fv /javac7.jar | grep -Fv JavaBuilder | grep -ve third_party/grpc/grpc.*jar | tr "\n" " ") GRPC_JAVA_VERSION=0.15.0 GRPC_LIBRARY_JARS=$(find third_party/grpc -name '*.jar' | grep -e .*${GRPC_JAVA_VERSION}.*jar | tr "\n" " ") LIBRARY_JARS="${LIBRARY_JARS} ${GRPC_LIBRARY_JARS}" diff --git a/src/create_embedded_tools.sh b/src/create_embedded_tools.sh index 67c11f5c09..aab88a369e 100755 --- a/src/create_embedded_tools.sh +++ b/src/create_embedded_tools.sh @@ -43,7 +43,7 @@ for i in $*; do *tools/jdk/BUILD*) OUTPUT_PATH=tools/jdk/BUILD ;; *JavaBuilder*_deploy.jar) OUTPUT_PATH=tools/jdk/JavaBuilder_deploy.jar ;; *turbine_deploy.jar) OUTPUT_PATH=tools/jdk/turbine_deploy.jar ;; - *javac.jar) OUTPUT_PATH=third_party/java/jdk/langtools/javac.jar ;; + *javac-9-dev-r3297-1.jar) OUTPUT_PATH=third_party/java/jdk/langtools/javac-9-dev-r3297-1.jar ;; *javac7.jar) OUTPUT_PATH=third_party/java/jdk/langtools/javac7.jar ;; *SingleJar_deploy.jar) OUTPUT_PATH=tools/jdk/SingleJar_deploy.jar ;; *GenClass_deploy.jar) OUTPUT_PATH=tools/jdk/GenClass_deploy.jar ;; @@ -67,9 +67,9 @@ for i in $*; do chmod u+w "${PACKAGE_DIR}/${OUTPUT_PATH}" done -if [ ! -f ${PACKAGE_DIR}/third_party/java/jdk/langtools/javac.jar ]; then +if [ ! -f ${PACKAGE_DIR}/third_party/java/jdk/langtools/javac-9-dev-r3297-1.jar ]; then cp ${PACKAGE_DIR}/third_party/java/jdk/langtools/javac7.jar \ - ${PACKAGE_DIR}/third_party/java/jdk/langtools/javac.jar + ${PACKAGE_DIR}/third_party/java/jdk/langtools/javac-9-dev-r3297-1.jar fi cat > "${PACKAGE_DIR}/WORKSPACE" <<EOF diff --git a/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/javac/plugins/dependency/ImplicitDependencyExtractor.java b/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/javac/plugins/dependency/ImplicitDependencyExtractor.java index 850d94ba52..27c4639bf0 100644 --- a/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/javac/plugins/dependency/ImplicitDependencyExtractor.java +++ b/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/javac/plugins/dependency/ImplicitDependencyExtractor.java @@ -16,25 +16,17 @@ package com.google.devtools.build.buildjar.javac.plugins.dependency; import com.google.common.collect.ImmutableSet; import com.google.devtools.build.lib.view.proto.Deps; - -import com.sun.nio.zipfs.ZipFileSystem; -import com.sun.nio.zipfs.ZipPath; import com.sun.tools.javac.code.Symbol.ClassSymbol; import com.sun.tools.javac.code.Symtab; -import com.sun.tools.javac.file.ZipArchive; -import com.sun.tools.javac.file.ZipFileIndexArchive; -import com.sun.tools.javac.nio.JavacPathFileManager; +import com.sun.tools.javac.file.JavacFileManager; import com.sun.tools.javac.util.Context; - -import java.io.File; +import java.lang.reflect.Field; import java.nio.file.Path; import java.util.Map; import java.util.Set; - import javax.lang.model.util.SimpleTypeVisitor7; import javax.tools.JavaFileManager; import javax.tools.JavaFileObject; -import javax.tools.StandardJavaFileManager; import javax.tools.StandardLocation; /** @@ -106,26 +98,17 @@ public class ImplicitDependencyExtractor { /** Collect the set of jars on the compilation bootclasspath. */ public static Set<String> getPlatformJars(JavaFileManager fileManager) { - if (fileManager instanceof StandardJavaFileManager) { - StandardJavaFileManager sjfm = (StandardJavaFileManager) fileManager; - ImmutableSet.Builder<String> result = ImmutableSet.builder(); - for (File jar : sjfm.getLocation(StandardLocation.PLATFORM_CLASS_PATH)) { - result.add(jar.toString()); - } - return result.build(); - } - - if (fileManager instanceof JavacPathFileManager) { - JavacPathFileManager jpfm = (JavacPathFileManager) fileManager; + if (fileManager instanceof JavacFileManager) { + JavacFileManager jfm = (JavacFileManager) fileManager; ImmutableSet.Builder<String> result = ImmutableSet.builder(); - for (Path jar : jpfm.getLocation(StandardLocation.PLATFORM_CLASS_PATH)) { - result.add(jar.toString()); + for (Path path : jfm.getLocationAsPaths(StandardLocation.PLATFORM_CLASS_PATH)) { + result.add(path.toString()); } return result.build(); } - // TODO(cushon): Assuming JavacPathFileManager or StandardJavaFileManager is slightly brittle, - // but in practice those are the only implementations that matter. + // TODO(cushon): Assuming JavacFileManager is brittle, but in practice it is the only + // implementation that matters. throw new IllegalStateException( "Unsupported file manager type: " + fileManager.getClass().getName()); } @@ -140,7 +123,7 @@ public class ImplicitDependencyExtractor { */ private void collectJarOf(JavaFileObject reference, Set<String> platformJars, boolean completed) { - String name = getJarName(fileManager, reference); + String name = getJarName(reference); if (name == null) { return; } @@ -166,29 +149,19 @@ public class ImplicitDependencyExtractor { } } - public static String getJarName(JavaFileManager fileManager, JavaFileObject file) { - if (file == null || fileManager == null) { + public static String getJarName(JavaFileObject file) { + if (file == null) { return null; } - - if (file instanceof ZipArchive.ZipFileObject - || file instanceof ZipFileIndexArchive.ZipFileIndexFileObject) { - // getName() will return something like com/foo/libfoo.jar(Bar.class) - return file.getName().split("\\(")[0]; - } - - if (fileManager instanceof JavacPathFileManager) { - JavacPathFileManager fm = (JavacPathFileManager) fileManager; - Path path = fm.getPath(file); - if (!(path instanceof ZipPath)) { - return null; - } - ZipFileSystem zipfs = ((ZipPath) path).getFileSystem(); - // calls toString() on the path to the zip archive - return zipfs.toString(); + try { + Field field = file.getClass().getDeclaredField("userJarPath"); + field.setAccessible(true); + return field.get(file).toString(); + } catch (NoSuchFieldException e) { + return null; + } catch (ReflectiveOperationException e) { + throw new LinkageError(e.getMessage(), e); } - - return null; } private static class TypeVisitor extends SimpleTypeVisitor7<Void, Void> { diff --git a/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/javac/plugins/dependency/StrictJavaDepsPlugin.java b/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/javac/plugins/dependency/StrictJavaDepsPlugin.java index 504a37dcea..715e2865aa 100644 --- a/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/javac/plugins/dependency/StrictJavaDepsPlugin.java +++ b/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/javac/plugins/dependency/StrictJavaDepsPlugin.java @@ -431,7 +431,7 @@ public final class StrictJavaDepsPlugin extends BlazeJavaCompilerPlugin { JavaFileObject classfile = classSymbol.classfile; - String name = ImplicitDependencyExtractor.getJarName(fileManager, classfile); + String name = ImplicitDependencyExtractor.getJarName(classfile); if (name == null) { return null; } diff --git a/src/java_tools/buildjar/javatests/com/google/devtools/build/java/turbine/javac/TreePrunerTest.java b/src/java_tools/buildjar/javatests/com/google/devtools/build/java/turbine/javac/TreePrunerTest.java index ac383a43ba..7acb9c959f 100644 --- a/src/java_tools/buildjar/javatests/com/google/devtools/build/java/turbine/javac/TreePrunerTest.java +++ b/src/java_tools/buildjar/javatests/com/google/devtools/build/java/turbine/javac/TreePrunerTest.java @@ -26,6 +26,8 @@ import com.sun.tools.javac.tree.JCTree.JCClassDecl; import com.sun.tools.javac.tree.JCTree.JCCompilationUnit; import com.sun.tools.javac.tree.JCTree.JCVariableDecl; import com.sun.tools.javac.util.Context; +import java.io.IOError; +import java.io.IOException; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -53,6 +55,8 @@ public class TreePrunerTest { parserFactory.newParser( input, /*keepDocComments=*/ false, /*keepEndPos=*/ false, /*keepLineMap=*/ false); return parser.parseCompilationUnit(); + } catch (IOException e) { + throw new IOError(e); } } diff --git a/src/test/shell/testenv.sh b/src/test/shell/testenv.sh index e8c5a087be..de3ad0039c 100755 --- a/src/test/shell/testenv.sh +++ b/src/test/shell/testenv.sh @@ -84,7 +84,7 @@ langtools_dir="$(dirname $(rlocation io_bazel/third_party/java/jdk/langtools/BUI # Java tooling javabuilder_path="$(find ${BAZEL_RUNFILES} -name JavaBuilder_*.jar)" -langtools_path="${BAZEL_RUNFILES}/third_party/java/jdk/langtools/javac.jar" +langtools_path="${BAZEL_RUNFILES}/third_party/java/jdk/langtools/javac-9-dev-r3297-1.jar" singlejar_path="${BAZEL_RUNFILES}/src/java_tools/singlejar/SingleJar_deploy.jar" genclass_path="${BAZEL_RUNFILES}/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/genclass/GenClass_deploy.jar" junitrunner_path="${BAZEL_RUNFILES}/src/java_tools/junitrunner/java/com/google/testing/junit/runner/Runner_deploy.jar" @@ -384,8 +384,8 @@ function create_new_workspace() { copy_tools_directory - [ -e third_party/java/jdk/langtools/javac.jar ] \ - || ln -s "${langtools_path}" third_party/java/jdk/langtools/javac.jar + [ -e third_party/java/jdk/langtools/javac-9-dev-r3297-1.jar ] \ + || ln -s "${langtools_path}" third_party/java/jdk/langtools/javac-9-dev-r3297-1.jar touch WORKSPACE } diff --git a/third_party/README.md b/third_party/README.md index 897a14800d..75b15f7ff9 100644 --- a/third_party/README.md +++ b/third_party/README.md @@ -172,8 +172,7 @@ a minimal set of extra dependencies. ## [javac](https://github.com/google/error-prone-javac) -* Version: 1.9.0-dev-r2973-2 (javac7.jar) and 1.9.0-dev-r2644-2 (javac.jar) and - javac-9-dev-r3297-1 (javac-9-dev-r3297-1.jar) +* Version: 1.9.0-dev-r2973-2 (javac7.jar) and 1.9.0-dev-r2644-2 (javac-9-dev-r3297-1.jar) * License: GNU GPL v2 with Classpath exception (plus other licenses, see third_party/java/jdk/langtools/LICENSE file). ## [jarjar](https://code.google.com/p/jarjar/) diff --git a/third_party/java/jdk/README.md b/third_party/java/jdk/README.md index 5b413d216d..96881e66b8 100644 --- a/third_party/java/jdk/README.md +++ b/third_party/java/jdk/README.md @@ -9,8 +9,8 @@ from [OpenJDK](https://openjdk.java.net) but compiled for a lower version of the JRE. Those builds are vendored in //third_party/java/jdk/langtools. -Current Bazel supports running on a JRE 8 only because the default Java -compiler used (//third_party/java/jdk/langtools/javac.jar) is the +Currently Bazel supports running on a JRE 8 only because the default Java +compiler used (//third_party/java/jdk/langtools/javac-9-dev-r3297-1.jar) is the Java compiler of OpenJDK 9 compiled to run on a JRE 8. This cannot be built to run on a JRE 7 because of code incompatibility. Bazel's JavaBuilder at HEAD cannot be linked with earlier version of the diff --git a/third_party/java/jdk/langtools/BUILD b/third_party/java/jdk/langtools/BUILD index 9a44df1018..b529d2a45d 100644 --- a/third_party/java/jdk/langtools/BUILD +++ b/third_party/java/jdk/langtools/BUILD @@ -19,22 +19,22 @@ filegroup( "//conditions:default": [ "BUILD", "LICENSE", - "javac.jar", - "javac.srcjar", + "javac-9-dev-r3297-1.jar", + "javac-9-dev-r3297-1.srcjar", ], }), ) java_import( name = "javac", - jars = ["javac.jar"], + jars = ["javac-9-dev-r3297-1.jar"], ) filegroup( name = "javac_jar", srcs = select({ "//tools/jdk:jdk7": ["javac7.jar"], - "//conditions:default": ["javac.jar"], + "//conditions:default": ["javac-9-dev-r3297-1.jar"], }), ) |