defs, JCExpression expr);
}
@@ -3013,6 +3091,7 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
public void visitErroneous(JCErroneous that) { visitTree(that); }
public void visitModuleDef(JCModuleDecl that) { visitTree(that); }
public void visitExports(JCExports that) { visitTree(that); }
+ public void visitOpens(JCOpens that) { visitTree(that); }
public void visitProvides(JCProvides that) { visitTree(that); }
public void visitRequires(JCRequires that) { visitTree(that); }
public void visitUses(JCUses that) { visitTree(that); }
diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/Pretty.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/Pretty.java
index e4a98d366c2..23fdbbeb164 100644
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/Pretty.java
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/Pretty.java
@@ -28,6 +28,7 @@ package com.sun.tools.javac.tree;
import java.io.*;
import com.sun.source.tree.MemberReferenceTree.ReferenceMode;
+import com.sun.source.tree.ModuleTree.ModuleKind;
import com.sun.tools.javac.code.*;
import com.sun.tools.javac.tree.JCTree.*;
import com.sun.tools.javac.util.*;
@@ -441,6 +442,10 @@ public class Pretty extends JCTree.Visitor {
@Override
public void visitModuleDef(JCModuleDecl tree) {
try {
+ printAnnotations(tree.mods.annotations);
+ if (tree.getModuleType() == ModuleKind.OPEN) {
+ print("open ");
+ }
print("module ");
printExpr(tree.qualId);
if (tree.directives == null) {
@@ -457,7 +462,11 @@ public class Pretty extends JCTree.Visitor {
@Override
public void visitExports(JCExports tree) {
try {
- print("exports ");
+ if (tree.hasTag(EXPORTS)) {
+ print("exports ");
+ } else {
+ print("opens ");
+ }
printExpr(tree.qualid);
if (tree.moduleNames != null) {
print(" to ");
@@ -475,7 +484,7 @@ public class Pretty extends JCTree.Visitor {
print("provides ");
printExpr(tree.serviceName);
print(" with ");
- printExpr(tree.implName);
+ printExprs(tree.implNames);
print(";");
} catch (IOException e) {
throw new UncheckedIOException(e);
@@ -486,8 +495,10 @@ public class Pretty extends JCTree.Visitor {
public void visitRequires(JCRequires tree) {
try {
print("requires ");
- if (tree.isPublic)
- print("public ");
+ if (tree.isStaticPhase)
+ print("static ");
+ if (tree.isTransitive)
+ print("transitive ");
printExpr(tree.moduleName);
print(";");
} catch (IOException e) {
diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeCopier.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeCopier.java
index 6fa5dc85b42..f1aa04fa4cf 100644
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeCopier.java
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeCopier.java
@@ -26,6 +26,7 @@
package com.sun.tools.javac.tree;
import com.sun.source.tree.*;
+import com.sun.source.tree.Tree.Kind;
import com.sun.tools.javac.tree.JCTree.*;
import com.sun.tools.javac.util.DefinedBy;
import com.sun.tools.javac.util.DefinedBy.Api;
@@ -508,9 +509,10 @@ public class TreeCopier implements TreeVisitor {
@Override @DefinedBy(Api.COMPILER_TREE)
public JCTree visitModule(ModuleTree node, P p) {
JCModuleDecl t = (JCModuleDecl) node;
+ JCModifiers mods = copy(t.mods, p);
JCExpression qualId = copy(t.qualId);
List directives = copy(t.directives);
- return M.at(t.pos).ModuleDef(qualId, directives);
+ return M.at(t.pos).ModuleDef(mods, t.getModuleType(), qualId, directives);
}
@Override @DefinedBy(Api.COMPILER_TREE)
@@ -521,19 +523,27 @@ public class TreeCopier implements TreeVisitor {
return M.at(t.pos).Exports(qualId, moduleNames);
}
+ @Override @DefinedBy(Api.COMPILER_TREE)
+ public JCOpens visitOpens(OpensTree node, P p) {
+ JCOpens t = (JCOpens) node;
+ JCExpression qualId = copy(t.qualid, p);
+ List moduleNames = copy(t.moduleNames, p);
+ return M.at(t.pos).Opens(qualId, moduleNames);
+ }
+
@Override @DefinedBy(Api.COMPILER_TREE)
public JCProvides visitProvides(ProvidesTree node, P p) {
JCProvides t = (JCProvides) node;
JCExpression serviceName = copy(t.serviceName, p);
- JCExpression implName = copy(t.implName, p);
- return M.at(t.pos).Provides(serviceName, implName);
+ List implNames = copy(t.implNames, p);
+ return M.at(t.pos).Provides(serviceName, implNames);
}
@Override @DefinedBy(Api.COMPILER_TREE)
public JCRequires visitRequires(RequiresTree node, P p) {
JCRequires t = (JCRequires) node;
JCExpression moduleName = copy(t.moduleName, p);
- return M.at(t.pos).Requires(t.isPublic, moduleName);
+ return M.at(t.pos).Requires(t.isTransitive, t.isStaticPhase, moduleName);
}
@Override @DefinedBy(Api.COMPILER_TREE)
diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeInfo.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeInfo.java
index 5210067035c..b0f430b0862 100644
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeInfo.java
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeInfo.java
@@ -378,6 +378,11 @@ public class TreeInfo {
return Position.NOPOS;
switch(tree.getTag()) {
+ case MODULEDEF: {
+ JCModuleDecl md = (JCModuleDecl)tree;
+ return md.mods.annotations.isEmpty() ? md.pos :
+ md.mods.annotations.head.pos;
+ }
case PACKAGEDEF: {
JCPackageDecl pd = (JCPackageDecl)tree;
return pd.annotations.isEmpty() ? pd.pos :
@@ -769,8 +774,9 @@ public class TreeInfo {
switch (node.getTag()) {
case TOPLEVEL:
JCCompilationUnit cut = (JCCompilationUnit) node;
- if (isModuleInfo(cut) && cut.defs.nonEmpty() && cut.defs.head.hasTag(MODULEDEF))
- return symbolFor(cut.defs.head);
+ JCModuleDecl moduleDecl = cut.getModuleDecl();
+ if (isModuleInfo(cut) && moduleDecl != null)
+ return symbolFor(moduleDecl);
return cut.packge;
case MODULEDEF:
return ((JCModuleDecl) node).sym;
@@ -1076,6 +1082,11 @@ public class TreeInfo {
case TYPE_ANNOTATION:
return Tree.Kind.TYPE_ANNOTATION;
+ case EXPORTS:
+ return Tree.Kind.EXPORTS;
+ case OPENS:
+ return Tree.Kind.OPENS;
+
default:
return null;
}
@@ -1158,7 +1169,7 @@ public class TreeInfo {
public static boolean isModuleInfo(JCCompilationUnit tree) {
return tree.sourcefile.isNameCompatible("module-info", JavaFileObject.Kind.SOURCE)
- && tree.defs.nonEmpty() && tree.defs.head.hasTag(MODULEDEF);
+ && tree.getModuleDecl() != null;
}
public static JCModuleDecl getModule(JCCompilationUnit t) {
diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeMaker.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeMaker.java
index 59d39453a51..83e3d5fc0de 100644
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeMaker.java
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeMaker.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2016, 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
@@ -27,6 +27,8 @@ package com.sun.tools.javac.tree;
import java.util.Iterator;
+import com.sun.source.tree.ModuleTree.ModuleKind;
+import com.sun.source.tree.Tree.Kind;
import com.sun.tools.javac.code.*;
import com.sun.tools.javac.code.Symbol.*;
import com.sun.tools.javac.code.Type.*;
@@ -538,8 +540,9 @@ public class TreeMaker implements JCTree.Factory {
}
@Override
- public JCModuleDecl ModuleDef(JCExpression qualid, List directives) {
- JCModuleDecl tree = new JCModuleDecl(qualid, directives);
+ public JCModuleDecl ModuleDef(JCModifiers mods, ModuleKind kind,
+ JCExpression qualid, List directives) {
+ JCModuleDecl tree = new JCModuleDecl(mods, kind, qualid, directives);
tree.pos = pos;
return tree;
}
@@ -552,15 +555,22 @@ public class TreeMaker implements JCTree.Factory {
}
@Override
- public JCProvides Provides(JCExpression serviceName, JCExpression implName) {
- JCProvides tree = new JCProvides(serviceName, implName);
+ public JCOpens Opens(JCExpression qualId, List moduleNames) {
+ JCOpens tree = new JCOpens(qualId, moduleNames);
tree.pos = pos;
return tree;
}
@Override
- public JCRequires Requires(boolean isPublic, JCExpression qualId) {
- JCRequires tree = new JCRequires(isPublic, qualId);
+ public JCProvides Provides(JCExpression serviceName, List implNames) {
+ JCProvides tree = new JCProvides(serviceName, implNames);
+ tree.pos = pos;
+ return tree;
+ }
+
+ @Override
+ public JCRequires Requires(boolean isTransitive, boolean isStaticPhase, JCExpression qualId) {
+ JCRequires tree = new JCRequires(isTransitive, isStaticPhase, qualId);
tree.pos = pos;
return tree;
}
diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeScanner.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeScanner.java
index 506925c186a..68407febcab 100644
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeScanner.java
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeScanner.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2016, 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
@@ -73,6 +73,7 @@ public class TreeScanner extends Visitor {
@Override
public void visitModuleDef(JCModuleDecl tree) {
+ scan(tree.mods);
scan(tree.qualId);
scan(tree.directives);
}
@@ -83,10 +84,16 @@ public class TreeScanner extends Visitor {
scan(tree.moduleNames);
}
+ @Override
+ public void visitOpens(JCOpens tree) {
+ scan(tree.qualid);
+ scan(tree.moduleNames);
+ }
+
@Override
public void visitProvides(JCProvides tree) {
scan(tree.serviceName);
- scan(tree.implName);
+ scan(tree.implNames);
}
@Override
diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/ModuleHelper.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/ModuleHelper.java
index dd0315e837c..906c0ccf85b 100644
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/ModuleHelper.java
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/ModuleHelper.java
@@ -51,4 +51,5 @@ public class ModuleHelper {
from.addExports(pack, to);
}
}
-}
\ No newline at end of file
+}
+
diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/Names.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/Names.java
index 5d671decd07..3ac63d5953e 100644
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/Names.java
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/Names.java
@@ -64,11 +64,14 @@ public class Names {
public final Name _super;
public final Name _this;
public final Name exports;
+ public final Name opens;
public final Name module;
public final Name provides;
public final Name requires;
public final Name to;
+ public final Name transitive;
public final Name uses;
+ public final Name open;
public final Name with;
// field and method names
@@ -101,6 +104,7 @@ public class Names {
public final Name length;
public final Name next;
public final Name ordinal;
+ public final Name provider;
public final Name serialVersionUID;
public final Name toString;
public final Name value;
@@ -146,6 +150,7 @@ public class Names {
public final Name LocalVariableTypeTable;
public final Name MethodParameters;
public final Name Module;
+ public final Name ModuleVersion;
public final Name RuntimeInvisibleAnnotations;
public final Name RuntimeInvisibleParameterAnnotations;
public final Name RuntimeInvisibleTypeAnnotations;
@@ -160,7 +165,6 @@ public class Names {
public final Name Synthetic;
public final Name Value;
public final Name Varargs;
- public final Name Version;
// members of java.lang.annotation.ElementType
public final Name ANNOTATION_TYPE;
@@ -168,6 +172,7 @@ public class Names {
public final Name FIELD;
public final Name LOCAL_VARIABLE;
public final Name METHOD;
+ public final Name MODULE;
public final Name PACKAGE;
public final Name PARAMETER;
public final Name TYPE;
@@ -220,11 +225,14 @@ public class Names {
_super = fromString("super");
_this = fromString("this");
exports = fromString("exports");
+ opens = fromString("opens");
module = fromString("module");
provides = fromString("provides");
requires = fromString("requires");
to = fromString("to");
+ transitive = fromString("transitive");
uses = fromString("uses");
+ open = fromString("open");
with = fromString("with");
// field and method names
@@ -257,6 +265,7 @@ public class Names {
length = fromString("length");
next = fromString("next");
ordinal = fromString("ordinal");
+ provider = fromString("provider");
serialVersionUID = fromString("serialVersionUID");
toString = fromString("toString");
value = fromString("value");
@@ -303,6 +312,7 @@ public class Names {
LocalVariableTypeTable = fromString("LocalVariableTypeTable");
MethodParameters = fromString("MethodParameters");
Module = fromString("Module");
+ ModuleVersion = fromString("ModuleVersion");
RuntimeInvisibleAnnotations = fromString("RuntimeInvisibleAnnotations");
RuntimeInvisibleParameterAnnotations = fromString("RuntimeInvisibleParameterAnnotations");
RuntimeInvisibleTypeAnnotations = fromString("RuntimeInvisibleTypeAnnotations");
@@ -317,7 +327,6 @@ public class Names {
Synthetic = fromString("Synthetic");
Value = fromString("Value");
Varargs = fromString("Varargs");
- Version = fromString("Version");
// members of java.lang.annotation.ElementType
ANNOTATION_TYPE = fromString("ANNOTATION_TYPE");
@@ -325,6 +334,7 @@ public class Names {
FIELD = fromString("FIELD");
LOCAL_VARIABLE = fromString("LOCAL_VARIABLE");
METHOD = fromString("METHOD");
+ MODULE = fromString("MODULE");
PACKAGE = fromString("PACKAGE");
PARAMETER = fromString("PARAMETER");
TYPE = fromString("TYPE");
diff --git a/langtools/src/jdk.compiler/share/classes/module-info.java b/langtools/src/jdk.compiler/share/classes/module-info.java
index 0b66b4d2b1e..3f7051be71b 100644
--- a/langtools/src/jdk.compiler/share/classes/module-info.java
+++ b/langtools/src/jdk.compiler/share/classes/module-info.java
@@ -28,7 +28,7 @@
* and its command line equivalent, javac, as well as javah.
*/
module jdk.compiler {
- requires public java.compiler;
+ requires transitive java.compiler;
exports com.sun.source.doctree;
exports com.sun.source.tree;
diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/doclet/package-info.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/doclet/package-info.java
index 43bb4ecbebb..279f7e81e2c 100644
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/doclet/package-info.java
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/doclet/package-info.java
@@ -79,7 +79,7 @@
* module declaration, to create a module set to considered for documentation
* as follows:
*
- * - public -- follows and expands all "requires public" edges in the module graph
+ *
- transitive -- follows and expands all "requires transitive" edges in the module graph
*
- all -- follows and expands all "requires" edges in the module graph.
* By default, only the specified modules will be considered, without expansion
* of the module dependencies.
diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/DeprecatedListWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/DeprecatedListWriter.java
index ef7681cf115..905b0806ba3 100644
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/DeprecatedListWriter.java
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/DeprecatedListWriter.java
@@ -28,11 +28,18 @@ package jdk.javadoc.internal.doclets.formats.html;
import java.util.ArrayList;
import java.util.EnumMap;
import java.util.List;
+import java.util.SortedSet;
+import javax.lang.model.element.Element;
+import javax.lang.model.element.ModuleElement;
+import javax.lang.model.element.PackageElement;
+
+import com.sun.source.doctree.DocTree;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
+import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
import jdk.javadoc.internal.doclets.toolkit.Content;
import jdk.javadoc.internal.doclets.toolkit.util.DeprecatedAPIListBuilder;
import jdk.javadoc.internal.doclets.toolkit.util.DeprecatedAPIListBuilder.DeprElementKind;
@@ -57,6 +64,8 @@ public class DeprecatedListWriter extends SubWriterHolderWriter {
private String getAnchorName(DeprElementKind kind) {
switch (kind) {
+ case MODULE:
+ return "module";
case PACKAGE:
return "package";
case INTERFACE:
@@ -88,6 +97,8 @@ public class DeprecatedListWriter extends SubWriterHolderWriter {
private String getHeadingKey(DeprElementKind kind) {
switch (kind) {
+ case MODULE:
+ return "doclet.Deprecated_Modules";
case PACKAGE:
return "doclet.Deprecated_Packages";
case INTERFACE:
@@ -119,6 +130,8 @@ public class DeprecatedListWriter extends SubWriterHolderWriter {
private String getSummaryKey(DeprElementKind kind) {
switch (kind) {
+ case MODULE:
+ return "doclet.deprecated_modules";
case PACKAGE:
return "doclet.deprecated_packages";
case INTERFACE:
@@ -150,6 +163,8 @@ public class DeprecatedListWriter extends SubWriterHolderWriter {
private String getHeaderKey(DeprElementKind kind) {
switch (kind) {
+ case MODULE:
+ return "doclet.Module";
case PACKAGE:
return "doclet.Package";
case INTERFACE:
@@ -197,6 +212,7 @@ public class DeprecatedListWriter extends SubWriterHolderWriter {
writerMap = new EnumMap<>(DeprElementKind.class);
for (DeprElementKind kind : DeprElementKind.values()) {
switch (kind) {
+ case MODULE:
case PACKAGE:
case INTERFACE:
case CLASS:
@@ -268,12 +284,16 @@ public class DeprecatedListWriter extends SubWriterHolderWriter {
List memberTableHeader = new ArrayList<>();
memberTableHeader.add(resources.getText(getHeaderKey(kind)));
memberTableHeader.add(resources.getText("doclet.Description"));
- if (kind == DeprElementKind.PACKAGE)
+ if (kind == DeprElementKind.MODULE) {
+ addModuleDeprecatedAPI(deprapi.getSet(kind),
+ getHeadingKey(kind), memberTableSummary, memberTableHeader, div);
+ } else if (kind == DeprElementKind.PACKAGE) {
addPackageDeprecatedAPI(deprapi.getSet(kind),
getHeadingKey(kind), memberTableSummary, memberTableHeader, div);
- else
+ } else {
writerMap.get(kind).addDeprecatedAPI(deprapi.getSet(kind),
getHeadingKey(kind), memberTableSummary, memberTableHeader, div);
+ }
}
}
if (configuration.allowTag(HtmlTag.MAIN)) {
@@ -373,4 +393,88 @@ public class DeprecatedListWriter extends SubWriterHolderWriter {
Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, contents.deprecatedLabel);
return li;
}
+
+ /**
+ * Add module deprecation information to the documentation tree
+ *
+ * @param deprMdles list of deprecated modules
+ * @param headingKey the caption for the deprecated module table
+ * @param tableSummary the summary for the deprecated module table
+ * @param tableHeader table headers for the deprecated module table
+ * @param contentTree the content tree to which the deprecated module table will be added
+ */
+ protected void addModuleDeprecatedAPI(SortedSet deprMdles, String headingKey,
+ String tableSummary, List tableHeader, Content contentTree) {
+ if (deprMdles.size() > 0) {
+ Content caption = getTableCaption(configuration.getContent(headingKey));
+ Content table = (configuration.isOutputHtml5())
+ ? HtmlTree.TABLE(HtmlStyle.deprecatedSummary, caption)
+ : HtmlTree.TABLE(HtmlStyle.deprecatedSummary, tableSummary, caption);
+ table.addContent(getSummaryTableHeader(tableHeader, "col"));
+ Content tbody = new HtmlTree(HtmlTag.TBODY);
+ boolean altColor = true;
+ for (Element e : deprMdles) {
+ ModuleElement mdle = (ModuleElement) e;
+ HtmlTree thRow = HtmlTree.TH_ROW_SCOPE(HtmlStyle.colFirst,
+ getModuleLink(mdle, new StringContent(mdle.getQualifiedName())));
+ HtmlTree tr = HtmlTree.TR(thRow);
+ HtmlTree tdDesc = new HtmlTree(HtmlTag.TD);
+ tdDesc.addStyle(HtmlStyle.colLast);
+ List extends DocTree> tags = utils.getDeprecatedTrees(mdle);
+ if (!tags.isEmpty()) {
+ addInlineDeprecatedComment(mdle, tags.get(0), tdDesc);
+ }
+ tr.addContent(tdDesc);
+ tr.addStyle(altColor ? HtmlStyle.altColor : HtmlStyle.rowColor);
+ altColor = !altColor;
+ tbody.addContent(tr);
+ }
+ table.addContent(tbody);
+ Content li = HtmlTree.LI(HtmlStyle.blockList, table);
+ Content ul = HtmlTree.UL(HtmlStyle.blockList, li);
+ contentTree.addContent(ul);
+ }
+ }
+
+ /**
+ * Add package deprecation information to the documentation tree
+ *
+ * @param deprPkgs list of deprecated packages
+ * @param headingKey the caption for the deprecated package table
+ * @param tableSummary the summary for the deprecated package table
+ * @param tableHeader table headers for the deprecated package table
+ * @param contentTree the content tree to which the deprecated package table will be added
+ */
+ protected void addPackageDeprecatedAPI(SortedSet deprPkgs, String headingKey,
+ String tableSummary, List tableHeader, Content contentTree) {
+ if (deprPkgs.size() > 0) {
+ Content caption = getTableCaption(configuration.getContent(headingKey));
+ Content table = (configuration.isOutputHtml5())
+ ? HtmlTree.TABLE(HtmlStyle.deprecatedSummary, caption)
+ : HtmlTree.TABLE(HtmlStyle.deprecatedSummary, tableSummary, caption);
+ table.addContent(getSummaryTableHeader(tableHeader, "col"));
+ Content tbody = new HtmlTree(HtmlTag.TBODY);
+ boolean altColor = true;
+ for (Element e : deprPkgs) {
+ PackageElement pkg = (PackageElement) e;
+ HtmlTree thRow = HtmlTree.TH_ROW_SCOPE(HtmlStyle.colFirst,
+ getPackageLink(pkg, getPackageName(pkg)));
+ HtmlTree tr = HtmlTree.TR(thRow);
+ HtmlTree tdDesc = new HtmlTree(HtmlTag.TD);
+ tdDesc.addStyle(HtmlStyle.colLast);
+ List extends DocTree> tags = utils.getDeprecatedTrees(pkg);
+ if (!tags.isEmpty()) {
+ addInlineDeprecatedComment(pkg, tags.get(0), tdDesc);
+ }
+ tr.addContent(tdDesc);
+ tr.addStyle(altColor ? HtmlStyle.altColor : HtmlStyle.rowColor);
+ altColor = !altColor;
+ tbody.addContent(tr);
+ }
+ table.addContent(tbody);
+ Content li = HtmlTree.LI(HtmlStyle.blockList, table);
+ Content ul = HtmlTree.UL(HtmlStyle.blockList, li);
+ contentTree.addContent(ul);
+ }
+ }
}
diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java
index 3467dd452e6..c4b2b2b933a 100644
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java
@@ -1045,48 +1045,6 @@ public class HtmlDocletWriter extends HtmlDocWriter {
return new StringContent(packageName);
}
- /**
- * Add package deprecation information to the documentation tree
- *
- * @param deprPkgs list of deprecated packages
- * @param headingKey the caption for the deprecated package table
- * @param tableSummary the summary for the deprecated package table
- * @param tableHeader table headers for the deprecated package table
- * @param contentTree the content tree to which the deprecated package table will be added
- */
- protected void addPackageDeprecatedAPI(SortedSet deprPkgs, String headingKey,
- String tableSummary, List tableHeader, Content contentTree) {
- if (deprPkgs.size() > 0) {
- Content caption = getTableCaption(configuration.getContent(headingKey));
- Content table = (configuration.isOutputHtml5())
- ? HtmlTree.TABLE(HtmlStyle.deprecatedSummary, caption)
- : HtmlTree.TABLE(HtmlStyle.deprecatedSummary, tableSummary, caption);
- table.addContent(getSummaryTableHeader(tableHeader, "col"));
- Content tbody = new HtmlTree(HtmlTag.TBODY);
- boolean altColor = true;
- for (Element e : deprPkgs) {
- PackageElement pkg = (PackageElement) e;
- HtmlTree thRow = HtmlTree.TH_ROW_SCOPE(HtmlStyle.colFirst,
- getPackageLink(pkg, getPackageName(pkg)));
- HtmlTree tr = HtmlTree.TR(thRow);
- HtmlTree tdDesc = new HtmlTree(HtmlTag.TD);
- tdDesc.addStyle(HtmlStyle.colLast);
- List extends DocTree> tags = utils.getDeprecatedTrees(pkg);
- if (!tags.isEmpty()) {
- addInlineDeprecatedComment(pkg, tags.get(0), tdDesc);
- }
- tr.addContent(tdDesc);
- tr.addStyle(altColor ? HtmlStyle.altColor : HtmlStyle.rowColor);
- altColor = !altColor;
- tbody.addContent(tr);
- }
- table.addContent(tbody);
- Content li = HtmlTree.LI(HtmlStyle.blockList, table);
- Content ul = HtmlTree.UL(HtmlStyle.blockList, li);
- contentTree.addContent(ul);
- }
- }
-
/**
* Return the path to the class page for a typeElement.
*
diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleWriterImpl.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleWriterImpl.java
index bb1e9038e26..702d20c8402 100644
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleWriterImpl.java
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleWriterImpl.java
@@ -114,6 +114,7 @@ public class ModuleWriterImpl extends HtmlDocletWriter implements ModuleSummaryW
*
* @param heading the heading for the section
*/
+ @Override
public Content getModuleHeader(String heading) {
HtmlTree bodyTree = getBody(true, getWindowTitle(mdle.getQualifiedName().toString()));
HtmlTree htmlTree = (configuration.allowTag(HtmlTag.HEADER))
@@ -126,6 +127,9 @@ public class ModuleWriterImpl extends HtmlDocletWriter implements ModuleSummaryW
}
HtmlTree div = new HtmlTree(HtmlTag.DIV);
div.addStyle(HtmlStyle.header);
+ Content annotationContent = new HtmlTree(HtmlTag.P);
+ addAnnotationInfo(mdle, annotationContent);
+ div.addContent(annotationContent);
Content tHeading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true,
HtmlStyle.title, contents.moduleLabel);
tHeading.addContent(Contents.SPACE);
@@ -143,6 +147,7 @@ public class ModuleWriterImpl extends HtmlDocletWriter implements ModuleSummaryW
/**
* Get the content header.
*/
+ @Override
public Content getContentHeader() {
HtmlTree div = new HtmlTree(HtmlTag.DIV);
div.addStyle(HtmlStyle.contentContainer);
@@ -152,6 +157,7 @@ public class ModuleWriterImpl extends HtmlDocletWriter implements ModuleSummaryW
/**
* Get the summary section header.
*/
+ @Override
public Content getSummaryHeader() {
HtmlTree li = new HtmlTree(HtmlTag.LI);
li.addStyle(HtmlStyle.blockList);
@@ -163,6 +169,7 @@ public class ModuleWriterImpl extends HtmlDocletWriter implements ModuleSummaryW
*
* @param summaryContentTree the content tree to be added to the summary tree.
*/
+ @Override
public Content getSummaryTree(Content summaryContentTree) {
HtmlTree ul = HtmlTree.UL(HtmlStyle.blockList, summaryContentTree);
return ul;
@@ -225,7 +232,7 @@ public class ModuleWriterImpl extends HtmlDocletWriter implements ModuleSummaryW
* Add the list of directives for the module.
*
* @param dirs the list of module directives
- * @params tbody the content tree to which the list is added
+ * @param tbody the content tree to which the list is added
*/
public void addList(List dirs, Content tbody) {
boolean altColor = true;
@@ -238,6 +245,9 @@ public class ModuleWriterImpl extends HtmlDocletWriter implements ModuleSummaryW
case EXPORTS:
addExportedPackagesList((ModuleElement.ExportsDirective) direct, tbody, altColor);
break;
+ case OPENS:
+ //XXX ignore for now
+ break;
case USES:
addUsesList((ModuleElement.UsesDirective) direct, tbody, altColor);
break;
@@ -254,6 +264,7 @@ public class ModuleWriterImpl extends HtmlDocletWriter implements ModuleSummaryW
/**
* {@inheritDoc}
*/
+ @Override
public void addModulesSummary(Content summaryContentTree) {
List dirs = directiveMap.get(DirectiveKind.REQUIRES);
if (dirs != null && !dirs.isEmpty()) {
@@ -307,6 +318,7 @@ public class ModuleWriterImpl extends HtmlDocletWriter implements ModuleSummaryW
/**
* {@inheritDoc}
*/
+ @Override
public void addPackagesSummary(Content summaryContentTree) {
List dirs = directiveMap.get(DirectiveKind.EXPORTS);
if (dirs != null && !dirs.isEmpty()) {
@@ -376,6 +388,7 @@ public class ModuleWriterImpl extends HtmlDocletWriter implements ModuleSummaryW
/**
* {@inheritDoc}
*/
+ @Override
public void addServicesSummary(Content summaryContentTree) {
List usesDirs = directiveMap.get(DirectiveKind.USES);
List providesDirs = directiveMap.get(DirectiveKind.PROVIDES);
@@ -459,33 +472,60 @@ public class ModuleWriterImpl extends HtmlDocletWriter implements ModuleSummaryW
* @param altColor true if altColor style should be used or false if rowColor style should be used
*/
public void addProvidesList(ModuleElement.ProvidesDirective direct, Content tbody, boolean altColor) {
- TypeElement impl = direct.getImplementation();
- TypeElement srv = direct.getService();
- Content implLinkContent = getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.PACKAGE, impl));
- Content srvLinkContent = getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.PACKAGE, srv));
- HtmlTree thType = HtmlTree.TH_ROW_SCOPE(HtmlStyle.colFirst, srvLinkContent);
- thType.addContent(new HtmlTree(HtmlTag.BR));
- thType.addContent("(");
- HtmlTree implSpan = HtmlTree.SPAN(HtmlStyle.implementationLabel, contents.implementation);
- thType.addContent(implSpan);
- thType.addContent(Contents.SPACE);
- thType.addContent(implLinkContent);
- thType.addContent(")");
- HtmlTree tdDesc = new HtmlTree(HtmlTag.TD);
- tdDesc.addStyle(HtmlStyle.colLast);
- addSummaryComment(srv, tdDesc);
- HtmlTree tr = HtmlTree.TR(thType);
- tr.addContent(tdDesc);
- tr.addStyle(altColor ? HtmlStyle.altColor : HtmlStyle.rowColor);
- tbody.addContent(tr);
+ List extends TypeElement> impls = direct.getImplementations();
+ for (TypeElement impl : impls) {
+ TypeElement srv = direct.getService();
+ Content implLinkContent = getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.PACKAGE, impl));
+ Content srvLinkContent = getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.PACKAGE, srv));
+ HtmlTree thType = HtmlTree.TH_ROW_SCOPE(HtmlStyle.colFirst, srvLinkContent);
+ thType.addContent(new HtmlTree(HtmlTag.BR));
+ thType.addContent("(");
+ HtmlTree implSpan = HtmlTree.SPAN(HtmlStyle.implementationLabel, contents.implementation);
+ thType.addContent(implSpan);
+ thType.addContent(Contents.SPACE);
+ thType.addContent(implLinkContent);
+ thType.addContent(")");
+ HtmlTree tdDesc = new HtmlTree(HtmlTag.TD);
+ tdDesc.addStyle(HtmlStyle.colLast);
+ addSummaryComment(srv, tdDesc);
+ HtmlTree tr = HtmlTree.TR(thType);
+ tr.addContent(tdDesc);
+ tr.addStyle(altColor ? HtmlStyle.altColor : HtmlStyle.rowColor);
+ tbody.addContent(tr);
+ }
+ }
+
+ /**
+ * Add the module deprecation information to the documentation tree.
+ *
+ * @param div the content tree to which the deprecation information will be added
+ */
+ public void addDeprecationInfo(Content div) {
+ List extends DocTree> deprs = utils.getBlockTags(mdle, DocTree.Kind.DEPRECATED);
+ if (utils.isDeprecated(mdle)) {
+ CommentHelper ch = utils.getCommentHelper(mdle);
+ HtmlTree deprDiv = new HtmlTree(HtmlTag.DIV);
+ deprDiv.addStyle(HtmlStyle.deprecatedContent);
+ Content deprPhrase = HtmlTree.SPAN(HtmlStyle.deprecatedLabel, contents.deprecatedPhrase);
+ deprDiv.addContent(deprPhrase);
+ if (!deprs.isEmpty()) {
+ List extends DocTree> commentTags = ch.getDescription(configuration, deprs.get(0));
+ if (!commentTags.isEmpty()) {
+ addInlineDeprecatedComment(mdle, deprs.get(0), deprDiv);
+ }
+ }
+ div.addContent(deprDiv);
+ }
}
/**
* {@inheritDoc}
*/
+ @Override
public void addModuleDescription(Content moduleContentTree) {
if (!utils.getFullBody(mdle).isEmpty()) {
Content tree = configuration.allowTag(HtmlTag.SECTION) ? HtmlTree.SECTION() : moduleContentTree;
+ addDeprecationInfo(tree);
tree.addContent(HtmlConstants.START_OF_MODULE_DESCRIPTION);
tree.addContent(getMarkerAnchor(SectionName.MODULE_DESCRIPTION));
addInlineComment(mdle, tree);
@@ -498,6 +538,7 @@ public class ModuleWriterImpl extends HtmlDocletWriter implements ModuleSummaryW
/**
* {@inheritDoc}
*/
+ @Override
public void addModuleTags(Content moduleContentTree) {
Content tree = (configuration.allowTag(HtmlTag.SECTION))
? HtmlTree.SECTION()
@@ -513,6 +554,7 @@ public class ModuleWriterImpl extends HtmlDocletWriter implements ModuleSummaryW
*
* @param subDiv the content tree to which the summary detail links will be added
*/
+ @Override
protected void addSummaryDetailLinks(Content subDiv) {
Content div = HtmlTree.DIV(getNavSummaryLinks());
subDiv.addContent(div);
@@ -560,6 +602,7 @@ public class ModuleWriterImpl extends HtmlDocletWriter implements ModuleSummaryW
/**
* {@inheritDoc}
*/
+ @Override
public void addModuleContent(Content contentTree, Content moduleContentTree) {
if (configuration.allowTag(HtmlTag.MAIN)) {
mainTree.addContent(moduleContentTree);
@@ -572,6 +615,7 @@ public class ModuleWriterImpl extends HtmlDocletWriter implements ModuleSummaryW
/**
* {@inheritDoc}
*/
+ @Override
public void addModuleFooter(Content contentTree) {
Content htmlTree = (configuration.allowTag(HtmlTag.FOOTER))
? HtmlTree.FOOTER()
@@ -633,6 +677,7 @@ public class ModuleWriterImpl extends HtmlDocletWriter implements ModuleSummaryW
*
* @return a content tree for the previous link
*/
+ @Override
public Content getNavLinkPrevious() {
Content li;
if (prevModule == null) {
@@ -649,6 +694,7 @@ public class ModuleWriterImpl extends HtmlDocletWriter implements ModuleSummaryW
*
* @return a content tree for the next link
*/
+ @Override
public Content getNavLinkNext() {
Content li;
if (nextModule == null) {
diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlAttr.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlAttr.java
index 35b8eedccc7..a4ff308eebd 100644
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlAttr.java
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlAttr.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2016, 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
diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/standard.properties b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/standard.properties
index a69ac46a45f..00239a4fdd9 100644
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/standard.properties
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/standard.properties
@@ -71,6 +71,7 @@ doclet.see.class_or_package_not_found=Tag {0}: reference not found: {1}
doclet.see.class_or_package_not_accessible=Tag {0}: reference not accessible: {1}
doclet.tag.invalid_usage=invalid usage of tag {0}
doclet.Deprecated_API=Deprecated API
+doclet.Deprecated_Modules=Deprecated Modules
doclet.Deprecated_Packages=Deprecated Packages
doclet.Deprecated_Classes=Deprecated Classes
doclet.Deprecated_Enums=Deprecated Enums
@@ -83,6 +84,7 @@ doclet.Deprecated_Constructors=Deprecated Constructors
doclet.Deprecated_Methods=Deprecated Methods
doclet.Deprecated_Enum_Constants=Deprecated Enum Constants
doclet.Deprecated_Annotation_Type_Members=Deprecated Annotation Type Elements
+doclet.deprecated_modules=deprecated modules
doclet.deprecated_packages=deprecated packages
doclet.deprecated_classes=deprecated classes
doclet.deprecated_enums=deprecated enums
diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/standard_ja.properties b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/standard_ja.properties
index bae63666b76..0d0432aa7f5 100644
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/standard_ja.properties
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/standard_ja.properties
@@ -99,7 +99,7 @@ doclet.Subclasses=\u76F4\u7CFB\u306E\u65E2\u77E5\u306E\u30B5\u30D6\u30AF\u30E9\u
doclet.Subinterfaces=\u65E2\u77E5\u306E\u30B5\u30D6\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u306E\u30EA\u30B9\u30C8:
doclet.Implementing_Classes=\u65E2\u77E5\u306E\u5B9F\u88C5\u30AF\u30E9\u30B9\u306E\u30EA\u30B9\u30C8:
doclet.Functional_Interface=\u6A5F\u80FD\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9
-doclet.Functional_Interface_Message=\u3053\u308C\u306F\u6A5F\u80FD\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u306A\u306E\u3067\u3001\u30E9\u30E0\u30C0\u5F0F\u307E\u305F\u306F\u30E1\u30BD\u30C3\u30C9\u53C2\u7167\u306E\u5272\u5F53\u3066\u30BF\u30FC\u30B2\u30C3\u30C8\u3068\u3057\u3066\u4F7F\u7528\u3067\u304D\u307E\u3059\u3002
+doclet.Functional_Interface_Message=\u3053\u308C\u306F\u6A5F\u80FD\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u306A\u306E\u3067\u3001\u30E9\u30E0\u30C0\u5F0F\u307E\u305F\u306F\u30E1\u30BD\u30C3\u30C9\u53C2\u7167\u306E\u5272\u5F53\u3066\u30BF\u30FC\u30B2\u30C3\u30C8\u3068\u3057\u3066\u4F7F\u7528\u3067\u304D\u307E\u3059\u3002
doclet.also=\u540C\u69D8\u306B
doclet.Frames=\u30D5\u30EC\u30FC\u30E0
doclet.No_Frames=\u30D5\u30EC\u30FC\u30E0\u306A\u3057
diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/DeprecatedAPIListBuilder.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/DeprecatedAPIListBuilder.java
index 8dc83827f8a..5c423b3f771 100644
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/DeprecatedAPIListBuilder.java
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/DeprecatedAPIListBuilder.java
@@ -28,6 +28,7 @@ package jdk.javadoc.internal.doclets.toolkit.util;
import java.util.*;
import javax.lang.model.element.Element;
+import javax.lang.model.element.ModuleElement;
import javax.lang.model.element.PackageElement;
import javax.lang.model.element.TypeElement;
@@ -51,6 +52,7 @@ public class DeprecatedAPIListBuilder {
private final Configuration configuration;
private final Utils utils;
public static enum DeprElementKind {
+ MODULE,
PACKAGE,
INTERFACE,
CLASS,
@@ -82,12 +84,19 @@ public class DeprecatedAPIListBuilder {
/**
* Build the sorted list of all the deprecated APIs in this run.
- * Build separate lists for deprecated packages, classes, constructors,
+ * Build separate lists for deprecated modules, packages, classes, constructors,
* methods and fields.
*
* @param configuration the current configuration of the doclet.
*/
private void buildDeprecatedAPIInfo() {
+ SortedSet modules = configuration.modules;
+ SortedSet mset = deprecatedMap.get(DeprElementKind.MODULE);
+ for (Element me : modules) {
+ if (utils.isDeprecated(me)) {
+ mset.add(me);
+ }
+ }
SortedSet packages = configuration.packages;
SortedSet pset = deprecatedMap.get(DeprElementKind.PACKAGE);
for (Element pe : packages) {
@@ -95,7 +104,6 @@ public class DeprecatedAPIListBuilder {
pset.add(pe);
}
}
- deprecatedMap.put(DeprElementKind.PACKAGE, pset);
for (Element e : configuration.docEnv.getIncludedTypeElements()) {
TypeElement te = (TypeElement)e;
SortedSet eset;
diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ElementsTable.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ElementsTable.java
index d678e9a4490..c538d2259a1 100644
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ElementsTable.java
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ElementsTable.java
@@ -516,10 +516,10 @@ public class ElementsTable {
private Set getModuleRequires(ModuleElement mdle, boolean isPublic) {
Set result = new HashSet<>();
for (RequiresDirective rd : ElementFilter.requiresIn(mdle.getDirectives())) {
- if (isPublic && rd.isPublic()) {
+ if (isPublic && rd.isTransitive()) {
result.add(rd.getDependency());
}
- if (!isPublic && !rd.isPublic()) {
+ if (!isPublic && !rd.isTransitive()) {
result.add(rd.getDependency());
}
}
diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ToolOption.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ToolOption.java
index 7f4ef90868b..18623cba1b3 100644
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ToolOption.java
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ToolOption.java
@@ -479,7 +479,7 @@ public enum ToolOption {
void setExpandRequires(ToolOption opt, String arg) throws OptionException {
switch (arg) {
- case "public":
+ case "transitive":
jdtoolOpts.put(opt, AccessKind.PUBLIC);
break;
case "all":
diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/resources/javadoc.properties b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/resources/javadoc.properties
index 89cfe162593..a720cf37fff 100644
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/resources/javadoc.properties
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/resources/javadoc.properties
@@ -81,8 +81,8 @@ main.opt.expand.requires.arg=\
main.opt.expand.requires.desc=\
Instructs the tool to expand the set of modules to be\n\
documented. By default, only the modules given explicitly on\n\
- the command line will be documented. A value of "public" will\n\
- additionally include all "requires public" dependencies of\n\
+ the command line will be documented. A value of "transitive" will\n\
+ additionally include all "requires transitive" dependencies of\n\
those modules. A value of "all" will include all dependencies\n\
of those modules.
diff --git a/langtools/src/jdk.javadoc/share/classes/module-info.java b/langtools/src/jdk.javadoc/share/classes/module-info.java
index 89c5d728fdd..cbac558bf90 100644
--- a/langtools/src/jdk.javadoc/share/classes/module-info.java
+++ b/langtools/src/jdk.javadoc/share/classes/module-info.java
@@ -28,8 +28,8 @@
* and its command line equivalent, javadoc.
*/
module jdk.javadoc {
- requires public java.compiler;
- requires public jdk.compiler;
+ requires transitive java.compiler;
+ requires transitive jdk.compiler;
requires java.xml;
exports com.sun.javadoc;
diff --git a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/classfile/Attribute.java b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/classfile/Attribute.java
index fed0bed45fa..3cb8c1f8f9c 100644
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/classfile/Attribute.java
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/classfile/Attribute.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2016, 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
@@ -42,20 +42,22 @@ public abstract class Attribute {
public static final String BootstrapMethods = "BootstrapMethods";
public static final String CharacterRangeTable = "CharacterRangeTable";
public static final String Code = "Code";
- public static final String ConcealedPackages = "ConcealedPackages";
public static final String ConstantValue = "ConstantValue";
public static final String CompilationID = "CompilationID";
public static final String Deprecated = "Deprecated";
public static final String EnclosingMethod = "EnclosingMethod";
public static final String Exceptions = "Exceptions";
- public static final String Hashes = "Hashes";
public static final String InnerClasses = "InnerClasses";
public static final String LineNumberTable = "LineNumberTable";
public static final String LocalVariableTable = "LocalVariableTable";
public static final String LocalVariableTypeTable = "LocalVariableTypeTable";
- public static final String MainClass = "MainClass";
public static final String MethodParameters = "MethodParameters";
public static final String Module = "Module";
+ public static final String ModuleHashes = "ModuleHashes";
+ public static final String ModuleMainClass = "ModuleMainClass";
+ public static final String ModulePackages = "ModulePackages";
+ public static final String ModuleTarget = "ModuleTarget";
+ public static final String ModuleVersion = "ModuleVersion";
public static final String RuntimeVisibleAnnotations = "RuntimeVisibleAnnotations";
public static final String RuntimeInvisibleAnnotations = "RuntimeInvisibleAnnotations";
public static final String RuntimeVisibleParameterAnnotations = "RuntimeVisibleParameterAnnotations";
@@ -69,8 +71,6 @@ public abstract class Attribute {
public static final String StackMap = "StackMap";
public static final String StackMapTable = "StackMapTable";
public static final String Synthetic = "Synthetic";
- public static final String TargetPlatform = "TargetPlatform";
- public static final String Version = "Version";
public static class Factory {
public Factory() {
@@ -115,19 +115,21 @@ public abstract class Attribute {
standardAttributes.put(CharacterRangeTable, CharacterRangeTable_attribute.class);
standardAttributes.put(Code, Code_attribute.class);
standardAttributes.put(CompilationID, CompilationID_attribute.class);
- standardAttributes.put(ConcealedPackages, ConcealedPackages_attribute.class);
standardAttributes.put(ConstantValue, ConstantValue_attribute.class);
standardAttributes.put(Deprecated, Deprecated_attribute.class);
standardAttributes.put(EnclosingMethod, EnclosingMethod_attribute.class);
standardAttributes.put(Exceptions, Exceptions_attribute.class);
- standardAttributes.put(Hashes, Hashes_attribute.class);
standardAttributes.put(InnerClasses, InnerClasses_attribute.class);
standardAttributes.put(LineNumberTable, LineNumberTable_attribute.class);
standardAttributes.put(LocalVariableTable, LocalVariableTable_attribute.class);
standardAttributes.put(LocalVariableTypeTable, LocalVariableTypeTable_attribute.class);
- standardAttributes.put(MainClass, MainClass_attribute.class);
standardAttributes.put(MethodParameters, MethodParameters_attribute.class);
standardAttributes.put(Module, Module_attribute.class);
+ standardAttributes.put(ModuleHashes, ModuleHashes_attribute.class);
+ standardAttributes.put(ModuleMainClass, ModuleMainClass_attribute.class);
+ standardAttributes.put(ModulePackages, ModulePackages_attribute.class);
+ standardAttributes.put(ModuleTarget, ModuleTarget_attribute.class);
+ standardAttributes.put(ModuleVersion, ModuleVersion_attribute.class);
standardAttributes.put(RuntimeInvisibleAnnotations, RuntimeInvisibleAnnotations_attribute.class);
standardAttributes.put(RuntimeInvisibleParameterAnnotations, RuntimeInvisibleParameterAnnotations_attribute.class);
standardAttributes.put(RuntimeVisibleAnnotations, RuntimeVisibleAnnotations_attribute.class);
@@ -141,8 +143,6 @@ public abstract class Attribute {
standardAttributes.put(StackMap, StackMap_attribute.class);
standardAttributes.put(StackMapTable, StackMapTable_attribute.class);
standardAttributes.put(Synthetic, Synthetic_attribute.class);
- standardAttributes.put(TargetPlatform, TargetPlatform_attribute.class);
- standardAttributes.put(Version, Version_attribute.class);
}
private Map> standardAttributes;
@@ -178,19 +178,21 @@ public abstract class Attribute {
R visitCharacterRangeTable(CharacterRangeTable_attribute attr, P p);
R visitCode(Code_attribute attr, P p);
R visitCompilationID(CompilationID_attribute attr, P p);
- R visitConcealedPackages(ConcealedPackages_attribute attr, P p);
R visitConstantValue(ConstantValue_attribute attr, P p);
R visitDeprecated(Deprecated_attribute attr, P p);
R visitEnclosingMethod(EnclosingMethod_attribute attr, P p);
R visitExceptions(Exceptions_attribute attr, P p);
- R visitHashes(Hashes_attribute attr, P p);
R visitInnerClasses(InnerClasses_attribute attr, P p);
R visitLineNumberTable(LineNumberTable_attribute attr, P p);
R visitLocalVariableTable(LocalVariableTable_attribute attr, P p);
R visitLocalVariableTypeTable(LocalVariableTypeTable_attribute attr, P p);
- R visitMainClass(MainClass_attribute attr, P p);
R visitMethodParameters(MethodParameters_attribute attr, P p);
R visitModule(Module_attribute attr, P p);
+ R visitModuleHashes(ModuleHashes_attribute attr, P p);
+ R visitModuleMainClass(ModuleMainClass_attribute attr, P p);
+ R visitModulePackages(ModulePackages_attribute attr, P p);
+ R visitModuleTarget(ModuleTarget_attribute attr, P p);
+ R visitModuleVersion(ModuleVersion_attribute attr, P p);
R visitRuntimeVisibleAnnotations(RuntimeVisibleAnnotations_attribute attr, P p);
R visitRuntimeInvisibleAnnotations(RuntimeInvisibleAnnotations_attribute attr, P p);
R visitRuntimeVisibleParameterAnnotations(RuntimeVisibleParameterAnnotations_attribute attr, P p);
@@ -204,7 +206,5 @@ public abstract class Attribute {
R visitStackMap(StackMap_attribute attr, P p);
R visitStackMapTable(StackMapTable_attribute attr, P p);
R visitSynthetic(Synthetic_attribute attr, P p);
- R visitTargetPlatform(TargetPlatform_attribute attr, P p);
- R visitVersion(Version_attribute attr, P p);
}
}
diff --git a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/classfile/ClassWriter.java b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/classfile/ClassWriter.java
index b4fad8ac72d..c3b8d811276 100644
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/classfile/ClassWriter.java
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/classfile/ClassWriter.java
@@ -55,6 +55,9 @@ public class ClassWriter {
/**
* Write a ClassFile data structure to a file.
+ * @param classFile the classfile object to be written
+ * @param f the file
+ * @throws IOException if an error occurs while writing the file
*/
public void write(ClassFile classFile, File f) throws IOException {
try (FileOutputStream f_out = new FileOutputStream(f)) {
@@ -64,6 +67,9 @@ public class ClassWriter {
/**
* Write a ClassFile data structure to a stream.
+ * @param classFile the classfile object to be written
+ * @param s the stream
+ * @throws IOException if an error occurs while writing the file
*/
public void write(ClassFile classFile, OutputStream s) throws IOException {
this.classFile = classFile;
@@ -419,7 +425,7 @@ public class ClassWriter {
}
@Override
- public Void visitConcealedPackages(ConcealedPackages_attribute attr, ClassOutputStream out) {
+ public Void visitModulePackages(ModulePackages_attribute attr, ClassOutputStream out) {
out.writeShort(attr.packages_count);
for (int i: attr.packages_index)
out.writeShort(i);
@@ -461,12 +467,15 @@ public class ClassWriter {
}
@Override
- public Void visitHashes(Hashes_attribute attr, ClassOutputStream out) {
+ public Void visitModuleHashes(ModuleHashes_attribute attr, ClassOutputStream out) {
out.writeShort(attr.algorithm_index);
out.writeShort(attr.hashes_table.length);
- for (Hashes_attribute.Entry e: attr.hashes_table) {
- out.writeShort(e.requires_index);
- out.writeShort(e.hash_index);
+ for (ModuleHashes_attribute.Entry e: attr.hashes_table) {
+ out.writeShort(e.module_name_index);
+ out.writeShort(e.hash.length);
+ for (byte b: e.hash) {
+ out.writeByte(b);
+ }
}
return null;
}
@@ -534,33 +543,54 @@ public class ClassWriter {
}
@Override
- public Void visitMainClass(MainClass_attribute attr, ClassOutputStream out) {
+ public Void visitModuleMainClass(ModuleMainClass_attribute attr, ClassOutputStream out) {
out.writeShort(attr.main_class_index);
return null;
}
@Override
public Void visitModule(Module_attribute attr, ClassOutputStream out) {
+ out.writeShort(attr.module_name);
+ out.writeShort(attr.module_flags);
+
out.writeShort(attr.requires.length);
for (Module_attribute.RequiresEntry e: attr.requires) {
out.writeShort(e.requires_index);
out.writeShort(e.requires_flags);
}
+
out.writeShort(attr.exports.length);
for (Module_attribute.ExportsEntry e: attr.exports) {
out.writeShort(e.exports_index);
+ out.writeShort(e.exports_flags);
out.writeShort(e.exports_to_index.length);
for (int index: e.exports_to_index)
out.writeShort(index);
}
+
+ out.writeShort(attr.opens.length);
+ for (Module_attribute.OpensEntry e: attr.opens) {
+ out.writeShort(e.opens_index);
+ out.writeShort(e.opens_flags);
+ out.writeShort(e.opens_to_index.length);
+ for (int index: e.opens_to_index)
+ out.writeShort(index);
+ }
+
out.writeShort(attr.uses_index.length);
- for (int index: attr.uses_index)
+ for (int index: attr.uses_index) {
out.writeShort(index);
+ }
+
out.writeShort(attr.provides.length);
for (Module_attribute.ProvidesEntry e: attr.provides) {
out.writeShort(e.provides_index);
- out.writeShort(e.with_index);
+ out.writeShort(e.with_count);
+ for (int with : e.with_index) {
+ out.writeShort(with);
+ }
}
+
return null;
}
@@ -656,7 +686,7 @@ public class ClassWriter {
}
@Override
- public Void visitTargetPlatform(TargetPlatform_attribute attr, ClassOutputStream out) {
+ public Void visitModuleTarget(ModuleTarget_attribute attr, ClassOutputStream out) {
out.writeShort(attr.os_name_index);
out.writeShort(attr.os_arch_index);
out.writeShort(attr.os_version_index);
@@ -668,7 +698,7 @@ public class ClassWriter {
}
@Override
- public Void visitVersion(Version_attribute attr, ClassOutputStream out) {
+ public Void visitModuleVersion(ModuleVersion_attribute attr, ClassOutputStream out) {
out.writeShort(attr.version_index);
return null;
}
diff --git a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/classfile/Hashes_attribute.java b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/classfile/ModuleHashes_attribute.java
similarity index 67%
rename from langtools/src/jdk.jdeps/share/classes/com/sun/tools/classfile/Hashes_attribute.java
rename to langtools/src/jdk.jdeps/share/classes/com/sun/tools/classfile/ModuleHashes_attribute.java
index a248ebce622..c227f3df8b7 100644
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/classfile/Hashes_attribute.java
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/classfile/ModuleHashes_attribute.java
@@ -35,8 +35,8 @@ import java.io.IOException;
* This code and its internal interfaces are subject to change or
* deletion without notice.
*/
-public class Hashes_attribute extends Attribute {
- Hashes_attribute(ClassReader cr, int name_index, int length) throws IOException {
+public class ModuleHashes_attribute extends Attribute {
+ ModuleHashes_attribute(ClassReader cr, int name_index, int length) throws IOException {
super(name_index, length);
algorithm_index = cr.readUnsignedShort();
hashes_table_length = cr.readUnsignedShort();
@@ -45,13 +45,13 @@ public class Hashes_attribute extends Attribute {
hashes_table[i] = new Entry(cr);
}
- public Hashes_attribute(ConstantPool constant_pool, int algorithm_index, Entry[] hashes_table)
+ public ModuleHashes_attribute(ConstantPool constant_pool, int algorithm_index, Entry[] hashes_table)
throws ConstantPoolException {
- this(constant_pool.getUTF8Index(Attribute.Hashes), algorithm_index, hashes_table);
+ this(constant_pool.getUTF8Index(Attribute.ModuleHashes), algorithm_index, hashes_table);
}
- public Hashes_attribute(int name_index, int algorithm_index, Entry[] hashes_table) {
- super(name_index, 4 + hashes_table.length * Entry.length());
+ public ModuleHashes_attribute(int name_index, int algorithm_index, Entry[] hashes_table) {
+ super(name_index, 2 + 2 + length(hashes_table));
this.algorithm_index = algorithm_index;
this.hashes_table_length = hashes_table.length;
this.hashes_table = hashes_table;
@@ -59,7 +59,15 @@ public class Hashes_attribute extends Attribute {
@Override
public R accept(Visitor visitor, D data) {
- return visitor.visitHashes(this, data);
+ return visitor.visitModuleHashes(this, data);
+ }
+
+ private static int length(Entry[] hashes_table) {
+ int len = 0;
+ for (Entry e: hashes_table) {
+ len += e.length();
+ }
+ return len;
}
public final int algorithm_index;
@@ -68,16 +76,20 @@ public class Hashes_attribute extends Attribute {
public static class Entry {
Entry(ClassReader cr) throws IOException {
- requires_index = cr.readUnsignedShort();
- hash_index = cr.readUnsignedShort();
+ module_name_index = cr.readUnsignedShort();
+ int hash_length = cr.readUnsignedShort();
+ hash = new byte[hash_length];
+ for (int i=0; i
*/
-public class MainClass_attribute extends Attribute {
- MainClass_attribute(ClassReader cr, int name_index, int length) throws IOException {
+public class ModuleMainClass_attribute extends Attribute {
+ ModuleMainClass_attribute(ClassReader cr, int name_index, int length) throws IOException {
super(name_index, length);
main_class_index = cr.readUnsignedShort();
}
- public MainClass_attribute(ConstantPool constant_pool, int mainClass_index)
+ public ModuleMainClass_attribute(ConstantPool constant_pool, int mainClass_index)
throws ConstantPoolException {
- this(constant_pool.getUTF8Index(Attribute.Version), mainClass_index);
+ this(constant_pool.getUTF8Index(Attribute.ModuleMainClass), mainClass_index);
}
- public MainClass_attribute(int name_index, int mainClass_index) {
+ public ModuleMainClass_attribute(int name_index, int mainClass_index) {
super(name_index, 2);
this.main_class_index = mainClass_index;
}
@@ -57,7 +57,7 @@ public class MainClass_attribute extends Attribute {
@Override
public R accept(Visitor visitor, D data) {
- return visitor.visitMainClass(this, data);
+ return visitor.visitModuleMainClass(this, data);
}
public final int main_class_index;
diff --git a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/classfile/ConcealedPackages_attribute.java b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/classfile/ModulePackages_attribute.java
similarity index 82%
rename from langtools/src/jdk.jdeps/share/classes/com/sun/tools/classfile/ConcealedPackages_attribute.java
rename to langtools/src/jdk.jdeps/share/classes/com/sun/tools/classfile/ModulePackages_attribute.java
index dc56d7b381a..a6eb2ffbfe7 100644
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/classfile/ConcealedPackages_attribute.java
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/classfile/ModulePackages_attribute.java
@@ -35,8 +35,8 @@ import java.io.IOException;
* This code and its internal interfaces are subject to change or
* deletion without notice.
*/
-public class ConcealedPackages_attribute extends Attribute {
- ConcealedPackages_attribute(ClassReader cr, int name_index, int length)
+public class ModulePackages_attribute extends Attribute {
+ ModulePackages_attribute(ClassReader cr, int name_index, int length)
throws IOException {
super(name_index, length);
packages_count = cr.readUnsignedShort();
@@ -45,15 +45,15 @@ public class ConcealedPackages_attribute extends Attribute {
packages_index[i] = cr.readUnsignedShort();
}
- public ConcealedPackages_attribute(ConstantPool constant_pool,
- int[] packages_index)
+ public ModulePackages_attribute(ConstantPool constant_pool,
+ int[] packages_index)
throws ConstantPoolException {
- this(constant_pool.getUTF8Index(Attribute.ConcealedPackages),
+ this(constant_pool.getUTF8Index(Attribute.ModulePackages),
packages_index);
}
- public ConcealedPackages_attribute(int name_index,
- int[] packages_index) {
+ public ModulePackages_attribute(int name_index,
+ int[] packages_index) {
super(name_index, 2 + packages_index.length * 2);
this.packages_count = packages_index.length;
this.packages_index = packages_index;
@@ -66,7 +66,7 @@ public class ConcealedPackages_attribute extends Attribute {
@Override
public R accept(Visitor visitor, D data) {
- return visitor.visitConcealedPackages(this, data);
+ return visitor.visitModulePackages(this, data);
}
public final int packages_count;
diff --git a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/classfile/TargetPlatform_attribute.java b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/classfile/ModuleTarget_attribute.java
similarity index 90%
rename from langtools/src/jdk.jdeps/share/classes/com/sun/tools/classfile/TargetPlatform_attribute.java
rename to langtools/src/jdk.jdeps/share/classes/com/sun/tools/classfile/ModuleTarget_attribute.java
index ad469a54524..630eac1bbf5 100644
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/classfile/TargetPlatform_attribute.java
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/classfile/ModuleTarget_attribute.java
@@ -35,8 +35,8 @@ import java.io.IOException;
* This code and its internal interfaces are subject to change or
* deletion without notice.
*/
-public class TargetPlatform_attribute extends Attribute {
- TargetPlatform_attribute(ClassReader cr, int name_index, int length) throws IOException {
+public class ModuleTarget_attribute extends Attribute {
+ ModuleTarget_attribute(ClassReader cr, int name_index, int length) throws IOException {
super(name_index, length);
os_name_index = cr.readUnsignedShort();
os_arch_index = cr.readUnsignedShort();
@@ -45,7 +45,7 @@ public class TargetPlatform_attribute extends Attribute {
@Override
public R accept(Visitor visitor, D data) {
- return visitor.visitTargetPlatform(this, data);
+ return visitor.visitModuleTarget(this, data);
}
public final int os_name_index;
diff --git a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/classfile/Version_attribute.java b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/classfile/ModuleVersion_attribute.java
similarity index 80%
rename from langtools/src/jdk.jdeps/share/classes/com/sun/tools/classfile/Version_attribute.java
rename to langtools/src/jdk.jdeps/share/classes/com/sun/tools/classfile/ModuleVersion_attribute.java
index ed6b749b715..8415d791496 100644
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/classfile/Version_attribute.java
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/classfile/ModuleVersion_attribute.java
@@ -35,25 +35,25 @@ import java.io.IOException;
* This code and its internal interfaces are subject to change or
* deletion without notice.
*/
-public class Version_attribute extends Attribute {
- Version_attribute(ClassReader cr, int name_index, int length) throws IOException {
+public class ModuleVersion_attribute extends Attribute {
+ ModuleVersion_attribute(ClassReader cr, int name_index, int length) throws IOException {
super(name_index, length);
version_index = cr.readUnsignedShort();
}
- public Version_attribute(ConstantPool constant_pool, int version_index)
+ public ModuleVersion_attribute(ConstantPool constant_pool, int version_index)
throws ConstantPoolException {
- this(constant_pool.getUTF8Index(Attribute.Version), version_index);
+ this(constant_pool.getUTF8Index(Attribute.ModuleVersion), version_index);
}
- public Version_attribute(int name_index, int version_index) {
+ public ModuleVersion_attribute(int name_index, int version_index) {
super(name_index, 2);
this.version_index = version_index;
}
@Override
public R accept(Visitor visitor, D data) {
- return visitor.visitVersion(this, data);
+ return visitor.visitModuleVersion(this, data);
}
public final int version_index;
diff --git a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/classfile/Module_attribute.java b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/classfile/Module_attribute.java
index b20729fba91..85262fbd8fe 100644
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/classfile/Module_attribute.java
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/classfile/Module_attribute.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, 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
@@ -36,24 +36,38 @@ import java.io.IOException;
* deletion without notice.
*/
public class Module_attribute extends Attribute {
- public static final int ACC_PUBLIC = 0x20;
- public static final int ACC_SYNTHETIC = 0x1000;
- public static final int ACC_MANDATED = 0x8000;
+ public static final int ACC_TRANSITIVE = 0x10;
+ public static final int ACC_STATIC_PHASE = 0x20;
+ public static final int ACC_OPEN = 0x20;
+ public static final int ACC_SYNTHETIC = 0x1000;
+ public static final int ACC_MANDATED = 0x8000;
Module_attribute(ClassReader cr, int name_index, int length) throws IOException {
super(name_index, length);
+
+ module_name = cr.readUnsignedShort();
+ module_flags = cr.readUnsignedShort();
+
requires_count = cr.readUnsignedShort();
requires = new RequiresEntry[requires_count];
for (int i = 0; i < requires_count; i++)
requires[i] = new RequiresEntry(cr);
+
exports_count = cr.readUnsignedShort();
exports = new ExportsEntry[exports_count];
for (int i = 0; i < exports_count; i++)
exports[i] = new ExportsEntry(cr);
+
+ opens_count = cr.readUnsignedShort();
+ opens = new OpensEntry[opens_count];
+ for (int i = 0; i < opens_count; i++)
+ opens[i] = new OpensEntry(cr);
+
uses_count = cr.readUnsignedShort();
uses_index = new int[uses_count];
for (int i = 0; i < uses_count; i++)
uses_index[i] = cr.readUnsignedShort();
+
provides_count = cr.readUnsignedShort();
provides = new ProvidesEntry[provides_count];
for (int i = 0; i < provides_count; i++)
@@ -61,20 +75,26 @@ public class Module_attribute extends Attribute {
}
public Module_attribute(int name_index,
+ int module_name,
+ int module_flags,
RequiresEntry[] requires,
ExportsEntry[] exports,
+ OpensEntry[] opens,
int[] uses,
ProvidesEntry[] provides) {
super(name_index, 2);
+ this.module_name = module_name;
+ this.module_flags = module_flags;
requires_count = requires.length;
this.requires = requires;
exports_count = exports.length;
this.exports = exports;
+ opens_count = opens.length;
+ this.opens = opens;
uses_count = uses.length;
this.uses_index = uses;
provides_count = provides.length;
this.provides = provides;
-
}
public String getUses(int index, ConstantPool constant_pool) throws ConstantPoolException {
@@ -87,10 +107,14 @@ public class Module_attribute extends Attribute {
return visitor.visitModule(this, data);
}
+ public final int module_name;
+ public final int module_flags;
public final int requires_count;
public final RequiresEntry[] requires;
public final int exports_count;
public final ExportsEntry[] exports;
+ public final int opens_count;
+ public final OpensEntry[] opens;
public final int uses_count;
public final int[] uses_index;
public final int provides_count;
@@ -120,14 +144,16 @@ public class Module_attribute extends Attribute {
public static class ExportsEntry {
ExportsEntry(ClassReader cr) throws IOException {
exports_index = cr.readUnsignedShort();
+ exports_flags = cr.readUnsignedShort();
exports_to_count = cr.readUnsignedShort();
exports_to_index = new int[exports_to_count];
for (int i = 0; i < exports_to_count; i++)
exports_to_index[i] = cr.readUnsignedShort();
}
- public ExportsEntry(int index, int[] to) {
+ public ExportsEntry(int index, int flags, int[] to) {
this.exports_index = index;
+ this.exports_flags = flags;
this.exports_to_count = to.length;
this.exports_to_index = to;
}
@@ -137,24 +163,57 @@ public class Module_attribute extends Attribute {
}
public final int exports_index;
+ public final int exports_flags;
public final int exports_to_count;
public final int[] exports_to_index;
}
+ public static class OpensEntry {
+ OpensEntry(ClassReader cr) throws IOException {
+ opens_index = cr.readUnsignedShort();
+ opens_flags = cr.readUnsignedShort();
+ opens_to_count = cr.readUnsignedShort();
+ opens_to_index = new int[opens_to_count];
+ for (int i = 0; i < opens_to_count; i++)
+ opens_to_index[i] = cr.readUnsignedShort();
+ }
+
+ public OpensEntry(int index, int flags, int[] to) {
+ this.opens_index = index;
+ this.opens_flags = flags;
+ this.opens_to_count = to.length;
+ this.opens_to_index = to;
+ }
+
+ public int length() {
+ return 4 + 2 * opens_to_index.length;
+ }
+
+ public final int opens_index;
+ public final int opens_flags;
+ public final int opens_to_count;
+ public final int[] opens_to_index;
+ }
+
public static class ProvidesEntry {
ProvidesEntry(ClassReader cr) throws IOException {
provides_index = cr.readUnsignedShort();
- with_index = cr.readUnsignedShort();
+ with_count = cr.readUnsignedShort();
+ with_index = new int[with_count];
+ for (int i = 0; i < with_count; i++)
+ with_index[i] = cr.readUnsignedShort();
}
- public ProvidesEntry(int provides, int with) {
+ public ProvidesEntry(int provides, int[] with) {
this.provides_index = provides;
+ this.with_count = with.length;
this.with_index = with;
}
public static final int length = 4;
public final int provides_index;
- public final int with_index;
+ public final int with_count;
+ public final int[] with_index;
}
}
diff --git a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/javap/AttributeWriter.java b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/javap/AttributeWriter.java
index 562d419c2d1..45fc421b5ac 100644
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/javap/AttributeWriter.java
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/javap/AttributeWriter.java
@@ -34,7 +34,6 @@ import com.sun.tools.classfile.CharacterRangeTable_attribute;
import com.sun.tools.classfile.CharacterRangeTable_attribute.Entry;
import com.sun.tools.classfile.Code_attribute;
import com.sun.tools.classfile.CompilationID_attribute;
-import com.sun.tools.classfile.ConcealedPackages_attribute;
import com.sun.tools.classfile.ConstantPool;
import com.sun.tools.classfile.ConstantPoolException;
import com.sun.tools.classfile.ConstantValue_attribute;
@@ -42,15 +41,18 @@ import com.sun.tools.classfile.DefaultAttribute;
import com.sun.tools.classfile.Deprecated_attribute;
import com.sun.tools.classfile.EnclosingMethod_attribute;
import com.sun.tools.classfile.Exceptions_attribute;
-import com.sun.tools.classfile.Hashes_attribute;
import com.sun.tools.classfile.InnerClasses_attribute;
import com.sun.tools.classfile.InnerClasses_attribute.Info;
import com.sun.tools.classfile.LineNumberTable_attribute;
import com.sun.tools.classfile.LocalVariableTable_attribute;
import com.sun.tools.classfile.LocalVariableTypeTable_attribute;
-import com.sun.tools.classfile.MainClass_attribute;
import com.sun.tools.classfile.MethodParameters_attribute;
import com.sun.tools.classfile.Module_attribute;
+import com.sun.tools.classfile.ModuleHashes_attribute;
+import com.sun.tools.classfile.ModuleMainClass_attribute;
+import com.sun.tools.classfile.ModulePackages_attribute;
+import com.sun.tools.classfile.ModuleTarget_attribute;
+import com.sun.tools.classfile.ModuleVersion_attribute;
import com.sun.tools.classfile.RuntimeInvisibleAnnotations_attribute;
import com.sun.tools.classfile.RuntimeInvisibleParameterAnnotations_attribute;
import com.sun.tools.classfile.RuntimeInvisibleTypeAnnotations_attribute;
@@ -64,8 +66,6 @@ import com.sun.tools.classfile.SourceID_attribute;
import com.sun.tools.classfile.StackMapTable_attribute;
import com.sun.tools.classfile.StackMap_attribute;
import com.sun.tools.classfile.Synthetic_attribute;
-import com.sun.tools.classfile.TargetPlatform_attribute;
-import com.sun.tools.classfile.Version_attribute;
import static com.sun.tools.classfile.AccessFlags.*;
@@ -237,7 +237,7 @@ public class AttributeWriter extends BasicWriter
return null;
}
- private String getJavaPackage(ConcealedPackages_attribute attr, int index) {
+ private String getJavaPackage(ModulePackages_attribute attr, int index) {
try {
return getJavaName(attr.getPackage(index, constant_pool));
} catch (ConstantPoolException e) {
@@ -246,8 +246,8 @@ public class AttributeWriter extends BasicWriter
}
@Override
- public Void visitConcealedPackages(ConcealedPackages_attribute attr, Void ignore) {
- println("ConcealedPackages: ");
+ public Void visitModulePackages(ModulePackages_attribute attr, Void ignore) {
+ println("ModulePackages: ");
indent(+1);
for (int i = 0; i < attr.packages_count; i++) {
print("#" + attr.packages_index[i]);
@@ -323,22 +323,24 @@ public class AttributeWriter extends BasicWriter
}
@Override
- public Void visitHashes(Hashes_attribute attr, Void ignore) {
- println("Hashes:");
+ public Void visitModuleHashes(ModuleHashes_attribute attr, Void ignore) {
+ println("ModuleHashes:");
indent(+1);
print("algorithm #" + attr.algorithm_index);
tab();
println("// " + getAlgorithm(attr));
- for (Hashes_attribute.Entry e : attr.hashes_table) {
- print("#" + e.requires_index + ", #" + e.hash_index);
+ for (ModuleHashes_attribute.Entry e : attr.hashes_table) {
+ print("#" + e.module_name_index);
tab();
- println("// " + getRequires(e) + ": " + getHash(e));
+ println("// " + getModuleName(e));
+ println("hash_length: " + e.hash.length);
+ println("hash: [" + toHex(e.hash) + "]");
}
indent(-1);
return null;
}
- private String getAlgorithm(Hashes_attribute attr) {
+ private String getAlgorithm(ModuleHashes_attribute attr) {
try {
return constant_pool.getUTF8Value(attr.algorithm_index);
} catch (ConstantPoolException e) {
@@ -346,17 +348,9 @@ public class AttributeWriter extends BasicWriter
}
}
- private String getRequires(Hashes_attribute.Entry entry) {
+ private String getModuleName(ModuleHashes_attribute.Entry entry) {
try {
- return constant_pool.getUTF8Value(entry.requires_index);
- } catch (ConstantPoolException e) {
- return report(e);
- }
- }
-
- private String getHash(Hashes_attribute.Entry entry) {
- try {
- return constant_pool.getUTF8Value(entry.hash_index);
+ return constant_pool.getUTF8Value(entry.module_name_index);
} catch (ConstantPoolException e) {
return report(e);
}
@@ -456,15 +450,15 @@ public class AttributeWriter extends BasicWriter
}
@Override
- public Void visitMainClass(MainClass_attribute attr, Void ignore) {
- print("MainClass: #" + attr.main_class_index);
+ public Void visitModuleMainClass(ModuleMainClass_attribute attr, Void ignore) {
+ print("ModuleMainClass: #" + attr.main_class_index);
tab();
print("// " + getJavaClassName(attr));
println();
return null;
}
- private String getJavaClassName(MainClass_attribute a) {
+ private String getJavaClassName(ModuleMainClass_attribute a) {
try {
return getJavaName(a.getMainClassName(constant_pool));
} catch (ConstantPoolException e) {
@@ -477,7 +471,6 @@ public class AttributeWriter extends BasicWriter
@Override
public Void visitMethodParameters(MethodParameters_attribute attr,
Void ignore) {
-
final String header = String.format(format, "Name", "Flags");
println("MethodParameters:");
indent(+1);
@@ -501,8 +494,25 @@ public class AttributeWriter extends BasicWriter
public Void visitModule(Module_attribute attr, Void ignore) {
println("Module:");
indent(+1);
+
+ print(attr.module_name);
+ tab();
+ println("// " + constantWriter.stringValue(attr.module_name));
+
+ print(String.format("%x", attr.module_flags));
+ tab();
+ print("// ");
+ if ((attr.module_flags & Module_attribute.ACC_OPEN) != 0)
+ print(" ACC_OPEN");
+ if ((attr.module_flags & Module_attribute.ACC_MANDATED) != 0)
+ print(" ACC_MANDATED");
+ if ((attr.module_flags & Module_attribute.ACC_SYNTHETIC) != 0)
+ print(" ACC_SYNTHETIC");
+ println();
+
printRequiresTable(attr);
printExportsTable(attr);
+ printOpensTable(attr);
printUsesTable(attr);
printProvidesTable(attr);
indent(-1);
@@ -511,63 +521,107 @@ public class AttributeWriter extends BasicWriter
protected void printRequiresTable(Module_attribute attr) {
Module_attribute.RequiresEntry[] entries = attr.requires;
- println(entries.length + "\t// " + "requires");
+ print(entries.length);
+ tab();
+ println("// " + "requires");
indent(+1);
for (Module_attribute.RequiresEntry e: entries) {
- print("#" + e.requires_index + "," +
- String.format("%x", e.requires_flags)+ "\t// requires");
- if ((e.requires_flags & Module_attribute.ACC_PUBLIC) != 0)
- print(" public");
+ print("#" + e.requires_index + "," + String.format("%x", e.requires_flags));
+ tab();
+ print("// " + constantWriter.stringValue(e.requires_index));
+ if ((e.requires_flags & Module_attribute.ACC_TRANSITIVE) != 0)
+ print(" ACC_TRANSITIVE");
+ if ((e.requires_flags & Module_attribute.ACC_STATIC_PHASE) != 0)
+ print(" ACC_STATIC_PHASE");
if ((e.requires_flags & Module_attribute.ACC_SYNTHETIC) != 0)
- print(" synthetic");
+ print(" ACC_SYNTHETIC");
if ((e.requires_flags & Module_attribute.ACC_MANDATED) != 0)
- print(" mandated");
- println(" " + constantWriter.stringValue(e.requires_index));
+ print(" ACC_MANDATED");
+ println();
}
indent(-1);
}
protected void printExportsTable(Module_attribute attr) {
Module_attribute.ExportsEntry[] entries = attr.exports;
- println(entries.length + "\t// " + "exports");
+ print(entries.length);
+ tab();
+ println("// exports");
indent(+1);
for (Module_attribute.ExportsEntry e: entries) {
- print("#" + e.exports_index + "\t// exports");
- print(" " + constantWriter.stringValue(e.exports_index));
- if (e.exports_to_index.length == 0) {
- println();
- } else {
- println(" to ... " + e.exports_to_index.length);
- indent(+1);
- for (int to: e.exports_to_index) {
- println("#" + to + "\t// ... to " + constantWriter.stringValue(to));
- }
- indent(-1);
- }
+ printExportOpenEntry(e.exports_index, e.exports_flags, e.exports_to_index);
}
indent(-1);
}
+ protected void printOpensTable(Module_attribute attr) {
+ Module_attribute.OpensEntry[] entries = attr.opens;
+ print(entries.length);
+ tab();
+ println("// opens");
+ indent(+1);
+ for (Module_attribute.OpensEntry e: entries) {
+ printExportOpenEntry(e.opens_index, e.opens_flags, e.opens_to_index);
+ }
+ indent(-1);
+ }
+
+ protected void printExportOpenEntry(int index, int flags, int[] to_index) {
+ print("#" + index + "," + String.format("%x", flags));
+ tab();
+ print("// ");
+ print(constantWriter.stringValue(index));
+ if ((flags & Module_attribute.ACC_MANDATED) != 0)
+ print(" ACC_MANDATED");
+ if ((flags & Module_attribute.ACC_SYNTHETIC) != 0)
+ print(" ACC_SYNTHETIC");
+ if (to_index.length == 0) {
+ println();
+ } else {
+ println(" to ... " + to_index.length);
+ indent(+1);
+ for (int to: to_index) {
+ print("#" + to);
+ tab();
+ println("// ... to " + constantWriter.stringValue(to));
+ }
+ indent(-1);
+ }
+ }
+
protected void printUsesTable(Module_attribute attr) {
int[] entries = attr.uses_index;
- println(entries.length + "\t// " + "uses services");
+ print(entries.length);
+ tab();
+ println("// " + "uses");
indent(+1);
for (int e: entries) {
- println("#" + e + "\t// uses " + constantWriter.stringValue(e));
+ print("#" + e);
+ tab();
+ println("// " + constantWriter.stringValue(e));
}
indent(-1);
}
protected void printProvidesTable(Module_attribute attr) {
Module_attribute.ProvidesEntry[] entries = attr.provides;
- println(entries.length + "\t// " + "provides services");
+ print(entries.length);
+ tab();
+ println("// " + "provides");
indent(+1);
for (Module_attribute.ProvidesEntry e: entries) {
- print("#" + e.provides_index + ",#" +
- e.with_index + "\t// provides ");
+ print("#" + e.provides_index);
+ tab();
+ print("// ");
print(constantWriter.stringValue(e.provides_index));
- print (" with ");
- println(constantWriter.stringValue(e.with_index));
+ println(" with ... " + e.with_count);
+ indent(+1);
+ for (int with : e.with_index) {
+ print("#" + with);
+ tab();
+ println("// ... with " + constantWriter.stringValue(with));
+ }
+ indent(-1);
}
indent(-1);
}
@@ -876,8 +930,8 @@ public class AttributeWriter extends BasicWriter
}
@Override
- public Void visitTargetPlatform(TargetPlatform_attribute attr, Void ignore) {
- println("TargetPlatform:");
+ public Void visitModuleTarget(ModuleTarget_attribute attr, Void ignore) {
+ println("ModuleTarget:");
indent(+1);
print("os_name: #" + attr.os_name_index);
if (attr.os_name_index != 0) {
@@ -901,7 +955,7 @@ public class AttributeWriter extends BasicWriter
return null;
}
- private String getOSName(TargetPlatform_attribute attr) {
+ private String getOSName(ModuleTarget_attribute attr) {
try {
return constant_pool.getUTF8Value(attr.os_name_index);
} catch (ConstantPoolException e) {
@@ -909,7 +963,7 @@ public class AttributeWriter extends BasicWriter
}
}
- private String getOSArch(TargetPlatform_attribute attr) {
+ private String getOSArch(ModuleTarget_attribute attr) {
try {
return constant_pool.getUTF8Value(attr.os_arch_index);
} catch (ConstantPoolException e) {
@@ -917,7 +971,7 @@ public class AttributeWriter extends BasicWriter
}
}
- private String getOSVersion(TargetPlatform_attribute attr) {
+ private String getOSVersion(ModuleTarget_attribute attr) {
try {
return constant_pool.getUTF8Value(attr.os_version_index);
} catch (ConstantPoolException e) {
@@ -926,8 +980,8 @@ public class AttributeWriter extends BasicWriter
}
@Override
- public Void visitVersion(Version_attribute attr, Void ignore) {
- print("Version: #" + attr.version_index);
+ public Void visitModuleVersion(ModuleVersion_attribute attr, Void ignore) {
+ print("ModuleVersion: #" + attr.version_index);
indent(+1);
tab();
println("// " + getVersion(attr));
@@ -935,7 +989,7 @@ public class AttributeWriter extends BasicWriter
return null;
}
- private String getVersion(Version_attribute attr) {
+ private String getVersion(ModuleVersion_attribute attr) {
try {
return constant_pool.getUTF8Value(attr.version_index);
} catch (ConstantPoolException e) {
@@ -962,6 +1016,14 @@ public class AttributeWriter extends BasicWriter
return StringUtils.toUpperCase(s);
}
+ static String toHex(byte[] ba) {
+ StringBuilder sb = new StringBuilder(ba.length);
+ for (byte b: ba) {
+ sb.append(String.format("%02x", b & 0xff));
+ }
+ return sb.toString();
+ }
+
private final AnnotationWriter annotationWriter;
private final CodeWriter codeWriter;
private final ConstantWriter constantWriter;
diff --git a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/javap/ClassWriter.java b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/javap/ClassWriter.java
index 4cf1b22aa52..0cfea172c93 100644
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/javap/ClassWriter.java
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/javap/ClassWriter.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2016, 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
@@ -40,7 +40,7 @@ import com.sun.tools.classfile.ConstantPool;
import com.sun.tools.classfile.ConstantPoolException;
import com.sun.tools.classfile.ConstantValue_attribute;
import com.sun.tools.classfile.Descriptor;
-import com.sun.tools.classfile.DescriptorException;
+import com.sun.tools.classfile.Descriptor.InvalidDescriptor;
import com.sun.tools.classfile.Exceptions_attribute;
import com.sun.tools.classfile.Field;
import com.sun.tools.classfile.Method;
@@ -157,21 +157,36 @@ public class ClassWriter extends BasicWriter {
indent(-1);
}
- String name = getJavaName(classFile);
AccessFlags flags = cf.access_flags;
-
writeModifiers(flags.getClassModifiers());
- if (classFile.access_flags.is(AccessFlags.ACC_MODULE) && name.endsWith(".module-info")) {
- print("module ");
- print(name.replace(".module-info", ""));
+ if (classFile.access_flags.is(AccessFlags.ACC_MODULE)) {
+ Attribute attr = classFile.attributes.get(Attribute.Module);
+ if (attr instanceof Module_attribute) {
+ Module_attribute modAttr = (Module_attribute) attr;
+ String name;
+ try {
+ name = getJavaName(constant_pool.getUTF8Value(modAttr.module_name));
+ } catch (ConstantPoolException e) {
+ name = report(e);
+ }
+ if ((modAttr.module_flags & Module_attribute.ACC_OPEN) != 0) {
+ print("open ");
+ }
+ print("module ");
+ print(name);
+ } else {
+ // fallback for malformed class files
+ print("class ");
+ print(getJavaName(classFile));
+ }
} else {
if (classFile.isClass())
print("class ");
else if (classFile.isInterface())
print("interface ");
- print(name);
+ print(getJavaName(classFile));
}
Signature_attribute sigAttr = getSignature(cf.attributes);
@@ -210,7 +225,23 @@ public class ClassWriter extends BasicWriter {
indent(+1);
println("minor version: " + cf.minor_version);
println("major version: " + cf.major_version);
- writeList("flags: ", flags.getClassFlags(), "\n");
+ writeList(String.format("flags: (0x%04x) ", flags.flags), flags.getClassFlags(), "\n");
+ print("this_class: #" + cf.this_class);
+ if (cf.this_class != 0) {
+ tab();
+ print("// " + constantWriter.stringValue(cf.this_class));
+ }
+ println();
+ print("super_class: #" + cf.super_class);
+ if (cf.super_class != 0) {
+ tab();
+ print("// " + constantWriter.stringValue(cf.super_class));
+ }
+ println();
+ print("interfaces: " + cf.interfaces.length);
+ print(", fields: " + cf.fields.length);
+ print(", methods: " + cf.methods.length);
+ println(", attributes: " + cf.attributes.attrs.length);
indent(-1);
constantWriter.writeConstantPool();
} else {
@@ -249,17 +280,20 @@ public class ClassWriter extends BasicWriter {
return builder.toString();
}
+ @Override
public StringBuilder visitSimpleType(SimpleType type, StringBuilder sb) {
sb.append(getJavaName(type.name));
return sb;
}
+ @Override
public StringBuilder visitArrayType(ArrayType type, StringBuilder sb) {
append(sb, type.elemType);
sb.append("[]");
return sb;
}
+ @Override
public StringBuilder visitMethodType(MethodType type, StringBuilder sb) {
appendIfNotEmpty(sb, "<", type.typeParamTypes, "> ");
append(sb, type.returnType);
@@ -268,6 +302,7 @@ public class ClassWriter extends BasicWriter {
return sb;
}
+ @Override
public StringBuilder visitClassSigType(ClassSigType type, StringBuilder sb) {
appendIfNotEmpty(sb, "<", type.typeParamTypes, ">");
if (isInterface) {
@@ -283,6 +318,7 @@ public class ClassWriter extends BasicWriter {
return sb;
}
+ @Override
public StringBuilder visitClassType(ClassType type, StringBuilder sb) {
if (type.outerType != null) {
append(sb, type.outerType);
@@ -293,6 +329,7 @@ public class ClassWriter extends BasicWriter {
return sb;
}
+ @Override
public StringBuilder visitTypeParamType(TypeParamType type, StringBuilder sb) {
sb.append(type.name);
String sep = " extends ";
@@ -312,6 +349,7 @@ public class ClassWriter extends BasicWriter {
return sb;
}
+ @Override
public StringBuilder visitWildcardType(WildcardType type, StringBuilder sb) {
switch (type.kind) {
case UNBOUNDED:
@@ -402,7 +440,7 @@ public class ClassWriter extends BasicWriter {
println("descriptor: " + getValue(f.descriptor));
if (options.verbose)
- writeList("flags: ", flags.getFieldFlags(), "\n");
+ writeList(String.format("flags: (0x%04x) ", flags.flags), flags.getFieldFlags(), "\n");
if (options.showAllAttrs) {
for (Attribute attr: f.attributes)
@@ -459,16 +497,20 @@ public class ClassWriter extends BasicWriter {
if (methodType != null) {
print(new JavaTypePrinter(false).printTypeArgs(methodType.typeParamTypes));
}
- if (getName(m).equals("")) {
- print(getJavaName(classFile));
- print(getJavaParameterTypes(d, flags));
- } else if (getName(m).equals("")) {
- print("{}");
- } else {
- print(getJavaReturnType(d));
- print(" ");
- print(getName(m));
- print(getJavaParameterTypes(d, flags));
+ switch (getName(m)) {
+ case "":
+ print(getJavaName(classFile));
+ print(getJavaParameterTypes(d, flags));
+ break;
+ case "":
+ print("{}");
+ break;
+ default:
+ print(getJavaReturnType(d));
+ print(" ");
+ print(getName(m));
+ print(getJavaParameterTypes(d, flags));
+ break;
}
Attribute e_attr = m.attributes.get(Attribute.Exceptions);
@@ -499,7 +541,7 @@ public class ClassWriter extends BasicWriter {
}
if (options.verbose) {
- writeList("flags: ", flags.getMethodFlags(), "\n");
+ writeList(String.format("flags: (0x%04x) ", flags.flags), flags.getMethodFlags(), "\n");
}
Code_attribute code = null;
@@ -555,15 +597,18 @@ public class ClassWriter extends BasicWriter {
Module_attribute m = (Module_attribute) attr;
for (Module_attribute.RequiresEntry entry: m.requires) {
print("requires");
- if ((entry.requires_flags & Module_attribute.ACC_PUBLIC) != 0)
- print(" public");
+ if ((entry.requires_flags & Module_attribute.ACC_STATIC_PHASE) != 0)
+ print(" static");
+ if ((entry.requires_flags & Module_attribute.ACC_TRANSITIVE) != 0)
+ print(" transitive");
print(" ");
print(getUTF8Value(entry.requires_index).replace('/', '.'));
println(";");
}
for (Module_attribute.ExportsEntry entry: m.exports) {
- print("exports ");
+ print("exports");
+ print(" ");
print(getUTF8Value(entry.exports_index).replace('/', '.'));
boolean first = true;
for (int i: entry.exports_to_index) {
@@ -587,6 +632,32 @@ public class ClassWriter extends BasicWriter {
indent(-1);
}
+ for (Module_attribute.OpensEntry entry: m.opens) {
+ print("opens");
+ print(" ");
+ print(getUTF8Value(entry.opens_index).replace('/', '.'));
+ boolean first = true;
+ for (int i: entry.opens_to_index) {
+ String mname;
+ try {
+ mname = classFile.constant_pool.getUTF8Value(i).replace('/', '.');
+ } catch (ConstantPoolException e) {
+ mname = report(e);
+ }
+ if (first) {
+ println(" to");
+ indent(+1);
+ first = false;
+ } else {
+ println(",");
+ }
+ print(mname);
+ }
+ println(";");
+ if (!first)
+ indent(-1);
+ }
+
for (int entry: m.uses_index) {
print("uses ");
print(getClassName(entry).replace('/', '.'));
@@ -594,13 +665,22 @@ public class ClassWriter extends BasicWriter {
}
for (Module_attribute.ProvidesEntry entry: m.provides) {
- print("provides ");
+ print("provides ");
print(getClassName(entry.provides_index).replace('/', '.'));
- println(" with");
- indent(+1);
- print(getClassName(entry.with_index).replace('/', '.'));
+ boolean first = true;
+ for (int i: entry.with_index) {
+ if (first) {
+ println(" with");
+ indent(+1);
+ first = false;
+ } else {
+ println(",");
+ }
+ print(getClassName(i).replace('/', '.'));
+ }
println(";");
- indent(-1);
+ if (!first)
+ indent(-1);
}
}
@@ -679,7 +759,7 @@ public class ClassWriter extends BasicWriter {
return getJavaName(d.getFieldType(constant_pool));
} catch (ConstantPoolException e) {
return report(e);
- } catch (DescriptorException e) {
+ } catch (InvalidDescriptor e) {
return report(e);
}
}
@@ -689,7 +769,7 @@ public class ClassWriter extends BasicWriter {
return getJavaName(d.getReturnType(constant_pool));
} catch (ConstantPoolException e) {
return report(e);
- } catch (DescriptorException e) {
+ } catch (InvalidDescriptor e) {
return report(e);
}
}
@@ -699,7 +779,7 @@ public class ClassWriter extends BasicWriter {
return getJavaName(adjustVarargs(flags, d.getParameterTypes(constant_pool)));
} catch (ConstantPoolException e) {
return report(e);
- } catch (DescriptorException e) {
+ } catch (InvalidDescriptor e) {
return report(e);
}
}
@@ -766,12 +846,16 @@ public class ClassWriter extends BasicWriter {
ConstantPool.CONSTANT_Integer_info info =
(ConstantPool.CONSTANT_Integer_info) cpInfo;
String t = d.getValue(constant_pool);
- if (t.equals("C")) { // character
- return getConstantCharValue((char) info.value);
- } else if (t.equals("Z")) { // boolean
- return String.valueOf(info.value == 1);
- } else { // other: assume integer
- return String.valueOf(info.value);
+ switch (t) {
+ case "C":
+ // character
+ return getConstantCharValue((char) info.value);
+ case "Z":
+ // boolean
+ return String.valueOf(info.value == 1);
+ default:
+ // other: assume integer
+ return String.valueOf(info.value);
}
}
@@ -823,10 +907,10 @@ public class ClassWriter extends BasicWriter {
}
}
- private Options options;
- private AttributeWriter attrWriter;
- private CodeWriter codeWriter;
- private ConstantWriter constantWriter;
+ private final Options options;
+ private final AttributeWriter attrWriter;
+ private final CodeWriter codeWriter;
+ private final ConstantWriter constantWriter;
private ClassFile classFile;
private URI uri;
private long lastModified;
diff --git a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/TraverseProc.java b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/TraverseProc.java
index 0b65d9f8762..72e4e0637a7 100644
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/TraverseProc.java
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/TraverseProc.java
@@ -136,7 +136,7 @@ public class TraverseProc extends AbstractProcessor {
Set set = new HashSet<>();
for (ModuleElement m : mods) {
for (ModuleElement.Directive dir : m.getDirectives()) {
- if (dir.getKind() == ModuleElement.DirectiveKind.EXPORTS) {
+ if (dir.getKind() == ModuleElement.DirectiveKind.EXPORTS) { //XXX
ModuleElement.ExportsDirective exp = (ModuleElement.ExportsDirective)dir;
if (exp.getTargetModules() == null) {
set.add(exp.getPackage());
diff --git a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ClassFileReader.java b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ClassFileReader.java
index 9ad023c5df5..d1e07da066a 100644
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ClassFileReader.java
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ClassFileReader.java
@@ -25,6 +25,7 @@
package com.sun.tools.jdeps;
+import com.sun.tools.classfile.AccessFlags;
import com.sun.tools.classfile.ClassFile;
import com.sun.tools.classfile.ConstantPoolException;
import com.sun.tools.classfile.Dependencies.ClassFileError;
@@ -170,7 +171,9 @@ public class ClassFileReader implements Closeable {
protected Set scan() {
try {
ClassFile cf = ClassFile.read(path);
- return Collections.singleton(cf.getName());
+ String name = cf.access_flags.is(AccessFlags.ACC_MODULE)
+ ? "module-info" : cf.getName();
+ return Collections.singleton(name);
} catch (ConstantPoolException|IOException e) {
throw new ClassFileError(e);
}
diff --git a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/DependencyFinder.java b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/DependencyFinder.java
index fbcb9a0d955..71508e6e595 100644
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/DependencyFinder.java
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/DependencyFinder.java
@@ -37,6 +37,7 @@ import com.sun.tools.classfile.Dependency.Location;
import java.io.IOException;
import java.io.UncheckedIOException;
+import java.util.Collections;
import java.util.Deque;
import java.util.HashMap;
import java.util.HashSet;
@@ -175,6 +176,9 @@ class DependencyFinder {
public Set call() throws Exception {
Set targets = new HashSet<>();
for (ClassFile cf : archive.reader().getClassFiles()) {
+ if (cf.access_flags.is(AccessFlags.ACC_MODULE))
+ continue;
+
String classFileName;
try {
classFileName = cf.getName();
@@ -216,9 +220,13 @@ class DependencyFinder {
{
ClassFile cf = archive.reader().getClassFile(name);
if (cf == null) {
- throw new IllegalArgumentException(archive.getName() + " does not contain " + name);
+ throw new IllegalArgumentException(archive.getName() +
+ " does not contain " + name);
}
+ if (cf.access_flags.is(AccessFlags.ACC_MODULE))
+ return Collections.emptySet();
+
Set targets = new HashSet<>();
String cn;
try {
diff --git a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/DepsAnalyzer.java b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/DepsAnalyzer.java
index 1941c14bfc9..c33ac26b2fe 100644
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/DepsAnalyzer.java
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/DepsAnalyzer.java
@@ -29,11 +29,9 @@ import com.sun.tools.classfile.Dependency.Location;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Deque;
-import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
-import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.ConcurrentLinkedDeque;
@@ -263,7 +261,7 @@ public class DepsAnalyzer {
public static enum Info {
REQUIRES,
- REQUIRES_PUBLIC,
+ REQUIRES_TRANSITIVE,
EXPORTED_API,
MODULE_PRIVATE,
QUALIFIED_EXPORTED_API,
@@ -288,7 +286,7 @@ public class DepsAnalyzer {
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
- if (info != Info.REQUIRES && info != Info.REQUIRES_PUBLIC)
+ if (info != Info.REQUIRES && info != Info.REQUIRES_TRANSITIVE)
sb.append(source).append("/");
sb.append(name);
@@ -325,7 +323,7 @@ public class DepsAnalyzer {
* Returns a graph of module dependences.
*
* Each Node represents a module and each edge is a dependence.
- * No analysis on "requires public".
+ * No analysis on "requires transitive".
*/
public Graph moduleGraph() {
Graph.Builder builder = new Graph.Builder<>();
diff --git a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/Graph.java b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/Graph.java
index 5e9450c5eb5..85aa1c6ff7a 100644
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/Graph.java
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/Graph.java
@@ -388,10 +388,10 @@ public final class Graph {
}
static void printEdges(PrintWriter out, Graph graph,
- String node, Set requiresPublic) {
+ String node, Set requiresTransitive) {
graph.adjacentNodes(node).forEach(dn -> {
String attr = dn.equals("java.base") ? REQUIRES_BASE
- : (requiresPublic.contains(dn) ? REEXPORTS : REQUIRES);
+ : (requiresTransitive.contains(dn) ? REEXPORTS : REQUIRES);
out.format(" \"%s\" -> \"%s\" [%s];%n", node, dn, attr);
});
}
diff --git a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsConfiguration.java b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsConfiguration.java
index 44159653d95..1f887bb0e9f 100644
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsConfiguration.java
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsConfiguration.java
@@ -38,6 +38,8 @@ import java.io.InputStream;
import java.io.UncheckedIOException;
import java.lang.module.Configuration;
import java.lang.module.ModuleDescriptor;
+import java.lang.module.ModuleDescriptor.Exports;
+import java.lang.module.ModuleDescriptor.Opens;
import java.lang.module.ModuleFinder;
import java.lang.module.ModuleReader;
import java.lang.module.ModuleReference;
@@ -408,7 +410,7 @@ public class JdepsConfiguration implements AutoCloseable {
}
@Override
- public void close() throws IOException {
+ public void close() {
}
};
}
@@ -421,12 +423,18 @@ public class JdepsConfiguration implements AutoCloseable {
}
private ModuleDescriptor dropHashes(ModuleDescriptor md) {
- ModuleDescriptor.Builder builder = new ModuleDescriptor.Builder(md.name());
+ ModuleDescriptor.Builder builder = ModuleDescriptor.module(md.name());
md.requires().forEach(builder::requires);
md.exports().forEach(builder::exports);
- md.provides().values().stream().forEach(builder::provides);
+ md.opens().forEach(builder::opens);
+ md.provides().stream().forEach(builder::provides);
md.uses().stream().forEach(builder::uses);
- builder.conceals(md.conceals());
+
+ Set concealed = new HashSet<>(md.packages());
+ md.exports().stream().map(Exports::source).forEach(concealed::remove);
+ md.opens().stream().map(Opens::source).forEach(concealed::remove);
+ concealed.forEach(builder::contains);
+
return builder.build();
}
diff --git a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsTask.java b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsTask.java
index 3ed77929c9c..6e2dfa44b08 100644
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsTask.java
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsTask.java
@@ -154,6 +154,7 @@ class JdepsTask {
ANALYZE_DEPS(""),
GENERATE_DOT_FILE("-dotoutput", "--dot-output"),
GENERATE_MODULE_INFO("--generate-module-info"),
+ GENERATE_OPEN_MODULE("--generate-open-module"),
LIST_DEPS("--list-deps"),
LIST_REDUCED_DEPS("--list-reduced-deps"),
CHECK_MODULES("--check");
@@ -248,7 +249,15 @@ class JdepsTask {
if (task.command != null) {
throw new BadArgs("err.command.set", task.command, opt);
}
- task.command = task.genModuleInfo(Paths.get(arg));
+ task.command = task.genModuleInfo(Paths.get(arg), false);
+ }
+ },
+ new Option(true, CommandOption.GENERATE_OPEN_MODULE) {
+ void process(JdepsTask task, String opt, String arg) throws BadArgs {
+ if (task.command != null) {
+ throw new BadArgs("err.command.set", task.command, opt);
+ }
+ task.command = task.genModuleInfo(Paths.get(arg), true);
}
},
new Option(false, CommandOption.LIST_DEPS) {
@@ -596,11 +605,11 @@ class JdepsTask {
return new GenDotFile(dir);
}
- private GenModuleInfo genModuleInfo(Path dir) throws BadArgs {
+ private GenModuleInfo genModuleInfo(Path dir, boolean openModule) throws BadArgs {
if (Files.exists(dir) && (!Files.isDirectory(dir) || !Files.isWritable(dir))) {
throw new BadArgs("err.invalid.path", dir.toString());
}
- return new GenModuleInfo(dir);
+ return new GenModuleInfo(dir, openModule);
}
private ListModuleDeps listModuleDeps(boolean reduced) throws BadArgs {
@@ -823,9 +832,11 @@ class JdepsTask {
class GenModuleInfo extends Command {
final Path dir;
- GenModuleInfo(Path dir) {
+ final boolean openModule;
+ GenModuleInfo(Path dir, boolean openModule) {
super(CommandOption.GENERATE_MODULE_INFO);
this.dir = dir;
+ this.openModule = openModule;
}
@Override
@@ -866,7 +877,7 @@ class JdepsTask {
}
ModuleInfoBuilder builder
- = new ModuleInfoBuilder(config, inputArgs, dir);
+ = new ModuleInfoBuilder(config, inputArgs, dir, openModule);
boolean ok = builder.run();
if (!ok && !options.nowarning) {
diff --git a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/Module.java b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/Module.java
index f00394a05a3..e49a7f7d47e 100644
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/Module.java
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/Module.java
@@ -26,6 +26,8 @@
package com.sun.tools.jdeps;
import java.lang.module.ModuleDescriptor;
+import java.lang.module.ModuleDescriptor.Exports;
+import java.lang.module.ModuleDescriptor.Opens;
import java.net.URI;
import java.util.Collections;
import java.util.HashMap;
@@ -240,18 +242,24 @@ class Module extends Archive {
private StrictModule(Module m, Map requires) {
super(m.name(), m.location, m.descriptor, m.exports, m.isSystem, m.reader());
- ModuleDescriptor.Builder builder = new ModuleDescriptor.Builder(m.name());
+ ModuleDescriptor.Builder builder = ModuleDescriptor.module(m.name());
requires.keySet().forEach(mn -> {
if (requires.get(mn).equals(Boolean.TRUE)) {
- builder.requires(ModuleDescriptor.Requires.Modifier.PUBLIC, mn);
+ builder.requires(Set.of(ModuleDescriptor.Requires.Modifier.TRANSITIVE), mn);
} else {
builder.requires(mn);
}
});
m.descriptor.exports().forEach(e -> builder.exports(e));
+ m.descriptor.opens().forEach(o -> builder.opens(o));
m.descriptor.uses().forEach(s -> builder.uses(s));
- m.descriptor.provides().values().forEach(p -> builder.provides(p));
- builder.conceals(m.descriptor.conceals());
+ m.descriptor.provides().forEach(p -> builder.provides(p));
+
+ Set concealed = new HashSet<>(m.descriptor.packages());
+ m.descriptor.exports().stream().map(Exports::source).forEach(concealed::remove);
+ m.descriptor.opens().stream().map(Opens::source).forEach(concealed::remove);
+ concealed.forEach(builder::contains);
+
this.md = builder.build();
}
diff --git a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ModuleAnalyzer.java b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ModuleAnalyzer.java
index 9c0d65cfc1a..6da162878cd 100644
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ModuleAnalyzer.java
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ModuleAnalyzer.java
@@ -87,8 +87,8 @@ public class ModuleAnalyzer {
public boolean run() throws IOException {
try {
- // compute "requires public" dependences
- modules.values().forEach(ModuleDeps::computeRequiresPublic);
+ // compute "requires transitive" dependences
+ modules.values().forEach(ModuleDeps::computeRequiresTransitive);
modules.values().forEach(md -> {
// compute "requires" dependences
@@ -104,7 +104,7 @@ public class ModuleAnalyzer {
class ModuleDeps {
final Module root;
- Set requiresPublic;
+ Set requiresTransitive;
Set requires;
Map> unusedQualifiedExports;
@@ -113,15 +113,15 @@ public class ModuleAnalyzer {
}
/**
- * Compute 'requires public' dependences by analyzing API dependencies
+ * Compute 'requires transitive' dependences by analyzing API dependencies
*/
- private void computeRequiresPublic() {
- // record requires public
- this.requiresPublic = computeRequires(true)
+ private void computeRequiresTransitive() {
+ // record requires transitive
+ this.requiresTransitive = computeRequires(true)
.filter(m -> !m.name().equals(JAVA_BASE))
.collect(toSet());
- trace("requires public: %s%n", requiresPublic);
+ trace("requires transitive: %s%n", requiresTransitive);
}
private void computeRequires() {
@@ -144,24 +144,24 @@ public class ModuleAnalyzer {
}
ModuleDescriptor descriptor() {
- return descriptor(requiresPublic, requires);
+ return descriptor(requiresTransitive, requires);
}
- private ModuleDescriptor descriptor(Set requiresPublic,
+ private ModuleDescriptor descriptor(Set requiresTransitive,
Set requires) {
- ModuleDescriptor.Builder builder = new ModuleDescriptor.Builder(root.name());
+ ModuleDescriptor.Builder builder = ModuleDescriptor.module(root.name());
if (!root.name().equals(JAVA_BASE))
- builder.requires(MANDATED, JAVA_BASE);
+ builder.requires(Set.of(MANDATED), JAVA_BASE);
- requiresPublic.stream()
+ requiresTransitive.stream()
.filter(m -> !m.name().equals(JAVA_BASE))
.map(Module::name)
- .forEach(mn -> builder.requires(PUBLIC, mn));
+ .forEach(mn -> builder.requires(Set.of(TRANSITIVE), mn));
requires.stream()
- .filter(m -> !requiresPublic.contains(m))
+ .filter(m -> !requiresTransitive.contains(m))
.filter(m -> !m.name().equals(JAVA_BASE))
.map(Module::name)
.forEach(mn -> builder.requires(mn));
@@ -172,10 +172,10 @@ public class ModuleAnalyzer {
private Graph buildReducedGraph() {
ModuleGraphBuilder rpBuilder = new ModuleGraphBuilder(configuration);
rpBuilder.addModule(root);
- requiresPublic.stream()
+ requiresTransitive.stream()
.forEach(m -> rpBuilder.addEdge(root, m));
- // requires public graph
+ // requires transitive graph
Graph rbg = rpBuilder.build().reduce();
ModuleGraphBuilder gb = new ModuleGraphBuilder(configuration);
@@ -198,7 +198,7 @@ public class ModuleAnalyzer {
*/
ModuleDescriptor reduced() {
Graph g = buildReducedGraph();
- return descriptor(requiresPublic, g.adjacentNodes(root));
+ return descriptor(requiresTransitive, g.adjacentNodes(root));
}
/**
@@ -309,16 +309,16 @@ public class ModuleAnalyzer {
}
private boolean matches(ModuleDescriptor md, ModuleDescriptor other) {
- // build requires public from ModuleDescriptor
- Set reqPublic = md.requires().stream()
- .filter(req -> req.modifiers().contains(PUBLIC))
+ // build requires transitive from ModuleDescriptor
+ Set reqTransitive = md.requires().stream()
+ .filter(req -> req.modifiers().contains(TRANSITIVE))
.collect(toSet());
- Set otherReqPublic = other.requires().stream()
- .filter(req -> req.modifiers().contains(PUBLIC))
+ Set otherReqTransitive = other.requires().stream()
+ .filter(req -> req.modifiers().contains(TRANSITIVE))
.collect(toSet());
- if (!reqPublic.equals(otherReqPublic)) {
- trace("mismatch requires public: %s%n", reqPublic);
+ if (!reqTransitive.equals(otherReqTransitive)) {
+ trace("mismatch requires transitive: %s%n", reqTransitive);
return false;
}
@@ -365,12 +365,12 @@ public class ModuleAnalyzer {
.sorted(Comparator.comparing(ModuleDescriptor::name))
.forEach(md -> {
String mn = md.name();
- Set requiresPublic = md.requires().stream()
- .filter(d -> d.modifiers().contains(PUBLIC))
+ Set requiresTransitive = md.requires().stream()
+ .filter(d -> d.modifiers().contains(TRANSITIVE))
.map(d -> d.name())
.collect(toSet());
- DotGraph.printEdges(out, graph, mn, requiresPublic);
+ DotGraph.printEdges(out, graph, mn, requiresTransitive);
});
out.println("}");
@@ -380,20 +380,20 @@ public class ModuleAnalyzer {
/**
* Returns a Graph of the given Configuration after transitive reduction.
*
- * Transitive reduction of requires public edge and requires edge have
- * to be applied separately to prevent the requires public edges
+ * Transitive reduction of requires transitive edge and requires edge have
+ * to be applied separately to prevent the requires transitive edges
* (e.g. U -> V) from being reduced by a path (U -> X -> Y -> V)
* in which V would not be re-exported from U.
*/
private Graph gengraph(Set modules) {
- // build a Graph containing only requires public edges
+ // build a Graph containing only requires transitive edges
// with transitive reduction.
Graph.Builder rpgbuilder = new Graph.Builder<>();
for (Module module : modules) {
ModuleDescriptor md = module.descriptor();
String mn = md.name();
md.requires().stream()
- .filter(d -> d.modifiers().contains(PUBLIC))
+ .filter(d -> d.modifiers().contains(TRANSITIVE))
.map(d -> d.name())
.forEach(d -> rpgbuilder.addEdge(mn, d));
}
diff --git a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ModuleExportsAnalyzer.java b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ModuleExportsAnalyzer.java
index 8d7b82094a1..056b53f2436 100644
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ModuleExportsAnalyzer.java
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ModuleExportsAnalyzer.java
@@ -178,7 +178,7 @@ public class ModuleExportsAnalyzer extends DepsAnalyzer {
RootModule(String name) {
super(name);
- ModuleDescriptor.Builder builder = new ModuleDescriptor.Builder(name);
+ ModuleDescriptor.Builder builder = ModuleDescriptor.module(name);
this.descriptor = builder.build();
}
diff --git a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ModuleGraphBuilder.java b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ModuleGraphBuilder.java
index 4352963049b..812f9be0d68 100644
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ModuleGraphBuilder.java
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ModuleGraphBuilder.java
@@ -98,7 +98,7 @@ public class ModuleGraphBuilder extends Graph.Builder {
});
});
- // read requires public from ModuleDescriptor
+ // read requires transitive from ModuleDescriptor
Module source;
while ((source = deque.poll()) != null) {
if (visited.contains(source))
@@ -107,7 +107,7 @@ public class ModuleGraphBuilder extends Graph.Builder {
visited.add(source);
builder.addNode(source);
Module from = source;
- requiresPublic(from).forEach(m -> {
+ requiresTransitive(from).forEach(m -> {
deque.add(m);
builder.addEdge(from, m);
});
@@ -116,13 +116,13 @@ public class ModuleGraphBuilder extends Graph.Builder {
}
/*
- * Returns a stream of modules upon which the given module `requires public`
+ * Returns a stream of modules upon which the given module `requires transitive`
*/
- public Stream requiresPublic(Module m) {
- // find requires public
+ public Stream requiresTransitive(Module m) {
+ // find requires transitive
return m.descriptor()
.requires().stream()
- .filter(req -> req.modifiers().contains(PUBLIC))
+ .filter(req -> req.modifiers().contains(TRANSITIVE))
.map(ModuleDescriptor.Requires::name)
.map(config::findModule)
.flatMap(Optional::stream);
diff --git a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ModuleInfoBuilder.java b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ModuleInfoBuilder.java
index ab493a61977..06a31cd6f45 100644
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ModuleInfoBuilder.java
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ModuleInfoBuilder.java
@@ -47,13 +47,14 @@ import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.function.Function;
-import java.util.stream.Collectors;
import java.util.stream.Stream;
+import static java.util.stream.Collectors.*;
public class ModuleInfoBuilder {
final JdepsConfiguration configuration;
final Path outputdir;
+ final boolean open;
final DependencyFinder dependencyFinder;
final Analyzer analyzer;
@@ -63,9 +64,11 @@ public class ModuleInfoBuilder {
final Map automaticToExplicitModule;
public ModuleInfoBuilder(JdepsConfiguration configuration,
List args,
- Path outputdir) {
+ Path outputdir,
+ boolean open) {
this.configuration = configuration;
this.outputdir = outputdir;
+ this.open = open;
this.dependencyFinder = new DependencyFinder(configuration, DEFAULT_FILTER);
this.analyzer = new Analyzer(configuration, Type.CLASS, DEFAULT_FILTER);
@@ -73,13 +76,13 @@ public class ModuleInfoBuilder {
// add targets to modulepath if it has module-info.class
List paths = args.stream()
.map(fn -> Paths.get(fn))
- .collect(Collectors.toList());
+ .collect(toList());
// automatic module to convert to explicit module
this.automaticToExplicitModule = ModuleFinder.of(paths.toArray(new Path[0]))
.findAll().stream()
.map(configuration::toModule)
- .collect(Collectors.toMap(Function.identity(), Function.identity()));
+ .collect(toMap(Function.identity(), Function.identity()));
Optional om = automaticToExplicitModule.keySet().stream()
.filter(m -> !m.descriptor().isAutomatic())
@@ -96,7 +99,7 @@ public class ModuleInfoBuilder {
public boolean run() throws IOException {
try {
// pass 1: find API dependencies
- Map> requiresPublic = computeRequiresPublic();
+ Map> requiresTransitive = computeRequiresTransitive();
// pass 2: analyze all class dependences
dependencyFinder.parse(automaticModules().stream());
@@ -105,13 +108,13 @@ public class ModuleInfoBuilder {
boolean missingDeps = false;
for (Module m : automaticModules()) {
- Set apiDeps = requiresPublic.containsKey(m)
- ? requiresPublic.get(m)
+ Set apiDeps = requiresTransitive.containsKey(m)
+ ? requiresTransitive.get(m)
: Collections.emptySet();
Path file = outputdir.resolve(m.name()).resolve("module-info.java");
- // computes requires and requires public
+ // computes requires and requires transitive
Module explicitModule = toExplicitModule(m, apiDeps);
if (explicitModule != null) {
automaticToExplicitModule.put(m, explicitModule);
@@ -136,7 +139,7 @@ public class ModuleInfoBuilder {
return m == NOT_FOUND || m == REMOVED_JDK_INTERNALS;
}
- private Module toExplicitModule(Module module, Set requiresPublic)
+ private Module toExplicitModule(Module module, Set