8182416: Clean up module-info.java like move requires transitive adjacent to exports
Reviewed-by: alanb
--- a/langtools/src/java.compiler/share/classes/module-info.java Sat Jun 17 08:02:55 2017 +0100
+++ b/langtools/src/java.compiler/share/classes/module-info.java Sat Jun 17 11:50:45 2017 -0700
@@ -23,16 +23,18 @@
* questions.
*/
- /**
- * Defines the Language Model, Annotation Processing, and Java Compiler APIs.
- * <P>
- * These APIs model declarations and types of the Java programming language,
- * and define interfaces for tools such as compilers which can be invoked
- * from a program.
- *
- * @moduleGraph
- * @since 9
- */
+/**
+ * Defines the Language Model, Annotation Processing, and Java Compiler APIs.
+ * <p>
+ * These APIs model declarations and types of the Java programming language,
+ * and define interfaces for tools such as compilers which can be invoked
+ * from a program.
+ * <p>
+ * This module is upgradeble.
+ *
+ * @moduleGraph
+ * @since 9
+ */
module java.compiler {
exports javax.annotation.processing;
exports javax.lang.model;
--- a/langtools/src/jdk.compiler/share/classes/module-info.java Sat Jun 17 08:02:55 2017 +0100
+++ b/langtools/src/jdk.compiler/share/classes/module-info.java Sat Jun 17 11:50:45 2017 -0700
@@ -88,6 +88,7 @@
exports com.sun.source.tree;
exports com.sun.source.util;
exports com.sun.tools.javac;
+
exports com.sun.tools.doclint to
jdk.javadoc;
exports com.sun.tools.javac.api to
@@ -127,16 +128,16 @@
uses com.sun.source.util.Plugin;
uses com.sun.tools.javac.platform.PlatformProvider;
- provides java.util.spi.ToolProvider
- with com.sun.tools.javac.main.JavacToolProvider;
+ provides java.util.spi.ToolProvider with
+ com.sun.tools.javac.main.JavacToolProvider;
- provides com.sun.tools.javac.platform.PlatformProvider
- with com.sun.tools.javac.platform.JDKPlatformProvider;
+ provides com.sun.tools.javac.platform.PlatformProvider with
+ com.sun.tools.javac.platform.JDKPlatformProvider;
- provides javax.tools.JavaCompiler
- with com.sun.tools.javac.api.JavacTool;
+ provides javax.tools.JavaCompiler with
+ com.sun.tools.javac.api.JavacTool;
- provides javax.tools.Tool
- with com.sun.tools.javac.api.JavacTool;
+ provides javax.tools.Tool with
+ com.sun.tools.javac.api.JavacTool;
}
--- a/langtools/src/jdk.javadoc/share/classes/module-info.java Sat Jun 17 08:02:55 2017 +0100
+++ b/langtools/src/jdk.javadoc/share/classes/module-info.java Sat Jun 17 11:50:45 2017 -0700
@@ -58,9 +58,10 @@
* @since 9
*/
module jdk.javadoc {
+ requires java.xml;
+
requires transitive java.compiler;
requires transitive jdk.compiler;
- requires java.xml;
exports com.sun.javadoc;
exports com.sun.tools.doclets;
@@ -69,13 +70,13 @@
exports jdk.javadoc.doclet;
- provides java.util.spi.ToolProvider
- with jdk.javadoc.internal.tool.JavadocToolProvider;
+ provides java.util.spi.ToolProvider with
+ jdk.javadoc.internal.tool.JavadocToolProvider;
- provides javax.tools.DocumentationTool
- with jdk.javadoc.internal.api.JavadocTool;
+ provides javax.tools.DocumentationTool with
+ jdk.javadoc.internal.api.JavadocTool;
- provides javax.tools.Tool
- with jdk.javadoc.internal.api.JavadocTool;
+ provides javax.tools.Tool with
+ jdk.javadoc.internal.api.JavadocTool;
}
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ModuleInfoBuilder.java Sat Jun 17 08:02:55 2017 +0100
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ModuleInfoBuilder.java Sat Jun 17 11:50:45 2017 -0700
@@ -203,21 +203,43 @@
writer.format("%smodule %s {%n", open ? "open " : "", md.name());
Map<String, Module> modules = configuration.getModules();
- // first print the JDK modules
- md.requires().stream()
- .filter(req -> !req.name().equals("java.base")) // implicit requires
- .sorted(Comparator.comparing(Requires::name))
- .forEach(req -> writer.format(" requires %s;%n",
- toString(req.modifiers(), req.name())));
+
+ // first print requires
+ Set<Requires> reqs = md.requires().stream()
+ .filter(req -> !req.name().equals("java.base") && req.modifiers().isEmpty())
+ .collect(Collectors.toSet());
+ reqs.stream()
+ .sorted(Comparator.comparing(Requires::name))
+ .forEach(req -> writer.format(" requires %s;%n",
+ toString(req.modifiers(), req.name())));
+ if (!reqs.isEmpty()) {
+ writer.println();
+ }
+
+ // requires transitive
+ reqs = md.requires().stream()
+ .filter(req -> !req.name().equals("java.base") && !req.modifiers().isEmpty())
+ .collect(Collectors.toSet());
+ reqs.stream()
+ .sorted(Comparator.comparing(Requires::name))
+ .forEach(req -> writer.format(" requires %s;%n",
+ toString(req.modifiers(), req.name())));
+ if (!reqs.isEmpty()) {
+ writer.println();
+ }
if (!open) {
md.exports().stream()
.peek(exp -> {
if (exp.isQualified())
throw new InternalError(md.name() + " qualified exports: " + exp);
- })
+ })
.sorted(Comparator.comparing(Exports::source))
.forEach(exp -> writer.format(" exports %s;%n", exp.source()));
+
+ if (!md.exports().isEmpty()) {
+ writer.println();
+ }
}
md.provides().stream()
@@ -228,8 +250,11 @@
String.format(" provides %s with%n",
p.service().replace('$', '.')),
";")))
- .forEach(writer::println);
+ .forEach(writer::println);
+ if (!md.provides().isEmpty()) {
+ writer.println();
+ }
writer.println("}");
}
--- a/langtools/src/jdk.jdeps/share/classes/module-info.java Sat Jun 17 08:02:55 2017 +0100
+++ b/langtools/src/jdk.jdeps/share/classes/module-info.java Sat Jun 17 11:50:45 2017 -0700
@@ -59,6 +59,7 @@
module jdk.jdeps {
requires java.compiler;
requires jdk.compiler;
+
exports com.sun.tools.classfile to jdk.jlink;
provides java.util.spi.ToolProvider with
--- a/langtools/src/jdk.jshell/share/classes/module-info.java Sat Jun 17 08:02:55 2017 +0100
+++ b/langtools/src/jdk.jshell/share/classes/module-info.java Sat Jun 17 11:50:45 2017 -0700
@@ -65,27 +65,28 @@
* @since 9
*/
module jdk.jshell {
- requires transitive java.compiler;
- requires transitive jdk.jdi;
- requires transitive java.prefs;
requires java.logging;
requires jdk.compiler;
+ requires jdk.internal.ed;
requires jdk.internal.le;
- requires jdk.internal.ed;
requires jdk.internal.opt;
+ requires transitive java.compiler;
+ requires transitive java.prefs;
+ requires transitive jdk.jdi;
+
exports jdk.jshell;
+ exports jdk.jshell.execution;
exports jdk.jshell.spi;
- exports jdk.jshell.execution;
exports jdk.jshell.tool;
uses jdk.jshell.spi.ExecutionControlProvider;
uses jdk.internal.editor.spi.BuildInEditorProvider;
- provides javax.tools.Tool
- with jdk.internal.jshell.tool.JShellToolProvider;
- provides jdk.jshell.spi.ExecutionControlProvider
- with jdk.jshell.execution.JdiExecutionControlProvider,
- jdk.jshell.execution.LocalExecutionControlProvider,
- jdk.jshell.execution.FailOverExecutionControlProvider;
+ provides javax.tools.Tool with
+ jdk.internal.jshell.tool.JShellToolProvider;
+ provides jdk.jshell.spi.ExecutionControlProvider with
+ jdk.jshell.execution.JdiExecutionControlProvider,
+ jdk.jshell.execution.LocalExecutionControlProvider,
+ jdk.jshell.execution.FailOverExecutionControlProvider;
}