--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/java.compiler/share/classes/javax/annotation/processing/Generated.java Thu Mar 30 17:24:01 2017 +0000
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package javax.annotation.processing;
+
+import java.lang.annotation.*;
+import static java.lang.annotation.ElementType.*;
+import static java.lang.annotation.RetentionPolicy.*;
+
+/**
+ * The Generated annotation is used to mark source code that has been generated.
+ * It can also be used to differentiate user written code from generated code in
+ * a single file.
+ *
+ * <h3>Examples:</h3>
+ * <pre>
+ * @Generated("com.example.Generator")
+ * </pre>
+ * <pre>
+ * @Generated(value="com.example.Generator", date= "2017-07-04T12:08:56.235-0700")
+ * </pre>
+ * <pre>
+ * @Generated(value="com.example.Generator", date= "2017-07-04T12:08:56.235-0700",
+ * comments= "comment 1")
+ * </pre>
+ *
+ * @since 9
+ */
+@Documented
+@Retention(SOURCE)
+@Target({PACKAGE, TYPE, METHOD, CONSTRUCTOR, FIELD,
+ LOCAL_VARIABLE, PARAMETER})
+public @interface Generated {
+
+ /**
+ * The value element MUST have the name of the code generator. The
+ * name is the fully qualified name of the code generator.
+ *
+ * @return The name of the code generator
+ */
+ String[] value();
+
+ /**
+ * Date when the source was generated. The date element must follow the ISO
+ * 8601 standard. For example the date element would have the following
+ * value 2017-07-04T12:08:56.235-0700 which represents 2017-07-04 12:08:56
+ * local time in the U.S. Pacific Time time zone.
+ *
+ * @return The date the source was generated
+ */
+ String date() default "";
+
+ /**
+ * A place holder for any comments that the code generator may want to
+ * include in the generated code.
+ *
+ * @return Comments that the code generated included
+ */
+ String comments() default "";
+}
--- a/langtools/src/java.compiler/share/classes/module-info.java Wed Mar 29 23:33:07 2017 +0000
+++ b/langtools/src/java.compiler/share/classes/module-info.java Thu Mar 30 17:24:01 2017 +0000
@@ -30,6 +30,7 @@
* and define interfaces for tools such as compilers which can be invoked
* from a program.
*
+ * @moduleGraph
* @since 9
*/
module java.compiler {
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java Wed Mar 29 23:33:07 2017 +0000
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java Thu Mar 30 17:24:01 2017 +0000
@@ -334,7 +334,10 @@
currModule.complete();
PackageSymbol p = c.packge();
isAccessible =
- (currModule == p.modle) || currModule.visiblePackages.get(p.fullname) == p || p == syms.rootPackage;
+ currModule == p.modle ||
+ currModule.visiblePackages.get(p.fullname) == p ||
+ p == syms.rootPackage ||
+ (p.modle == syms.unnamedModule && currModule.readModules.contains(p.modle));
} else {
isAccessible = true;
}
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Arguments.java Wed Mar 29 23:33:07 2017 +0000
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Arguments.java Thu Mar 30 17:24:01 2017 +0000
@@ -39,6 +39,7 @@
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;
+import java.util.function.Predicate;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Stream;
@@ -283,23 +284,14 @@
}
/**
- * Processes strings containing options and operands.
- * @param args the strings to be processed
- * @param allowableOpts the set of option declarations that are applicable
- * @param helper a help for use by Option.process
- * @param allowOperands whether or not to check for files and classes
- * @param checkFileManager whether or not to check if the file manager can handle
- * options which are not recognized by any of allowableOpts
- * @return true if all the strings were successfully processed; false otherwise
- * @throws IllegalArgumentException if a problem occurs and errorMode is set to
- * ILLEGAL_ARGUMENT
+ * Handles the {@code --release} option.
+ *
+ * @param additionalOptions a predicate to handle additional options implied by the
+ * {@code --release} option. The predicate should return true if all the additional
+ * options were processed successfully.
+ * @return true if successful, false otherwise
*/
- private boolean processArgs(Iterable<String> args,
- Set<Option> allowableOpts, OptionHelper helper,
- boolean allowOperands, boolean checkFileManager) {
- if (!doProcessArgs(args, allowableOpts, helper, allowOperands, checkFileManager))
- return false;
-
+ public boolean handleReleaseOptions(Predicate<Iterable<String>> additionalOptions) {
String platformString = options.get(Option.RELEASE);
checkOptionAllowed(platformString == null,
@@ -323,7 +315,7 @@
context.put(PlatformDescription.class, platformDescription);
- if (!doProcessArgs(platformDescription.getAdditionalOptions(), allowableOpts, helper, allowOperands, checkFileManager))
+ if (!additionalOptions.test(platformDescription.getAdditionalOptions()))
return false;
Collection<Path> platformCP = platformDescription.getPlatformPath();
@@ -348,6 +340,30 @@
}
}
+ return true;
+ }
+
+ /**
+ * Processes strings containing options and operands.
+ * @param args the strings to be processed
+ * @param allowableOpts the set of option declarations that are applicable
+ * @param helper a help for use by Option.process
+ * @param allowOperands whether or not to check for files and classes
+ * @param checkFileManager whether or not to check if the file manager can handle
+ * options which are not recognized by any of allowableOpts
+ * @return true if all the strings were successfully processed; false otherwise
+ * @throws IllegalArgumentException if a problem occurs and errorMode is set to
+ * ILLEGAL_ARGUMENT
+ */
+ private boolean processArgs(Iterable<String> args,
+ Set<Option> allowableOpts, OptionHelper helper,
+ boolean allowOperands, boolean checkFileManager) {
+ if (!doProcessArgs(args, allowableOpts, helper, allowOperands, checkFileManager))
+ return false;
+
+ if (!handleReleaseOptions(extra -> doProcessArgs(extra, allowableOpts, helper, allowOperands, checkFileManager)))
+ return false;
+
options.notifyListeners();
return true;
--- a/langtools/src/jdk.compiler/share/classes/module-info.java Wed Mar 29 23:33:07 2017 +0000
+++ b/langtools/src/jdk.compiler/share/classes/module-info.java Thu Mar 30 17:24:01 2017 +0000
@@ -27,6 +27,7 @@
* {@link javax.tools.ToolProvider#getSystemJavaCompiler system Java compiler}
* and its command line equivalent, <em>javac</em>, as well as <em>javah</em>.
*
+ * @moduleGraph
* @since 9
*/
module jdk.compiler {
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/stylesheet.css Wed Mar 29 23:33:07 2017 +0000
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/stylesheet.css Thu Mar 30 17:24:01 2017 +0000
@@ -787,3 +787,15 @@
font-style:italic;
font-size:12px;
}
+
+.moduleGraph span {
+ display:none;
+ position:absolute;
+}
+.moduleGraph:hover span {
+ display:block;
+ margin: -100px 0 0 100px;
+ z-index: 1;
+}
+
+
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/Start.java Wed Mar 29 23:33:07 2017 +0000
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/Start.java Thu Mar 30 17:24:01 2017 +0000
@@ -513,12 +513,22 @@
} catch (com.sun.tools.javac.main.Option.InvalidValueException ignore) {
}
+ Arguments arguments = Arguments.instance(context);
+ arguments.init(ProgramName);
+ arguments.allowEmpty();
+
doclet.init(locale, messager);
parseArgs(argList, javaNames);
- Arguments arguments = Arguments.instance(context);
- arguments.init(ProgramName);
- arguments.allowEmpty();
+ if (!arguments.handleReleaseOptions(extra -> true)) {
+ // Arguments does not always increase the error count in the
+ // case of errors, so increment the error count only if it has
+ // not been updated previously, preventing complaints by callers
+ if (!messager.hasErrors() && !messager.hasWarnings())
+ messager.nerrors++;
+ return CMDERR;
+ }
+
if (!arguments.validate()) {
// Arguments does not always increase the error count in the
// case of errors, so increment the error count only if it has
@@ -532,49 +542,6 @@
((BaseFileManager) fileManager).handleOptions(fileManagerOpts);
}
- String platformString = compOpts.get("--release");
-
- if (platformString != null) {
- if (compOpts.isSet("-source")) {
- String text = messager.getText("main.release.bootclasspath.conflict", "-source");
- throw new ToolException(CMDERR, text);
- }
- if (fileManagerOpts.containsKey(BOOT_CLASS_PATH)) {
- String text = messager.getText("main.release.bootclasspath.conflict",
- BOOT_CLASS_PATH.getPrimaryName());
- throw new ToolException(CMDERR, text);
- }
-
- PlatformDescription platformDescription =
- PlatformUtils.lookupPlatformDescription(platformString);
-
- if (platformDescription == null) {
- String text = messager.getText("main.unsupported.release.version", platformString);
- throw new IllegalArgumentException(text);
- }
-
- compOpts.put(SOURCE, platformDescription.getSourceVersion());
-
- context.put(PlatformDescription.class, platformDescription);
-
- Collection<Path> platformCP = platformDescription.getPlatformPath();
-
- if (platformCP != null) {
- if (fileManager instanceof StandardJavaFileManager) {
- StandardJavaFileManager sfm = (StandardJavaFileManager) fileManager;
- try {
- sfm.setLocationFromPaths(StandardLocation.PLATFORM_CLASS_PATH, platformCP);
- } catch (IOException ioe) {
- throw new ToolException(SYSERR, ioe.getMessage(), ioe);
- }
- } else {
- String text = messager.getText("main.release.not.standard.file.manager",
- platformString);
- throw new ToolException(ABNORMAL, text);
- }
- }
- }
-
compOpts.notifyListeners();
List<String> modules = (List<String>) jdtoolOpts.computeIfAbsent(ToolOption.MODULE,
s -> Collections.EMPTY_LIST);
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/resources/javadoc.properties Wed Mar 29 23:33:07 2017 +0000
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/resources/javadoc.properties Thu Mar 30 17:24:01 2017 +0000
@@ -284,9 +284,6 @@
main.illegal_class_name=Illegal class name: "{0}"
main.illegal_package_name=Illegal package name: "{0}"
main.illegal_option_value=Illegal option value: "{0}"
-main.release.bootclasspath.conflict=option {0} cannot be used together with -release
-main.unsupported.release.version=release version {0} not supported
-main.release.not.standard.file.manager=-release option specified, but the provided JavaFileManager is not a StandardJavaFileManager.
main.file.manager.list=FileManager error listing files: "{0}"
main.assertion.error=assertion failed: "{0}}"
main.unknown.error=an unknown error has occurred
--- a/langtools/src/jdk.javadoc/share/classes/module-info.java Wed Mar 29 23:33:07 2017 +0000
+++ b/langtools/src/jdk.javadoc/share/classes/module-info.java Thu Mar 30 17:24:01 2017 +0000
@@ -27,6 +27,7 @@
* {@link javax.tools.ToolProvider#getSystemDocumentationTool system documentation tool}
* and its command line equivalent, <em>javadoc</em>.
*
+ * @moduleGraph
* @since 9
*/
module jdk.javadoc {
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ModuleDotGraph.java Wed Mar 29 23:33:07 2017 +0000
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ModuleDotGraph.java Thu Mar 30 17:24:01 2017 +0000
@@ -32,6 +32,7 @@
import java.io.PrintWriter;
import java.lang.module.Configuration;
import java.lang.module.ModuleDescriptor;
+import java.lang.module.ModuleDescriptor.*;
import java.lang.module.ModuleFinder;
import java.lang.module.ModuleReference;
import java.lang.module.ResolvedModule;
@@ -39,8 +40,8 @@
import java.nio.file.Path;
import java.util.ArrayDeque;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.Deque;
-import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
@@ -76,10 +77,16 @@
* @param dir output directory
*/
public boolean genDotFiles(Path dir) throws IOException {
+ return genDotFiles(dir, DotGraphAttributes.DEFAULT);
+ }
+
+ public boolean genDotFiles(Path dir, Attributes attributes)
+ throws IOException
+ {
Files.createDirectories(dir);
for (String mn : configurations.keySet()) {
Path path = dir.resolve(mn + ".dot");
- genDotFile(path, mn, configurations.get(mn));
+ genDotFile(path, mn, configurations.get(mn), attributes);
}
return true;
}
@@ -87,7 +94,9 @@
/**
* Generate dotfile of the given path
*/
- public void genDotFile(Path path, String name, Configuration configuration)
+ public void genDotFile(Path path, String name,
+ Configuration configuration,
+ Attributes attributes)
throws IOException
{
// transitive reduction
@@ -95,12 +104,12 @@
? requiresTransitiveGraph(configuration, Set.of(name))
: gengraph(configuration);
- DotGraphBuilder builder = new DotGraphBuilder(name, graph);
- builder.subgraph("se", "java", DotGraphBuilder.ORANGE,
+ DotGraphBuilder builder = new DotGraphBuilder(name, graph, attributes);
+ builder.subgraph("se", "java", attributes.javaSubgraphColor(),
DotGraphBuilder.JAVA_SE_SUBGRAPH)
- .subgraph("jdk", "jdk", DotGraphBuilder.BLUE,
+ .subgraph("jdk", "jdk", attributes.jdkSubgraphColor(),
DotGraphBuilder.JDK_SUBGRAPH)
- .descriptors(graph.nodes().stream()
+ .modules(graph.nodes().stream()
.map(mn -> configuration.findModule(mn).get()
.reference().descriptor()));
// build dot file
@@ -118,12 +127,12 @@
private Graph<String> gengraph(Configuration cf) {
Graph.Builder<String> builder = new Graph.Builder<>();
cf.modules().stream()
- .forEach(resolvedModule -> {
- String mn = resolvedModule.reference().descriptor().name();
+ .forEach(rm -> {
+ String mn = rm.name();
builder.addNode(mn);
- resolvedModule.reads().stream()
- .map(ResolvedModule::name)
- .forEach(target -> builder.addEdge(mn, target));
+ rm.reads().stream()
+ .map(ResolvedModule::name)
+ .forEach(target -> builder.addEdge(mn, target));
});
Graph<String> rpg = requiresTransitiveGraph(cf, builder.nodes);
@@ -149,22 +158,103 @@
visited.add(mn);
builder.addNode(mn);
- ModuleDescriptor descriptor = cf.findModule(mn).get()
- .reference().descriptor();
- descriptor.requires().stream()
- .filter(d -> d.modifiers().contains(TRANSITIVE)
+ cf.findModule(mn).get()
+ .reference().descriptor().requires().stream()
+ .filter(d -> d.modifiers().contains(TRANSITIVE)
|| d.name().equals("java.base"))
- .map(d -> d.name())
- .forEach(d -> {
- deque.add(d);
- builder.addEdge(mn, d);
- });
+ .map(Requires::name)
+ .forEach(d -> {
+ deque.add(d);
+ builder.addEdge(mn, d);
+ });
}
return builder.build().reduce();
}
- public static class DotGraphBuilder {
+ public interface Attributes {
+ static final String ORANGE = "#e76f00";
+ static final String BLUE = "#437291";
+ static final String BLACK = "#000000";
+ static final String DARK_GRAY = "#999999";
+ static final String LIGHT_GRAY = "#dddddd";
+
+ int fontSize();
+ String fontName();
+ String fontColor();
+
+ int arrowSize();
+ int arrowWidth();
+ String arrowColor();
+
+ default double rankSep() {
+ return 1;
+ }
+
+ default List<Set<String>> ranks() {
+ return Collections.emptyList();
+ }
+
+ default int weightOf(String s, String t) {
+ return 1;
+ }
+
+ default String requiresMandatedColor() {
+ return LIGHT_GRAY;
+ }
+
+ default String javaSubgraphColor() {
+ return ORANGE;
+ }
+
+ default String jdkSubgraphColor() {
+ return BLUE;
+ }
+ }
+
+ static class DotGraphAttributes implements Attributes {
+ static final DotGraphAttributes DEFAULT = new DotGraphAttributes();
+
+ static final String FONT_NAME = "DejaVuSans";
+ static final int FONT_SIZE = 12;
+ static final int ARROW_SIZE = 1;
+ static final int ARROW_WIDTH = 2;
+
+ @Override
+ public int fontSize() {
+ return FONT_SIZE;
+ }
+
+ @Override
+ public String fontName() {
+ return FONT_NAME;
+ }
+
+ @Override
+ public String fontColor() {
+ return BLACK;
+ }
+
+ @Override
+ public int arrowSize() {
+ return ARROW_SIZE;
+ }
+
+ @Override
+ public int arrowWidth() {
+ return ARROW_WIDTH;
+ }
+
+ @Override
+ public String arrowColor() {
+ return DARK_GRAY;
+ }
+ }
+
+ private static class DotGraphBuilder {
+ static final String REEXPORTS = "";
+ static final String REQUIRES = "style=\"dashed\"";
+
static final Set<String> JAVA_SE_SUBGRAPH = javaSE();
static final Set<String> JDK_SUBGRAPH = jdk();
@@ -215,41 +305,20 @@
}
}
- static final String ORANGE = "#e76f00";
- static final String BLUE = "#437291";
- static final String GRAY = "#dddddd";
- static final String BLACK = "#000000";
-
- static final String FONT_NAME = "DejaVuSans";
- static final int FONT_SIZE = 12;
- static final int ARROW_SIZE = 1;
- static final int ARROW_WIDTH = 2;
- static final int RANK_SEP = 1;
-
- static final String REEXPORTS = "";
- static final String REQUIRES = "style=\"dashed\"";
- static final String REQUIRES_BASE = "color=\"" + GRAY + "\"";
-
- // can be configured
- static double rankSep = RANK_SEP;
- static String fontColor = BLACK;
- static String fontName = FONT_NAME;
- static int fontsize = FONT_SIZE;
- static int arrowWidth = ARROW_WIDTH;
- static int arrowSize = ARROW_SIZE;
- static final Map<String, Integer> weights = new HashMap<>();
- static final List<Set<String>> ranks = new ArrayList<>();
-
private final String name;
private final Graph<String> graph;
private final Set<ModuleDescriptor> descriptors = new TreeSet<>();
private final List<SubGraph> subgraphs = new ArrayList<>();
- public DotGraphBuilder(String name, Graph<String> graph) {
+ private final Attributes attributes;
+ public DotGraphBuilder(String name,
+ Graph<String> graph,
+ Attributes attributes) {
this.name = name;
this.graph = graph;
+ this.attributes = attributes;
}
- public DotGraphBuilder descriptors(Stream<ModuleDescriptor> descriptors) {
+ public DotGraphBuilder modules(Stream<ModuleDescriptor> descriptors) {
descriptors.forEach(this.descriptors::add);
return this;
}
@@ -260,22 +329,27 @@
out.format("digraph \"%s\" {%n", name);
out.format(" nodesep=.5;%n");
- out.format(" ranksep=%f;%n", rankSep);
+ out.format(" ranksep=%f;%n", attributes.rankSep());
out.format(" pencolor=transparent;%n");
- out.format(" node [shape=plaintext, fontname=\"%s\", fontsize=%d, margin=\".2,.2\"];%n",
- fontName, fontsize);
- out.format(" edge [penwidth=%d, color=\"#999999\", arrowhead=open, arrowsize=%d];%n",
- arrowWidth, arrowSize);
+ out.format(" node [shape=plaintext, fontcolor=\"%s\", fontname=\"%s\","
+ + " fontsize=%d, margin=\".2,.2\"];%n",
+ attributes.fontColor(),
+ attributes.fontName(),
+ attributes.fontSize());
+ out.format(" edge [penwidth=%d, color=\"%s\", arrowhead=open, arrowsize=%d];%n",
+ attributes.arrowWidth(),
+ attributes.arrowColor(),
+ attributes.arrowSize());
// same RANKS
- ranks.stream()
- .map(nodes -> descriptors.stream()
+ attributes.ranks().stream()
+ .map(nodes -> descriptors.stream()
.map(ModuleDescriptor::name)
.filter(nodes::contains)
.map(mn -> "\"" + mn + "\"")
.collect(joining(",")))
- .filter(group -> group.length() > 0)
- .forEach(group -> out.format(" {rank=same %s}%n", group));
+ .filter(group -> group.length() > 0)
+ .forEach(group -> out.format(" {rank=same %s}%n", group));
subgraphs.forEach(subgraph -> {
out.format(" subgraph %s {%n", subgraph.name);
@@ -314,10 +388,14 @@
String mn = md.name();
edges.stream().forEach(dn -> {
- String attr = dn.equals("java.base") ? REQUIRES_BASE
- : (requiresTransitive.contains(dn) ? REEXPORTS : REQUIRES);
+ String attr;
+ if (dn.equals("java.base")) {
+ attr = "color=\"" + attributes.requiresMandatedColor() + "\"";
+ } else {
+ attr = (requiresTransitive.contains(dn) ? REEXPORTS : REQUIRES);
+ }
- int w = weightOf(mn, dn);
+ int w = attributes.weightOf(mn, dn);
if (w > 1) {
if (!attr.isEmpty())
attr += ", ";
@@ -328,41 +406,5 @@
});
}
- public int weightOf(String s, String t) {
- int w = weights.getOrDefault(s + ":" + t, 1);
- if (w != 1)
- return w;
- if (s.startsWith("java.") && t.startsWith("java."))
- return 10;
- return 1;
- }
-
- public static void sameRankNodes(Set<String> nodes) {
- ranks.add(nodes);
- }
-
- public static void weight(String s, String t, int w) {
- weights.put(s + ":" + t, w);
- }
-
- public static void setRankSep(double value) {
- rankSep = value;
- }
-
- public static void setFontSize(int size) {
- fontsize = size;
- }
-
- public static void setFontColor(String color) {
- fontColor = color;
- }
-
- public static void setArrowSize(int size) {
- arrowSize = size;
- }
-
- public static void setArrowWidth(int width) {
- arrowWidth = width;
- }
}
}
--- a/langtools/src/jdk.jdeps/share/classes/module-info.java Wed Mar 29 23:33:07 2017 +0000
+++ b/langtools/src/jdk.jdeps/share/classes/module-info.java Thu Mar 30 17:24:01 2017 +0000
@@ -26,6 +26,7 @@
/** Defines tools for analysing dependencies in Java libraries and programs, including
* the <em>jdeps</em> and <em>javap</em> tools.
*
+ * @moduleGraph
* @since 9
*/
module jdk.jdeps {
--- a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java Wed Mar 29 23:33:07 2017 +0000
+++ b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java Thu Mar 30 17:24:01 2017 +0000
@@ -1429,9 +1429,15 @@
List<Suggestion> result;
int pastSpace = code.indexOf(' ') + 1; // zero if no space
if (pastSpace == 0) {
+ // initially suggest commands (with slash) and subjects,
+ // however, if their subject starts without slash, include
+ // commands without slash
+ boolean noslash = code.length() > 0 && !code.startsWith("/");
result = new FixedCompletionProvider(commands.values().stream()
.filter(cmd -> cmd.kind.showInHelp || cmd.kind == CommandKind.HELP_SUBJECT)
- .map(c -> c.command + " ")
+ .map(c -> ((noslash && c.command.startsWith("/"))
+ ? c.command.substring(1)
+ : c.command) + " ")
.toArray(String[]::new))
.completionSuggestions(code, cursor, anchor);
} else if (code.startsWith("/se")) {
@@ -2087,8 +2093,11 @@
ArgTokenizer at = new ArgTokenizer("/help", arg);
String subject = at.next();
if (subject != null) {
+ // check if the requested subject is a help subject or
+ // a command, with or without slash
Command[] matches = commands.values().stream()
- .filter(c -> c.command.startsWith(subject))
+ .filter(c -> c.command.startsWith(subject)
+ || c.command.substring(1).startsWith(subject))
.toArray(Command[]::new);
if (matches.length == 1) {
String cmd = matches[0].command;
@@ -2113,6 +2122,18 @@
}
return true;
} else {
+ // failing everything else, check if this is the start of
+ // a /set sub-command name
+ String[] subs = Arrays.stream(SET_SUBCOMMANDS)
+ .filter(s -> s.startsWith(subject))
+ .toArray(String[]::new);
+ if (subs.length > 0) {
+ for (String sub : subs) {
+ hardrb("help.set." + sub);
+ hard("");
+ }
+ return true;
+ }
errormsg("jshell.err.help.arg", arg);
}
}
--- a/langtools/src/jdk.jshell/share/classes/module-info.java Wed Mar 29 23:33:07 2017 +0000
+++ b/langtools/src/jdk.jshell/share/classes/module-info.java Thu Mar 30 17:24:01 2017 +0000
@@ -52,6 +52,7 @@
* definitions.
* </p>
*
+ * @moduleGraph
* @since 9
*/
module jdk.jshell {
--- a/langtools/test/jdk/javadoc/tool/modules/ReleaseOptions.java Wed Mar 29 23:33:07 2017 +0000
+++ b/langtools/test/jdk/javadoc/tool/modules/ReleaseOptions.java Thu Mar 30 17:24:01 2017 +0000
@@ -23,7 +23,7 @@
/**
* @test
- * @bug 8175346
+ * @bug 8175346 8175277
* @summary Test release option interactions
* @modules
* jdk.javadoc/jdk.javadoc.internal.api
@@ -58,7 +58,7 @@
Task.Result result = execNegativeTask("--release", "8",
"--patch-module", "m=" + mpath.toString(),
"p");
- assertMessagePresent(".*No source files for package p.*");
+ assertMessagePresent(".*not allowed with target 1.8.*");
assertMessageNotPresent(".*Exception*");
assertMessageNotPresent(".java.lang.AssertionError.*");
}
@@ -80,20 +80,20 @@
assertMessageNotPresent(".java.lang.AssertionError.*");
}
-// @Test TBD, JDK-8175277, argument validation should fail on this
-// public void testReleaseWithModuleSourcepath(Path base) throws Exception {
-// Path src = Paths.get(base.toString(), "src");
-// Path mpath = Paths.get(src.toString(), "m");
-//
-// tb.writeJavaFiles(mpath,
-// "module m { exports p; }",
-// "package p; public class C { }");
-//
-// Task.Result result = execNegativeTask("--release", "8",
-// "--module-source-path", src.toString(),
-// "--module", "m");
-// assertMessagePresent(".*(use -source 9 or higher to enable modules).*");
-// assertMessageNotPresent(".*Exception*");
-// assertMessageNotPresent(".java.lang.AssertionError.*");
-// }
+ @Test
+ public void testReleaseWithModuleSourcepath(Path base) throws Exception {
+ Path src = Paths.get(base.toString(), "src");
+ Path mpath = Paths.get(src.toString(), "m");
+
+ tb.writeJavaFiles(mpath,
+ "module m { exports p; }",
+ "package p; public class C { }");
+
+ Task.Result result = execNegativeTask("--release", "8",
+ "--module-source-path", src.toString(),
+ "--module", "m");
+ assertMessagePresent(".*not allowed with target 1.8.*");
+ assertMessageNotPresent(".*Exception*");
+ assertMessageNotPresent(".java.lang.AssertionError.*");
+ }
}
--- a/langtools/test/jdk/jshell/CommandCompletionTest.java Wed Mar 29 23:33:07 2017 +0000
+++ b/langtools/test/jdk/jshell/CommandCompletionTest.java Thu Mar 30 17:24:01 2017 +0000
@@ -23,7 +23,7 @@
/*
* @test
- * @bug 8144095 8164825 8169818 8153402 8165405
+ * @bug 8144095 8164825 8169818 8153402 8165405 8177079
* @summary Test Command Completion
* @modules jdk.compiler/com.sun.tools.javac.api
* jdk.compiler/com.sun.tools.javac.main
@@ -173,7 +173,9 @@
"/save ", "/set "),
a -> assertCompletion(a, "/help /set |", false,
"editor", "feedback", "format", "mode", "prompt", "start", "truncation"),
- a -> assertCompletion(a, "/help /edit |", false)
+ a -> assertCompletion(a, "/help /edit |", false),
+ a -> assertCompletion(a, "/help dr|", false,
+ "drop ")
);
}
--- a/langtools/test/jdk/jshell/ToolSimpleTest.java Wed Mar 29 23:33:07 2017 +0000
+++ b/langtools/test/jdk/jshell/ToolSimpleTest.java Thu Mar 30 17:24:01 2017 +0000
@@ -23,7 +23,7 @@
/*
* @test
- * @bug 8153716 8143955 8151754 8150382 8153920 8156910 8131024 8160089 8153897 8167128 8154513 8170015 8170368 8172102 8172103 8165405 8173073 8173848 8174041 8173916 8174028 8174262 8174797
+ * @bug 8153716 8143955 8151754 8150382 8153920 8156910 8131024 8160089 8153897 8167128 8154513 8170015 8170368 8172102 8172103 8165405 8173073 8173848 8174041 8173916 8174028 8174262 8174797 8177079
* @summary Simple jshell tool tests
* @modules jdk.compiler/com.sun.tools.javac.api
* jdk.compiler/com.sun.tools.javac.main
@@ -350,7 +350,9 @@
(a) -> assertHelp(a, "/help short", "shortcuts", "<tab>"),
(a) -> assertHelp(a, "/? /li", "/list -all", "snippets"),
(a) -> assertHelp(a, "/help /set prompt", "optionally contain '%s'", "quoted"),
- (a) -> assertHelp(a, "/help /help", "/help <command>")
+ (a) -> assertHelp(a, "/help /help", "/help <command>"),
+ (a) -> assertHelp(a, "/help li", "/list -start"),
+ (a) -> assertHelp(a, "/help fe", "/set feedback -retain")
);
}
--- a/langtools/test/tools/javac/modules/EdgeCases.java Wed Mar 29 23:33:07 2017 +0000
+++ b/langtools/test/tools/javac/modules/EdgeCases.java Thu Mar 30 17:24:01 2017 +0000
@@ -23,7 +23,7 @@
/*
* @test
- * @bug 8154283 8167320 8171098 8172809 8173068 8173117 8176045
+ * @bug 8154283 8167320 8171098 8172809 8173068 8173117 8176045 8177311
* @summary tests for multi-module mode compilation
* @library /tools/lib
* @modules
@@ -958,4 +958,41 @@
throw new Exception("expected output not found: " + log);
}
+ @Test
+ public void testDependOnUnnamedAccessibility(Path base) throws Exception {
+ Path unnamedSrc = base.resolve("unnamed-src");
+ tb.writeJavaFiles(unnamedSrc,
+ "package p1; public class First { public static p2.Second get() { return null; } }",
+ "package p2; public class Second { public void test() { } }");
+ Path unnamedClasses = base.resolve("unnamed-classes");
+ tb.createDirectories(unnamedClasses);
+
+ System.err.println("compiling unnamed sources:");
+
+ new JavacTask(tb)
+ .outdir(unnamedClasses)
+ .files(findJavaFiles(unnamedSrc))
+ .run()
+ .writeAll();
+
+ //test sources:
+ Path src = base.resolve("src");
+ Path m = src.resolve("m");
+ tb.writeJavaFiles(m,
+ "module m { }",
+ "package p; public class Test { { p1.First.get().test(); } }");
+ Path classes = base.resolve("classes");
+ tb.createDirectories(classes);
+
+ System.err.println("compiling test module:");
+
+ new JavacTask(tb)
+ .options("-classpath", unnamedClasses.toString(),
+ "--add-reads", "m=ALL-UNNAMED")
+ .outdir(classes)
+ .files(findJavaFiles(src))
+ .run()
+ .writeAll();
+ }
+
}