diff --git a/jdk/.hgtags b/jdk/.hgtags index 4cede3d5e81..7c40923b81b 100644 --- a/jdk/.hgtags +++ b/jdk/.hgtags @@ -414,3 +414,4 @@ e78da9db6299b3fcba49300d52e2359e82fdd218 jdk-9+168 177436a54ca13730ffc725a6e5dbfcd9486f3da3 jdk-9+169 ef9954f6896bb0b95ac62bf769f68b59a7a56ccd jdk-9+170 29bbedd4cce8e14742bdb22118c057b877c02f0f jdk-9+171 +0ff9ad7d067cd4fa14450cf208bf019175a0aaba jdk-9+172 diff --git a/jdk/make/src/classes/build/tools/jigsaw/ListPackages.java b/jdk/make/src/classes/build/tools/jigsaw/ListPackages.java new file mode 100644 index 00000000000..89cbc2892aa --- /dev/null +++ b/jdk/make/src/classes/build/tools/jigsaw/ListPackages.java @@ -0,0 +1,203 @@ +/* + * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package build.tools.jigsaw; + +import java.io.IOException; +import java.io.OutputStream; +import java.io.PrintStream; +import java.io.UncheckedIOException; +import java.lang.module.ModuleDescriptor; +import java.lang.module.ModuleFinder; +import java.lang.module.ModuleReference; +import java.net.URI; +import java.nio.file.FileSystem; +import java.nio.file.FileSystems; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.attribute.BasicFileAttributes; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.jar.JarEntry; +import java.util.jar.JarFile; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +/** + * Run this tool to generate the JDK internal APIs in the previous releases + * including platform-specific internal APIs. + */ +public class ListPackages { + // Filter non-interesting JAR files + private final static List excludes = Arrays.asList( + "deploy.jar", + "javaws.jar", + "plugin.jar", + "cldrdata.jar", + "localedata.jar" + ); + private static void usage() { + System.out.println("ListPackages [-o ] [-jdkinternals] []*"); + } + + private static final Set EXPORTED_PACKAGES = new HashSet<>(); + + public static void main(String... args) throws IOException { + List paths = new ArrayList<>(); + Path outFile = null; + boolean jdkinternals = false; + int i=0; + while (i < args.length) { + String arg = args[i++]; + if (arg.equals("-o")) { + outFile = Paths.get(args[i++]); + } else if (arg.equals("-jdkinternals")) { + jdkinternals = true; + } else { + Path p = Paths.get(arg); + if (Files.notExists(p)) + throw new IllegalArgumentException(p + " not exist"); + paths.add(p); + } + } + if (paths.isEmpty()) { + usage(); + System.exit(1); + } + + // Get the exported APIs from the current JDK releases + Path javaHome = Paths.get(System.getProperty("java.home")); + ModuleFinder.ofSystem().findAll() + .stream() + .map(ModuleReference::descriptor) + .filter(md -> !md.name().equals("jdk.unsupported")) + .flatMap(md -> md.exports().stream()) + .filter(exp -> !exp.isQualified()) + .map(ModuleDescriptor.Exports::source) + .forEach(EXPORTED_PACKAGES::add); + + ListPackages listPackages = new ListPackages(paths); + Stream pkgs = listPackages.packages().stream(); + if (jdkinternals) { + pkgs = pkgs.filter(pn -> !EXPORTED_PACKAGES.contains(pn)); + } + if (outFile != null) { + try (OutputStream out = Files.newOutputStream(outFile); + PrintStream pw = new PrintStream(out)) { + write(pw, pkgs); + } + } else { + write(System.out, pkgs); + } + } + + + private static void write(PrintStream pw, Stream packages) { + pw.println("# This file is auto-generated by ListPackages tool on " + + LocalDateTime.now().toString()); + packages.sorted().forEach(pw::println); + } + + private final Set packages = new HashSet<>(); + ListPackages(List dirs) throws IOException { + for (Path p : dirs) { + packages.addAll(list(p)); + } + } + + Set packages() { + return packages; + } + + private Set list(Path javaHome) throws IOException { + Path jrt = javaHome.resolve("lib").resolve("modules"); + Path jre = javaHome.resolve("jre"); + + if (Files.exists(jrt)) { + return listModularRuntime(javaHome); + } else if (Files.exists(jre.resolve("lib").resolve("rt.jar"))) { + return listLegacyRuntime(javaHome); + } + throw new IllegalArgumentException("invalid " + javaHome); + } + + private Set listModularRuntime(Path javaHome) throws IOException { + Map env = new HashMap<>(); + env.put("java.home", javaHome.toString()); + FileSystem fs = FileSystems.newFileSystem(URI.create("jrt:/"), env); + Path root = fs.getPath("packages"); + return Files.walk(root, 1) + .map(Path::getFileName) + .map(Path::toString) + .collect(Collectors.toSet()); + } + + private Set listLegacyRuntime(Path javaHome) throws IOException { + List dirs = new ArrayList<>(); + Path jre = javaHome.resolve("jre"); + Path lib = javaHome.resolve("lib"); + + dirs.add(jre.resolve("lib")); + dirs.add(jre.resolve("lib").resolve("ext")); + dirs.add(lib.resolve("tools.jar")); + dirs.add(lib.resolve("jconsole.jar")); + Set packages = new HashSet<>(); + for (Path d : dirs) { + Files.find(d, 1, (Path p, BasicFileAttributes attr) + -> p.getFileName().toString().endsWith(".jar") && + !excludes.contains(p.getFileName().toString())) + .map(ListPackages::walkJarFile) + .forEach(packages::addAll); + } + return packages; + } + + static Set walkJarFile(Path jarfile) { + try (JarFile jf = new JarFile(jarfile.toFile())) { + return jf.stream() + .map(JarEntry::getName) + .filter(n -> n.endsWith(".class")) + .map(ListPackages::toPackage) + .collect(Collectors.toSet()); + } catch (IOException e) { + throw new UncheckedIOException(e); + } + } + + static String toPackage(String name) { + int i = name.lastIndexOf('/'); + if (i < 0) { + System.err.format("Warning: unnamed package %s%n", name); + } + return i >= 0 ? name.substring(0, i).replace("/", ".") : ""; + } +} diff --git a/jdk/src/java.base/share/classes/java/lang/RuntimePermission.java b/jdk/src/java.base/share/classes/java/lang/RuntimePermission.java index b1a4280498a..762740a5917 100644 --- a/jdk/src/java.base/share/classes/java/lang/RuntimePermission.java +++ b/jdk/src/java.base/share/classes/java/lang/RuntimePermission.java @@ -403,6 +403,7 @@ import java.lang.module.ModuleFinder; * * @author Marianne Mueller * @author Roland Schemers + * @since 1.2 */ public final class RuntimePermission extends BasicPermission { diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/package-info.java b/jdk/src/java.base/share/classes/java/lang/invoke/package-info.java index ba1d84a8911..7e4ce134ec0 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/package-info.java +++ b/jdk/src/java.base/share/classes/java/lang/invoke/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -44,13 +44,13 @@ * * * - *

Summary of relevant Java Virtual Machine changes

+ *

Summary of relevant Java Virtual Machine changes

* The following low-level information summarizes relevant parts of the * Java Virtual Machine specification. For full details, please see the * current version of that specification. * * Each occurrence of an {@code invokedynamic} instruction is called a dynamic call site. - *

{@code invokedynamic} instructions

+ *

{@code invokedynamic} instructions

* A dynamic call site is originally in an unlinked state. In this state, there is * no target method for the call site to invoke. *

@@ -77,7 +77,8 @@ *

* The bootstrap method is invoked on at least three values: *