From 3977b2c53021f4f62a18a36f594d566260ccdd06 Mon Sep 17 00:00:00 2001 From: Kumar Srinivasan Date: Tue, 4 Apr 2017 11:27:06 -0700 Subject: [PATCH 1/9] 8176901: Internal error running javadoc over jdk internal classes Reviewed-by: jjg --- .../toolkit/util/JavaScriptScanner.java | 4 +- .../doclet/testBadHtml/TestBadHtml.java | 52 +++++++++++++++++++ .../javadoc/doclet/testBadHtml/pkg1/A.java | 42 +++++++++++++++ 3 files changed, 96 insertions(+), 2 deletions(-) create mode 100644 langtools/test/jdk/javadoc/doclet/testBadHtml/TestBadHtml.java create mode 100644 langtools/test/jdk/javadoc/doclet/testBadHtml/pkg1/A.java diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/JavaScriptScanner.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/JavaScriptScanner.java index c476c536dab..8699bed356b 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/JavaScriptScanner.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/JavaScriptScanner.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -95,7 +95,7 @@ public class JavaScriptScanner extends DocTreePathScanner value = tree.getValue(); - if (!value.isEmpty() && value.get(0).getKind() == Kind.TEXT) { + if (value != null && !value.isEmpty() && value.get(0).getKind() == Kind.TEXT) { String v = value.get(0).toString().trim().toLowerCase(Locale.ENGLISH); if (v.startsWith("javascript:")) { f.accept(getCurrentPath()); diff --git a/langtools/test/jdk/javadoc/doclet/testBadHtml/TestBadHtml.java b/langtools/test/jdk/javadoc/doclet/testBadHtml/TestBadHtml.java new file mode 100644 index 00000000000..1b2b0535d34 --- /dev/null +++ b/langtools/test/jdk/javadoc/doclet/testBadHtml/TestBadHtml.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 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. + * + * 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. + */ + +/* + * @test + * @bug 8176901 + * @summary The doclet should cope with bad HTML form + * @library ../lib + * @modules jdk.javadoc/jdk.javadoc.internal.tool + * @build JavadocTester + * @run main TestBadHtml + */ + +public class TestBadHtml extends JavadocTester { + + public static void main(String... args) throws Exception { + TestBadHtml tester = new TestBadHtml(); + tester.runTests(); + } + + @Test + void testNegative() { + javadoc("-d", "out1", + "-sourcepath", testSrc, + "pkg1"); + + checkExit(Exit.ERROR); + + checkOutput(Output.STDERR, false, "NullPointerException"); + checkOutput(Output.OUT, false, "NullPointerException"); + } +} diff --git a/langtools/test/jdk/javadoc/doclet/testBadHtml/pkg1/A.java b/langtools/test/jdk/javadoc/doclet/testBadHtml/pkg1/A.java new file mode 100644 index 00000000000..f33d1420385 --- /dev/null +++ b/langtools/test/jdk/javadoc/doclet/testBadHtml/pkg1/A.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 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. + * + * 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 pkg1; + +/** + * The first sentence. + * + * + * + * + * + * + * + * + * + * + * + * + */ + +public class A {} From 3fd763e24f832d8f42094ca2fbdec4844ab17d0f Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Tue, 4 Apr 2017 14:02:03 -0700 Subject: [PATCH 2/9] 8177562: Small updates to module summary page Reviewed-by: bpatel, ksrini --- .../doclets/formats/html/Contents.java | 2 + .../formats/html/ModuleWriterImpl.java | 126 +++++++++--------- .../formats/html/markup/HtmlWriter.java | 15 +-- .../html/resources/standard.properties | 1 + .../doclets/toolkit/resources/doclet.xml | 4 +- .../toolkit/resources/doclets.properties | 17 +-- .../doclet/testModules/TestModules.java | 53 ++++---- 7 files changed, 109 insertions(+), 109 deletions(-) diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/Contents.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/Contents.java index f0d28672792..827053db261 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/Contents.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/Contents.java @@ -130,6 +130,7 @@ public class Contents { public final Content nextPackageLabel; public final Content noFramesLabel; public final Content noScriptMessage; + public final Content openModuleLabel; public final Content overridesLabel; public final Content overviewLabel; public final Content packageHierarchies; @@ -244,6 +245,7 @@ public class Contents { nextPackageLabel = getNonBreakContent("doclet.Next_Package"); noFramesLabel = getNonBreakContent("doclet.No_Frames"); noScriptMessage = getContent("doclet.No_Script_Message"); + openModuleLabel = getContent("doclet.Open_Module"); overridesLabel = getContent("doclet.Overrides"); overviewLabel = getContent("doclet.Overview"); packageHierarchies = getContent("doclet.Package_Hierarchies"); 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 e5a733c23d1..70b56accaa0 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 @@ -98,19 +98,19 @@ public class ModuleWriterImpl extends HtmlDocletWriter implements ModuleSummaryW = new TreeMap<>(utils.makeModuleComparator()); /** - * Map of additional modules and modifiers, transitive closure, required by this module. + * Map of indirect modules and modifiers, transitive closure, required by this module. */ - private final Map additionalModules + private final Map indirectModules = new TreeMap<>(utils.makeModuleComparator()); /** - * Map of packages exported by this module and the modules it's been exported to. + * Map of packages exported by this module and the modules it has been exported to. */ private final Map> exportedPackages = new TreeMap<>(utils.makePackageComparator()); /** - * Map of opened packages by this module and the modules it's been opened to. + * Map of opened packages by this module and the modules it has been opened to. */ private final Map> openedPackages = new TreeMap<>(utils.makePackageComparator()); @@ -121,15 +121,15 @@ public class ModuleWriterImpl extends HtmlDocletWriter implements ModuleSummaryW private final SortedSet concealedPackages = new TreeSet<>(utils.makePackageComparator()); /** - * Map of additional modules (transitive closure) and its exported packages. + * Map of indirect modules (transitive closure) and their exported packages. */ - private final Map> additionalPackages + private final Map> indirectPackages = new TreeMap<>(utils.makeModuleComparator()); /** - * Map of additional modules (transitive closure) and its open packages. + * Map of indirect modules (transitive closure) and their open packages. */ - private final Map> additionalOpenPackages + private final Map> indirectOpenPackages = new TreeMap<>(utils.makeModuleComparator()); /** @@ -212,8 +212,10 @@ public class ModuleWriterImpl extends HtmlDocletWriter implements ModuleSummaryW Content annotationContent = new HtmlTree(HtmlTag.P); addAnnotationInfo(mdle, annotationContent); div.addContent(annotationContent); + Content label = mdle.isOpen() && (configuration.docEnv.getModuleMode() == ModuleMode.ALL) + ? contents.openModuleLabel : contents.moduleLabel; Content tHeading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true, - HtmlStyle.title, contents.moduleLabel); + HtmlStyle.title, label); tHeading.addContent(Contents.SPACE); Content moduleHead = new RawHtml(heading); tHeading.addContent(moduleHead); @@ -264,12 +266,12 @@ public class ModuleWriterImpl extends HtmlDocletWriter implements ModuleSummaryW CommentHelper ch = utils.getCommentHelper(mdle); // Get module dependencies using the module's transitive closure. Map dependentModules = utils.getDependentModules(mdle); - // Add all dependent modules to additional modules set. We will remove the modules, - // listed using the requires directive, from this set to come up with the table of additional + // Add all dependent modules to indirect modules set. We will remove the modules, + // listed using the requires directive, from this set to come up with the table of indirect // required modules. dependentModules.forEach((module, mod) -> { if (shouldDocument(module)) { - additionalModules.put(module, new StringContent(mod)); + indirectModules.put(module, new StringContent(mod)); } }); (ElementFilter.requiresIn(mdle.getDirectives())).forEach((directive) -> { @@ -278,11 +280,11 @@ public class ModuleWriterImpl extends HtmlDocletWriter implements ModuleSummaryW if (moduleMode == ModuleMode.ALL || directive.isTransitive()) { requires.put(m, new StringContent(utils.getModifiers(directive))); } else { - // For api mode, just keep the public requires in dependentModules for display of - // additional packages in the "Packages" section. + // For api mode, just keep the public requires in dependentModules for display of + // indirect packages in the "Packages" section. dependentModules.remove(m); - } - additionalModules.remove(m); + } + indirectModules.remove(m); } }); @@ -320,7 +322,7 @@ public class ModuleWriterImpl extends HtmlDocletWriter implements ModuleSummaryW mdleList.addAll(targetMdles); } // Qualified opens should not be displayed in the api mode. So if mdleList is empty, - // it's opened to all modules and hence can be added. + // it is opened to all modules and hence can be added. if (moduleMode == ModuleMode.ALL || mdleList.isEmpty()) { openedPackages.put(p, mdleList); } @@ -331,7 +333,7 @@ public class ModuleWriterImpl extends HtmlDocletWriter implements ModuleSummaryW concealedPackages.removeAll(exportedPackages.keySet()); concealedPackages.removeAll(openedPackages.keySet()); // Get all the exported and opened packages, for the transitive closure of the module, to be displayed in - // the additional packages tables. + // the indirect packages tables. dependentModules.forEach((module, mod) -> { SortedSet pkgList = new TreeSet<>(utils.makePackageComparator()); (ElementFilter.exportsIn(module.getDirectives())).forEach((directive) -> { @@ -343,7 +345,7 @@ public class ModuleWriterImpl extends HtmlDocletWriter implements ModuleSummaryW // If none of the transitive modules have exported packages to be displayed, we should not be // displaying the table and so it should not be added to the map. if (!pkgList.isEmpty()) { - additionalPackages.put(module, pkgList); + indirectPackages.put(module, pkgList); } SortedSet openPkgList = new TreeSet<>(utils.makePackageComparator()); (ElementFilter.opensIn(module.getDirectives())).forEach((directive) -> { @@ -355,7 +357,7 @@ public class ModuleWriterImpl extends HtmlDocletWriter implements ModuleSummaryW // If none of the transitive modules have opened packages to be displayed, we should not be // displaying the table and so it should not be added to the map. if (!openPkgList.isEmpty()) { - additionalOpenPackages.put(module, openPkgList); + indirectOpenPackages.put(module, openPkgList); } }); // Get all the services listed as uses directive. @@ -471,31 +473,31 @@ public class ModuleWriterImpl extends HtmlDocletWriter implements ModuleSummaryW * {@inheritDoc} */ public void addModulesSummary(Content summaryContentTree) { - if (display(requires) || display(additionalModules)) { + if (display(requires) || display(indirectModules)) { HtmlTree li = new HtmlTree(HtmlTag.LI); li.addStyle(HtmlStyle.blockList); addSummaryHeader(HtmlConstants.START_OF_MODULES_SUMMARY, SectionName.MODULES, contents.navModules, li); if (display(requires)) { - String text = configuration.getText("doclet.Requires_Summary"); - String tableSummary = configuration.getText("doclet.Member_Table_Summary", - configuration.getText("doclet.Requires_Summary"), - configuration.getText("doclet.modules")); + String text = configuration.getText("doclet.Requires_Summary"); + String tableSummary = configuration.getText("doclet.Member_Table_Summary", + configuration.getText("doclet.Requires_Summary"), + configuration.getText("doclet.modules")); Content table = getTableHeader(text, tableSummary, HtmlStyle.requiresSummary, requiresTableHeader); Content tbody = new HtmlTree(HtmlTag.TBODY); addModulesList(requires, tbody); table.addContent(tbody); li.addContent(table); } - // Display additional modules table in both "api" and "all" mode. - if (display(additionalModules)) { - String amrText = configuration.getText("doclet.Additional_Modules_Required_Summary"); + // Display indirect modules table in both "api" and "all" mode. + if (display(indirectModules)) { + String amrText = configuration.getText("doclet.Indirect_Requires_Summary"); String amrTableSummary = configuration.getText("doclet.Member_Table_Summary", - configuration.getText("doclet.Additional_Modules_Required_Summary"), + configuration.getText("doclet.Indirect_Requires_Summary"), configuration.getText("doclet.modules")); Content amrTable = getTableHeader(amrText, amrTableSummary, HtmlStyle.requiresSummary, requiresTableHeader); Content amrTbody = new HtmlTree(HtmlTag.TBODY); - addModulesList(additionalModules, amrTbody); + addModulesList(indirectModules, amrTbody); amrTable.addContent(amrTbody); li.addContent(amrTable); } @@ -530,7 +532,7 @@ public class ModuleWriterImpl extends HtmlDocletWriter implements ModuleSummaryW public void addPackagesSummary(Content summaryContentTree) { if (display(exportedPackages) || display(openedPackages) || display(concealedPackages) - || display(additionalPackages) || display(additionalOpenPackages)) { + || display(indirectPackages) || display(indirectOpenPackages)) { HtmlTree li = new HtmlTree(HtmlTag.LI); li.addStyle(HtmlStyle.blockList); addSummaryHeader(HtmlConstants.START_OF_PACKAGES_SUMMARY, SectionName.PACKAGES, @@ -541,29 +543,29 @@ public class ModuleWriterImpl extends HtmlDocletWriter implements ModuleSummaryW if (display(exportedPackages) || display(openedPackages) || display(concealedPackages)) { addPackageSummary(tableSummary, li); } - if (display(additionalPackages)) { - String aepText = configuration.getText("doclet.Additional_Exported_Packages_Summary"); - String aepTableSummary = configuration.getText("doclet.Additional_Packages_Table_Summary", - configuration.getText("doclet.Additional_Exported_Packages_Summary"), + if (display(indirectPackages)) { + String aepText = configuration.getText("doclet.Indirect_Exports_Summary"); + String aepTableSummary = configuration.getText("doclet.Indirect_Packages_Table_Summary", + configuration.getText("doclet.Indirect_Exports_Summary"), configuration.getText("doclet.modules"), configuration.getText("doclet.packages")); Content aepTable = getTableHeader(aepText, aepTableSummary, HtmlStyle.packagesSummary, - additionalPackagesTableHeader); + indirectPackagesTableHeader); Content aepTbody = new HtmlTree(HtmlTag.TBODY); - addAdditionalPackages(aepTbody, additionalPackages); + addIndirectPackages(aepTbody, indirectPackages); aepTable.addContent(aepTbody); li.addContent(aepTable); } - if (display(additionalOpenPackages)) { - String aopText = configuration.getText("doclet.Additional_Opened_Packages_Summary"); - String aopTableSummary = configuration.getText("doclet.Additional_Packages_Table_Summary", - configuration.getText("doclet.Additional_Opened_Packages_Summary"), + if (display(indirectOpenPackages)) { + String aopText = configuration.getText("doclet.Indirect_Opens_Summary"); + String aopTableSummary = configuration.getText("doclet.Indirect_Packages_Table_Summary", + configuration.getText("doclet.Indirect_Opens_Summary"), configuration.getText("doclet.modules"), configuration.getText("doclet.packages")); Content aopTable = getTableHeader(aopText, aopTableSummary, HtmlStyle.packagesSummary, - additionalPackagesTableHeader); + indirectPackagesTableHeader); Content aopTbody = new HtmlTree(HtmlTag.TBODY); - addAdditionalPackages(aopTbody, additionalOpenPackages); + addIndirectPackages(aopTbody, indirectOpenPackages); aopTable.addContent(aopTbody); li.addContent(aopTable); } @@ -734,14 +736,14 @@ public class ModuleWriterImpl extends HtmlDocletWriter implements ModuleSummaryW } /** - * Add the additional packages for the module being documented. + * Add the indirect packages for the module being documented. * * @param tbody the content tree to which the table will be added - * @param ap additional packages to be added + * @param ip indirect packages to be added */ - public void addAdditionalPackages(Content tbody, Map> ap) { + public void addIndirectPackages(Content tbody, Map> ip) { boolean altColor = true; - for (Map.Entry> entry : ap.entrySet()) { + for (Map.Entry> entry : ip.entrySet()) { ModuleElement m = entry.getKey(); SortedSet pkgList = entry.getValue(); Content moduleLinkContent = getModuleLink(m, new StringContent(m.getQualifiedName())); @@ -773,19 +775,6 @@ public class ModuleWriterImpl extends HtmlDocletWriter implements ModuleSummaryW contents.navServices, li); String text; String tableSummary; - if (display(uses)) { - text = configuration.getText("doclet.Uses_Summary"); - tableSummary = configuration.getText("doclet.Member_Table_Summary", - configuration.getText("doclet.Uses_Summary"), - configuration.getText("doclet.types")); - Content table = getTableHeader(text, tableSummary, HtmlStyle.usesSummary, usesTableHeader); - Content tbody = new HtmlTree(HtmlTag.TBODY); - addUsesList(tbody); - if (!tbody.isEmpty()) { - table.addContent(tbody); - li.addContent(table); - } - } if (display(provides)) { text = configuration.getText("doclet.Provides_Summary"); tableSummary = configuration.getText("doclet.Member_Table_Summary", @@ -799,6 +788,19 @@ public class ModuleWriterImpl extends HtmlDocletWriter implements ModuleSummaryW li.addContent(table); } } + if (display(uses)) { + text = configuration.getText("doclet.Uses_Summary"); + tableSummary = configuration.getText("doclet.Member_Table_Summary", + configuration.getText("doclet.Uses_Summary"), + configuration.getText("doclet.types")); + Content table = getTableHeader(text, tableSummary, HtmlStyle.usesSummary, usesTableHeader); + Content tbody = new HtmlTree(HtmlTag.TBODY); + addUsesList(tbody); + if (!tbody.isEmpty()) { + table.addContent(tbody); + li.addContent(table); + } + } HtmlTree ul = HtmlTree.UL(HtmlStyle.blockList, li); summaryContentTree.addContent(ul); } @@ -975,12 +977,12 @@ public class ModuleWriterImpl extends HtmlDocletWriter implements ModuleSummaryW ? getHyperLink(SectionName.MODULE_DESCRIPTION, contents.navModuleDescription) : contents.navModuleDescription); addNavGap(liNav); - liNav.addContent((display(requires) || display(additionalModules)) + liNav.addContent((display(requires) || display(indirectModules)) ? getHyperLink(SectionName.MODULES, contents.navModules) : contents.navModules); addNavGap(liNav); liNav.addContent((display(exportedPackages) || display(openedPackages) || display(concealedPackages) - || display(additionalPackages) || display(additionalOpenPackages)) + || display(indirectPackages) || display(indirectOpenPackages)) ? getHyperLink(SectionName.PACKAGES, contents.navPackages) : contents.navPackages); addNavGap(liNav); diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlWriter.java index 706d7294e45..f1f1b9ebe7f 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlWriter.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlWriter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -36,7 +36,6 @@ import jdk.javadoc.internal.doclets.toolkit.util.DocFile; import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException; import jdk.javadoc.internal.doclets.toolkit.util.DocPath; import jdk.javadoc.internal.doclets.toolkit.util.DocletConstants; -import jdk.javadoc.internal.doclets.toolkit.util.ModulePackageTypes; import jdk.javadoc.internal.doclets.toolkit.util.TableTabTypes; @@ -88,7 +87,7 @@ public class HtmlWriter { /** * Header for tables displaying modules and exported packages. */ - protected final List additionalPackagesTableHeader; + protected final List indirectPackagesTableHeader; /** * Header for tables displaying types and description. @@ -136,18 +135,18 @@ public class HtmlWriter { packageTableHeader.add(resources.getText("doclet.Package")); packageTableHeader.add(resources.getText("doclet.Description")); requiresTableHeader = new ArrayList<>(); - requiresTableHeader.add(resources.getText("doclet.Modifier")); + requiresTableHeader.add(resources.getText("doclet.Modifier")); requiresTableHeader.add(resources.getText("doclet.Module")); requiresTableHeader.add(resources.getText("doclet.Description")); exportedPackagesTableHeader = new ArrayList<>(); exportedPackagesTableHeader.add(resources.getText("doclet.Package")); if (configuration.docEnv.getModuleMode() == ModuleMode.ALL) { - exportedPackagesTableHeader.add(resources.getText("doclet.Module")); + exportedPackagesTableHeader.add(resources.getText("doclet.Module")); } exportedPackagesTableHeader.add(resources.getText("doclet.Description")); - additionalPackagesTableHeader = new ArrayList<>(); - additionalPackagesTableHeader.add(resources.getText("doclet.Module")); - additionalPackagesTableHeader.add(resources.getText("doclet.Packages")); + indirectPackagesTableHeader = new ArrayList<>(); + indirectPackagesTableHeader.add(resources.getText("doclet.From")); + indirectPackagesTableHeader.add(resources.getText("doclet.Packages")); usesTableHeader = new ArrayList<>(); usesTableHeader.add(resources.getText("doclet.Type")); usesTableHeader.add(resources.getText("doclet.Description")); 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 8990c4d2ef4..6fa91217571 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 @@ -6,6 +6,7 @@ doclet.Window_Overview_Summary=Overview doclet.Element=Element doclet.Package=Package doclet.Module=Module +doclet.Open_Module=Open Module doclet.All_Packages=All Packages doclet.All_Modules=All Modules doclet.None=None diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/doclet.xml b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/doclet.xml index 7a6c54d145a..3148605db46 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/doclet.xml +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/doclet.xml @@ -1,7 +1,7 @@ "); + + ""); checkOutput("moduleB-summary.html", found, "
\n" + "
    \n" @@ -372,7 +372,7 @@ public class TestModules extends JavadocTester { + "
  • \n" + "
      \n" + "
    • \n" - + ""); + + ""); checkOutput("moduleB-summary.html", found, "
      \n" + "
        \n" @@ -595,7 +595,7 @@ public class TestModules extends JavadocTester { + "TestInterface2InModuleB\n" + " \n" + "", - "Opened Packages \n" + "Opens \n" + "\n" + "Package\n" + "Description\n" @@ -730,17 +730,12 @@ public class TestModules extends JavadocTester { checkOutput("moduleA-summary.html", true, "
      • Description | " + "Modules | Packages | Services
      • ", - "transitive\n" - + "moduleB\n" - + "\n" - + "
        This is a test description for the moduleB module.
        \n" - + "", - "\n" - + "", - "
        Additional Exported Packages 
        \n" - + "\n" + "
        Additional Opened Packages 
        \n" + + "", + "
        Indirect Exports 
        \n" + + "\n" + "\n" - + "\n" + + "\n" + "\n" + "\n", "\n" @@ -751,15 +746,15 @@ public class TestModules extends JavadocTester { checkOutput("moduletags-summary.html", true, "
      • Description | Modules" + " | Packages | Services
      • ", - "
        Indirect Opens 
        ModuleFromPackages
        moduleB
        \n" - + "", + "
        Additional Modules Required 
        \n" + + "", "\n" + "\n" + "", - "
        Indirect Requires 
        transitivemoduleB\n" + "
        This is a test description for the moduleB module.
        \n" + "
        \n" - + "", + "
        Additional Exported Packages 
        \n" + + "", "\n" + "\n" + "\n" + "\n" + "", - "
        Indirect Exports 
        transitive staticmoduleA\n" @@ -771,16 +766,16 @@ public class TestModules extends JavadocTester { + "ModifierModuleDescription
        \n" - + "\n" + "
        Additional Modules Required 
        \n" + + "\n" + "\n" + "\n" + "\n" + "", - "
        Indirect Requires 
        ModifierModuleDescription
        \n" - + "\n" + "
        Additional Opened Packages 
        \n" + + "\n" + "\n" - + "\n" + + "\n" + "\n" + "\n", "\n" @@ -797,7 +792,7 @@ public class TestModules extends JavadocTester { "\n" + "", "
        Indirect Opens 
        ModuleFromPackages
        moduleBtestpkgmdlB 
        \n" - + "\n" + + "\n" + "\n" + "\n" + "\n" @@ -830,9 +825,9 @@ public class TestModules extends JavadocTester { + "\n" + "", "", + + "Concealed ", "\n" + "\n" + ""); @@ -854,10 +849,10 @@ public class TestModules extends JavadocTester { + "", ""); + + "Exports " + + "Opens "); checkOutput("moduleC-summary.html", found, - "\n" + "\n" + "\n" + "\n" + "\n" From 543364d22cc7842f117c81a01d2669a37006bce1 Mon Sep 17 00:00:00 2001 From: Bhavesh Patel Date: Tue, 4 Apr 2017 14:06:54 -0700 Subject: [PATCH 3/9] 8177417: Constructor Summary readability problems in jdk9 javadoc Reviewed-by: jjg, ksrini --- .../formats/html/ConstructorWriterImpl.java | 6 +----- .../doclets/formats/html/markup/HtmlStyle.java | 1 + .../doclets/toolkit/resources/stylesheet.css | 12 +++++++----- .../testMemberSummary/TestMemberSummary.java | 14 +++++++++++--- .../testMemberSummary/pkg/PrivateParent.java | 8 +++++++- .../doclet/testStylesheet/TestStylesheet.java | 6 +++--- 6 files changed, 30 insertions(+), 17 deletions(-) diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConstructorWriterImpl.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConstructorWriterImpl.java index c44087e07f2..9a4eb9f8a52 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConstructorWriterImpl.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConstructorWriterImpl.java @@ -169,11 +169,7 @@ public class ConstructorWriterImpl extends AbstractExecutableMemberWriter */ @Override public void setSummaryColumnStyleAndScope(HtmlTree thTree) { - if (foundNonPubConstructor) { - thTree.addStyle(HtmlStyle.colSecond); - } else { - thTree.addStyle(HtmlStyle.colFirst); - } + thTree.addStyle(HtmlStyle.colConstructorName); thTree.addAttr(HtmlAttr.SCOPE, "row"); } diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlStyle.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlStyle.java index 4010138211d..941538e83d3 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlStyle.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlStyle.java @@ -46,6 +46,7 @@ public enum HtmlStyle { bottomNav, circle, classUseContainer, + colConstructorName, colFirst, colLast, colSecond, diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/stylesheet.css b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/stylesheet.css index 470fd9d3010..c0eeeb42590 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/stylesheet.css +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/stylesheet.css @@ -540,14 +540,14 @@ Table styles text-align:left; padding:0px 0px 12px 10px; } -th.colFirst, th.colSecond, th.colLast, .useSummary th, .constantsSummary th, .packagesSummary th, +th.colFirst, th.colSecond, th.colLast, th.colConstructorName, .useSummary th, .constantsSummary th, .packagesSummary th, td.colFirst, td.colSecond, td.colLast, .useSummary td, .constantsSummary td { vertical-align:top; padding-right:0px; padding-top:8px; padding-bottom:3px; } -th.colFirst, th.colSecond, th.colLast, .constantsSummary th, .packagesSummary th { +th.colFirst, th.colSecond, th.colLast, th.colConstructorName, .constantsSummary th, .packagesSummary th { background:#dee3e9; text-align:left; padding:8px 3px 3px 7px; @@ -556,7 +556,7 @@ td.colFirst, th.colFirst { white-space:nowrap; font-size:13px; } -td.colSecond, th.colSecond, td.colLast, th.colLast { +td.colSecond, th.colSecond, td.colLast, th.colConstructorName, th.colLast { font-size:13px; } .constantsSummary th, .packagesSummary th { @@ -573,8 +573,8 @@ td.colSecond, th.colSecond, td.colLast, th.colLast { .usesSummary td.colFirst, .usesSummary th.colFirst, .providesSummary td.colFirst, .providesSummary th.colFirst, .memberSummary td.colFirst, .memberSummary th.colFirst, -.memberSummary td.colSecond, .memberSummary th.colSecond, -.typeSummary td.colFirst{ +.memberSummary td.colSecond, .memberSummary th.colSecond, .memberSummary th.colConstructorName, +.typeSummary td.colFirst { vertical-align:top; } .packagesSummary th.colLast, .packagesSummary td.colLast { @@ -584,6 +584,8 @@ td.colFirst a:link, td.colFirst a:active, td.colFirst a:visited, td.colFirst a:h td.colSecond a:link, td.colSecond a:active, td.colSecond a:visited, td.colSecond a:hover, th.colFirst a:link, th.colFirst a:active, th.colFirst a:visited, th.colFirst a:hover, th.colSecond a:link, th.colSecond a:active, th.colSecond a:visited, th.colSecond a:hover, +th.colConstructorName a:link, th.colConstructorName a:active, th.colConstructorName a:visited, +th.colConstructorName a:hover, td.colLast a:link, td.colLast a:active, td.colLast a:visited, td.colLast a:hover, .constantValuesContainer td a:link, .constantValuesContainer td a:active, .constantValuesContainer td a:visited, .constantValuesContainer td a:hover { diff --git a/langtools/test/jdk/javadoc/doclet/testMemberSummary/TestMemberSummary.java b/langtools/test/jdk/javadoc/doclet/testMemberSummary/TestMemberSummary.java index 404ff945291..1b443469f09 100644 --- a/langtools/test/jdk/javadoc/doclet/testMemberSummary/TestMemberSummary.java +++ b/langtools/test/jdk/javadoc/doclet/testMemberSummary/TestMemberSummary.java @@ -23,7 +23,7 @@ /* * @test - * @bug 4951228 6290760 8025633 8026567 8081854 8162363 8175200 + * @bug 4951228 6290760 8025633 8026567 8081854 8162363 8175200 8177417 * @summary Test the case where the overriden method returns a different * type than the method in the child class. Make sure the * documentation is inherited but the return type isn't. @@ -43,7 +43,7 @@ public class TestMemberSummary extends JavadocTester { @Test void test() { - javadoc("-d", "out", + javadoc("-d", "out", "-private", "-sourcepath", testSrc, "pkg","pkg2"); checkExit(Exit.OK); @@ -55,7 +55,15 @@ public class TestMemberSummary extends JavadocTester { + "returnTypeTest​()", // Check return type in member detail. "
        public "
        -                + "PublicChild returnTypeTest​()
        "); + + "PublicChild returnTypeTest​()", + "
        "); + + checkOutput("pkg/PrivateParent.html", true, + "\n" + + ""); // Legacy anchor dimensions (6290760) checkOutput("pkg2/A.html", true, diff --git a/langtools/test/jdk/javadoc/doclet/testMemberSummary/pkg/PrivateParent.java b/langtools/test/jdk/javadoc/doclet/testMemberSummary/pkg/PrivateParent.java index a3fa4bd0f0b..86d671db7d4 100644 --- a/langtools/test/jdk/javadoc/doclet/testMemberSummary/pkg/PrivateParent.java +++ b/langtools/test/jdk/javadoc/doclet/testMemberSummary/pkg/PrivateParent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -24,6 +24,12 @@ package pkg; class PrivateParent { + /** + * Test private constructor. + * @param i a test parameter. + */ + private PrivateParent(int i) { + } /** * Test to make sure the member summary inherits documentation diff --git a/langtools/test/jdk/javadoc/doclet/testStylesheet/TestStylesheet.java b/langtools/test/jdk/javadoc/doclet/testStylesheet/TestStylesheet.java index 944d99494b7..b5b9c373f02 100644 --- a/langtools/test/jdk/javadoc/doclet/testStylesheet/TestStylesheet.java +++ b/langtools/test/jdk/javadoc/doclet/testStylesheet/TestStylesheet.java @@ -23,7 +23,7 @@ /* * @test - * @bug 4494033 7028815 7052425 8007338 8023608 8008164 8016549 8072461 8154261 8162363 8160196 8151743 + * @bug 4494033 7028815 7052425 8007338 8023608 8008164 8016549 8072461 8154261 8162363 8160196 8151743 8177417 * @summary Run tests on doclet stylesheet. * @author jamieh * @library ../lib @@ -140,8 +140,8 @@ public class TestStylesheet extends JavadocTester { + ".usesSummary td.colFirst, .usesSummary th.colFirst,\n" + ".providesSummary td.colFirst, .providesSummary th.colFirst,\n" + ".memberSummary td.colFirst, .memberSummary th.colFirst,\n" - + ".memberSummary td.colSecond, .memberSummary th.colSecond,\n" - + ".typeSummary td.colFirst{\n" + + ".memberSummary td.colSecond, .memberSummary th.colSecond, .memberSummary th.colConstructorName,\n" + + ".typeSummary td.colFirst {\n" + " vertical-align:top;\n" + "}", ".overviewSummary td, .memberSummary td, .typeSummary td,\n" From 97a88e5a275e23b5e203f667a1285ebe907892ee Mon Sep 17 00:00:00 2001 From: Vicente Romero Date: Tue, 4 Apr 2017 15:15:59 -0700 Subject: [PATCH 4/9] 8177332: The presence of a file with a Japanese ShiftJIS name can cause javac to fail Reviewed-by: jjg, jlahoda --- .../com/sun/tools/javac/file/JavacFileManager.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/JavacFileManager.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/JavacFileManager.java index 5689334fdcd..959c88bc789 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/JavacFileManager.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/JavacFileManager.java @@ -473,10 +473,14 @@ public class JavacFileManager extends BaseFileManager implements StandardJavaFil } } else { if (isValidFile(fname, fileKinds)) { - RelativeFile file = new RelativeFile(subdirectory, fname); - JavaFileObject fe = PathFileObject.forDirectoryPath(JavacFileManager.this, - file.resolveAgainst(directory), userPath, file); - resultList.append(fe); + try { + RelativeFile file = new RelativeFile(subdirectory, fname); + JavaFileObject fe = PathFileObject.forDirectoryPath(JavacFileManager.this, + file.resolveAgainst(directory), userPath, file); + resultList.append(fe); + } catch (InvalidPathException e) { + throw new IOException("error accessing directory " + directory + e); + } } } } From 25dbddc731f544c3563113b56cc936ae53e26c37 Mon Sep 17 00:00:00 2001 From: Bhavesh Patel Date: Tue, 4 Apr 2017 23:04:39 -0700 Subject: [PATCH 5/9] 8175218: The fix for JDK-8141492 broke formatting of some javadoc documentation 8178078: jdk/javadoc/doclet/testDeprecatedDocs/TestDeprecatedDocs.java failed due to some subtests failed 8178079: jdk/javadoc/doclet/testModules/TestModules.java failed due to some subtests failed Reviewed-by: jjg, ksrini --- .../formats/html/TagletWriterImpl.java | 2 +- .../formats/html/markup/HtmlStyle.java | 1 + .../doclets/formats/html/markup/HtmlTree.java | 17 +++++++++++- .../doclets/toolkit/resources/stylesheet.css | 11 ++++---- .../TestDeprecatedDocs.java | 26 +++++++++---------- .../doclet/testModules/TestModules.java | 16 ++++++------ .../javadoc/doclet/testSearch/TestSearch.java | 6 ++--- .../doclet/testStylesheet/TestStylesheet.java | 11 ++++++++ 8 files changed, 58 insertions(+), 32 deletions(-) diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TagletWriterImpl.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TagletWriterImpl.java index 32f3871286e..2892801a090 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TagletWriterImpl.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TagletWriterImpl.java @@ -106,7 +106,7 @@ public class TagletWriterImpl extends TagletWriter { String desc = ch.getText(itt.getDescription()); String anchorName = htmlWriter.getName(tagText); - Content result = HtmlTree.A_ID(anchorName, new StringContent(tagText)); + Content result = HtmlTree.A_ID(HtmlStyle.searchTagResult, anchorName, new StringContent(tagText)); if (configuration.createindex && !tagText.isEmpty()) { SearchIndexItem si = new SearchIndexItem(); si.setLabel(tagText); diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlStyle.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlStyle.java index 941538e83d3..ad6c183448e 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlStyle.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlStyle.java @@ -99,6 +99,7 @@ public enum HtmlStyle { rightIframe, rowColor, searchTagLink, + searchTagResult, seeLabel, serializedFormContainer, simpleTagLabel, diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlTree.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlTree.java index b3ab27dadd3..46001936673 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlTree.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 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 @@ -264,6 +264,21 @@ public class HtmlTree extends Content { return htmltree; } + /** + * Generates an HTML anchor tag with a style class, id attribute and a body. + * + * @param styleClass stylesheet class for the tag + * @param id id for the anchor tag + * @param body body for the anchor tag + * @return an HtmlTree object + */ + public static HtmlTree A_ID(HtmlStyle styleClass, String id, Content body) { + HtmlTree htmltree = A_ID(id, body); + if (styleClass != null) + htmltree.addStyle(styleClass); + return htmltree; + } + /** * Generates a CAPTION tag with some content. * diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/stylesheet.css b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/stylesheet.css index c0eeeb42590..25b7cf34ef9 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/stylesheet.css +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/stylesheet.css @@ -42,15 +42,14 @@ a[name]:hover { text-decoration:none; color:#353833; } -a[name]:before, a[name]:target { +a[name]:before, a[name]:target, a[id]:before, a[id]:target { content:""; - display:block; - height:120px; - margin:-120px 0 0; -} -a[id]:before, a[id]:target { + display:inline-block; + position:relative; padding-top:129px; margin-top:-129px; +} +.searchTagResult:before, .searchTagResult:target { color:red; } pre { diff --git a/langtools/test/jdk/javadoc/doclet/testDeprecatedDocs/TestDeprecatedDocs.java b/langtools/test/jdk/javadoc/doclet/testDeprecatedDocs/TestDeprecatedDocs.java index 0fe649e029a..a801c887055 100644 --- a/langtools/test/jdk/javadoc/doclet/testDeprecatedDocs/TestDeprecatedDocs.java +++ b/langtools/test/jdk/javadoc/doclet/testDeprecatedDocs/TestDeprecatedDocs.java @@ -23,7 +23,7 @@ /* * @test - * @bug 4927552 8026567 8071982 8162674 8175200 + * @bug 4927552 8026567 8071982 8162674 8175200 8175218 * @summary * @author jamieh * @library ../lib @@ -81,16 +81,16 @@ public class TestDeprecatedDocs extends JavadocTester { + "extends java.lang.Object", "
        @Deprecated(forRemoval=true)\n"
                         + "public int field
        \n" - + "
        Deprecated, for removal: This API element is subject to removal in a future version.  
        ", + + "
        Deprecated, for removal: This API element is subject to removal in a future version. 
        ", "
        @Deprecated(forRemoval=true)\n"
                         + "public DeprecatedClassByAnnotation​()
        \n" - + "
        Deprecated, for removal: This API element is subject to removal in a future version.  
        ", + + "
        Deprecated, for removal: This API element is subject to removal in a future version. 
        ", "
        @Deprecated\n"
                         + "public void method​()
        \n" + "
        Deprecated. 
        "); checkOutput("pkg/TestAnnotationType.html", true, - "
        Deprecated, for removal: This API element is subject to removal in a future version.  \n" + "
        Deprecated, for removal: This API element is subject to removal in a future version. \n" + "
        annotation_test1 passes.
        \n" + "
        \n" + "
        \n" @@ -100,16 +100,16 @@ public class TestDeprecatedDocs extends JavadocTester { "
        @Deprecated(forRemoval=true)\n"
                         + "static final int field
        \n" + "
        Deprecated, for removal: This " - + "API element is subject to removal in a future version.  annotation_test4 passes.
        ", + + "API element is subject to removal in a future version. annotation_test4 passes.
        ", "
        @Deprecated(forRemoval=true)\n"
                         + "int required
        \n" - + "
        Deprecated, for removal: This API element is subject to removal in a future version.  " + + "
        Deprecated, for removal: This API element is subject to removal in a future version. " + "annotation_test3 passes.
        ", "
        java.lang.String optional
        \n" + "
        Deprecated. annotation_test2 passes.
        "); checkOutput("pkg/TestClass.html", true, - "
        Deprecated, for removal: This API element is subject to removal in a future version.  \n" + "
        Deprecated, for removal: This API element is subject to removal in a future version. \n" + "
        class_test1 passes.
        \n" + "
        \n" + "
        \n" @@ -118,11 +118,11 @@ public class TestDeprecatedDocs extends JavadocTester { + "extends java.lang.Object", "
        @Deprecated(forRemoval=true)\n"
                         + "public TestClass​()
        \n" - + "
        Deprecated, for removal: This API element is subject to removal in a future version.  " + + "
        Deprecated, for removal: This API element is subject to removal in a future version. " + "class_test3 passes.
        "); checkOutput("pkg/TestEnum.html", true, - "
        Deprecated, for removal: This API element is subject to removal in a future version.  \n" + "
        Deprecated, for removal: This API element is subject to removal in a future version. \n" + "
        enum_test1 passes.
        \n" + "
        \n" + "
        \n" @@ -131,11 +131,11 @@ public class TestDeprecatedDocs extends JavadocTester { + "extends java.lang.Enum<TestEnum>", "
        @Deprecated(forRemoval=true)\n"
                         + "public static final TestEnum FOR_REMOVAL
        \n" - + "
        Deprecated, for removal: This API element is subject to removal in a future version.  " + + "
        Deprecated, for removal: This API element is subject to removal in a future version. " + "enum_test3 passes.
        "); checkOutput("pkg/TestError.html", true, - "
        Deprecated, for removal: This API element is subject to removal in a future version.  \n" + "
        Deprecated, for removal: This API element is subject to removal in a future version. \n" + "
        error_test1 passes.
        \n" + "
        \n" + "
        \n" @@ -144,7 +144,7 @@ public class TestDeprecatedDocs extends JavadocTester { + "extends java.lang.Error"); checkOutput("pkg/TestException.html", true, - "
        Deprecated, for removal: This API element is subject to removal in a future version.  \n" + "
        Deprecated, for removal: This API element is subject to removal in a future version. \n" + "
        exception_test1 passes.
        \n" + "
        \n" + "
        \n" @@ -153,7 +153,7 @@ public class TestDeprecatedDocs extends JavadocTester { + "extends java.lang.Exception"); checkOutput("pkg/TestInterface.html", true, - "
        Deprecated, for removal: This API element is subject to removal in a future version.  \n" + "
        Deprecated, for removal: This API element is subject to removal in a future version. \n" + "
        interface_test1 passes.
        \n" + "
        \n" + "
        \n" diff --git a/langtools/test/jdk/javadoc/doclet/testModules/TestModules.java b/langtools/test/jdk/javadoc/doclet/testModules/TestModules.java index 4a148756b37..5c026ea57ea 100644 --- a/langtools/test/jdk/javadoc/doclet/testModules/TestModules.java +++ b/langtools/test/jdk/javadoc/doclet/testModules/TestModules.java @@ -24,7 +24,7 @@ /* * @test * @bug 8154119 8154262 8156077 8157987 8154261 8154817 8135291 8155995 8162363 - * 8168766 8168688 8162674 8160196 8175799 8174974 8176778 8177562 + * 8168766 8168688 8162674 8160196 8175799 8174974 8176778 8177562 8175218 * @summary Test modules support in javadoc. * @author bpatel * @library ../lib @@ -277,14 +277,14 @@ public class TestModules extends JavadocTester { + "\n" + "\n" + "
        This is a test description for the moduleA module. Search " - + "phrase search phrase.
        "); + + "phrase search phrase.
        "); checkOutput("moduleB-summary.html", found, "\n" + "\n" + "\n" + "\n" + "
        This is a test description for the moduleB module. Search " - + "word search_word with no description.
        "); + + "word search_word with no description.
        "); checkOutput("overview-summary.html", found, "\n" + "
        \n" @@ -325,7 +325,7 @@ public class TestModules extends JavadocTester { checkOutput("moduleA-summary.html", found, "
        \n" + "
        Deprecated, for removal:" - + " This API element is subject to removal in a future version. \n" + + " This API element is subject to removal in a future version.\n" + "
        This module is deprecated.
        \n" + "
        \n" + "\n" @@ -333,7 +333,7 @@ public class TestModules extends JavadocTester { + "\n" + "\n" + "
        This is a test description for the moduleA module. Search " - + "phrase search phrase.
        "); + + "phrase search phrase.
        "); checkOutput("moduleB-summary.html", found, "
        \n" + "\n" @@ -341,7 +341,7 @@ public class TestModules extends JavadocTester { + "\n" + "\n" + "
        This is a test description for the moduleB module. Search " - + "word search_word with no description.
        "); + + "word search_word with no description.
        "); checkOutput("overview-summary.html", found, "\n" + "\n" @@ -618,7 +618,7 @@ public class TestModules extends JavadocTester { + "

        Module moduleT

        \n" + "
        ", "
        This is a test description for the moduleT module. " - + "Search phrase search phrase. " + + "Search phrase search phrase. " + "Make sure there are no exported packages.
        ", "
        \n" + "\n" @@ -867,7 +867,7 @@ public class TestModules extends JavadocTester { void checkModuleDeprecation(boolean found) { checkOutput("moduleA-summary.html", found, "
        Deprecated, for removal:" - + " This API element is subject to removal in a future version. \n" + + " This API element is subject to removal in a future version.\n" + "
        This module is deprecated.
        \n" + "
        "); checkOutput("deprecated-list.html", found, diff --git a/langtools/test/jdk/javadoc/doclet/testSearch/TestSearch.java b/langtools/test/jdk/javadoc/doclet/testSearch/TestSearch.java index ccda7324d47..5be26d2e972 100644 --- a/langtools/test/jdk/javadoc/doclet/testSearch/TestSearch.java +++ b/langtools/test/jdk/javadoc/doclet/testSearch/TestSearch.java @@ -23,7 +23,7 @@ /* * @test - * @bug 8141492 8071982 8141636 8147890 8166175 8168965 8176794 + * @bug 8141492 8071982 8141636 8147890 8166175 8168965 8176794 8175218 * @summary Test the search feature of javadoc. * @author bpatel * @library ../lib @@ -321,9 +321,9 @@ public class TestSearch extends JavadocTester { + "pkg2.TestEnum"); checkOutput("index-all.html", true, "
        class_test1 passes. Search tag" - + " SearchTagDeprecatedClass
        ", + + " SearchTagDeprecatedClass", "
        error_test3 passes. Search tag for\n" - + " method SearchTagDeprecatedMethod
        "); + + " method SearchTagDeprecatedMethod"); } void checkSplitIndex() { diff --git a/langtools/test/jdk/javadoc/doclet/testStylesheet/TestStylesheet.java b/langtools/test/jdk/javadoc/doclet/testStylesheet/TestStylesheet.java index b5b9c373f02..f649f3b4f15 100644 --- a/langtools/test/jdk/javadoc/doclet/testStylesheet/TestStylesheet.java +++ b/langtools/test/jdk/javadoc/doclet/testStylesheet/TestStylesheet.java @@ -24,6 +24,7 @@ /* * @test * @bug 4494033 7028815 7052425 8007338 8023608 8008164 8016549 8072461 8154261 8162363 8160196 8151743 8177417 + * 8175218 * @summary Run tests on doclet stylesheet. * @author jamieh * @library ../lib @@ -162,6 +163,16 @@ public class TestStylesheet extends JavadocTester { "@import url('resources/fonts/dejavu.css');", ".navPadding {\n" + " padding-top: 107px;\n" + + "}", + "a[name]:before, a[name]:target, a[id]:before, a[id]:target {\n" + + " content:\"\";\n" + + " display:inline-block;\n" + + " position:relative;\n" + + " padding-top:129px;\n" + + " margin-top:-129px;\n" + + "}\n" + + ".searchTagResult:before, .searchTagResult:target {\n" + + " color:red;\n" + "}"); // Test whether a link to the stylesheet file is inserted properly From 06143df6a2a32985cd59baf569121cc4eec9a8d8 Mon Sep 17 00:00:00 2001 From: Srikanth Adayapalam Date: Wed, 5 Apr 2017 14:34:15 +0530 Subject: [PATCH 6/9] 8176572: Javac does not enforce module name restrictions Reviewed-by: jlahoda --- .../com/sun/tools/javac/comp/Check.java | 30 ++++++++++++++++--- .../tools/javac/resources/compiler.properties | 2 +- .../modules/PoorChoiceForModuleNameTest.java | 25 ++++++++++++++-- 3 files changed, 49 insertions(+), 8 deletions(-) diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java index 117da713ead..f8b9ee6761e 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java @@ -2107,10 +2107,32 @@ public class Check { Name moduleName = tree.sym.name; Assert.checkNonNull(moduleName); if (lint.isEnabled(LintCategory.MODULE)) { - String moduleNameString = moduleName.toString(); - int nameLength = moduleNameString.length(); - if (nameLength > 0 && Character.isDigit(moduleNameString.charAt(nameLength - 1))) { - log.warning(Lint.LintCategory.MODULE, tree.qualId.pos(), Warnings.PoorChoiceForModuleName(moduleName)); + JCExpression qualId = tree.qualId; + while (qualId != null) { + Name componentName; + DiagnosticPosition pos; + switch (qualId.getTag()) { + case SELECT: + JCFieldAccess selectNode = ((JCFieldAccess) qualId); + componentName = selectNode.name; + pos = selectNode.pos(); + qualId = selectNode.selected; + break; + case IDENT: + componentName = ((JCIdent) qualId).name; + pos = qualId.pos(); + qualId = null; + break; + default: + throw new AssertionError("Unexpected qualified identifier: " + qualId.toString()); + } + if (componentName != null) { + String moduleNameComponentString = componentName.toString(); + int nameLength = moduleNameComponentString.length(); + if (nameLength > 0 && Character.isDigit(moduleNameComponentString.charAt(nameLength - 1))) { + log.warning(Lint.LintCategory.MODULE, pos, Warnings.PoorChoiceForModuleName(componentName)); + } + } } } } diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties index 3a93a8ad874..f72baf51d57 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties @@ -1537,7 +1537,7 @@ compiler.warn.finally.cannot.complete=\ # 0: name compiler.warn.poor.choice.for.module.name=\ - module name {0} should avoid terminal digits + module name component {0} should avoid terminal digits # 0: string compiler.warn.incubating.modules=\ diff --git a/langtools/test/tools/javac/modules/PoorChoiceForModuleNameTest.java b/langtools/test/tools/javac/modules/PoorChoiceForModuleNameTest.java index 9bb8f15fa0c..cf9480c43d5 100644 --- a/langtools/test/tools/javac/modules/PoorChoiceForModuleNameTest.java +++ b/langtools/test/tools/javac/modules/PoorChoiceForModuleNameTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2017 Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,7 @@ /* * @test - * @bug 8160181 + * @bug 8160181 8176572 * @summary Add lint warning for digits in module names * @library /tools/lib * @modules @@ -63,6 +63,22 @@ public class PoorChoiceForModuleNameTest extends ModuleTestBase { Path src_m3 = src.resolve("mango100"); tb.writeJavaFiles(src_m3, "@SuppressWarnings(\"module\") module mango100 { }"); + // Check that there is no warning at use site. + Path src_m4 = src.resolve("mangouser"); + tb.writeJavaFiles(src_m4, "module mangouser { requires mango19; }"); + + // Check that we warn about component names ending in digit also + Path src_m5 = src.resolve("mango1000.mangofruit.mangomodule"); + tb.writeJavaFiles(src_m5, "module mango1000.mangofruit.mangomodule { }"); + + // Check that we warn about component names ending in digit also + Path src_m6 = src.resolve("mangofruit.mango1000.mangomodule"); + tb.writeJavaFiles(src_m6, "module mangofruit.mango1000.mangomodule { }"); + + // Check that we warn about component names ending in digit also + Path src_m7 = src.resolve("mangomodule.mangofruit.mango1000"); + tb.writeJavaFiles(src_m7, "module mangomodule.mangofruit.mango1000 { }"); + Path classes = base.resolve("classes"); tb.createDirectories(classes); @@ -78,9 +94,12 @@ public class PoorChoiceForModuleNameTest extends ModuleTestBase { .getOutput(Task.OutputKind.DIRECT); if (!log.contains("module-info.java:1:8: compiler.warn.poor.choice.for.module.name: mango19") || + !log.contains("module-info.java:1:8: compiler.warn.poor.choice.for.module.name: mango1000") || + !log.contains("module-info.java:1:18: compiler.warn.poor.choice.for.module.name: mango1000") || + !log.contains("module-info.java:1:30: compiler.warn.poor.choice.for.module.name: mango1000") || !log.contains("- compiler.err.warnings.and.werror") || !log.contains("1 error") || - !log.contains("1 warning")) + !log.contains("4 warning")) throw new Exception("expected output not found: " + log); } } From 64d37b0a69b5739b198a69b97cc7c26d55a1edb2 Mon Sep 17 00:00:00 2001 From: Jan Lahoda Date: Thu, 6 Apr 2017 11:55:58 +0200 Subject: [PATCH 7/9] 8178013: Finetuning of merged tab and shift tab completion Fixing mistakes in localization bundle, fixing completion after /help set. Reviewed-by: rfield --- .../classes/jdk/internal/jshell/tool/JShellTool.java | 4 ++-- .../jdk/internal/jshell/tool/resources/l10n.properties | 8 ++++---- langtools/test/jdk/jshell/CommandCompletionTest.java | 6 ++++-- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java index 6d6e3855d3c..1c4283d600b 100644 --- a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java +++ b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 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 @@ -1440,7 +1440,7 @@ public class JShellTool implements MessageHandler { : c.command) + " ") .toArray(String[]::new)) .completionSuggestions(code, cursor, anchor); - } else if (code.startsWith("/se")) { + } else if (code.startsWith("/se") || code.startsWith("se")) { result = new FixedCompletionProvider(SET_SUBCOMMANDS) .completionSuggestions(code.substring(pastSpace), cursor - pastSpace, anchor); } else { diff --git a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/resources/l10n.properties b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/resources/l10n.properties index 76a309539df..734b2805fd3 100644 --- a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/resources/l10n.properties +++ b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/resources/l10n.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -500,11 +500,11 @@ Supported shortcuts include:\n\ Shift- v\n\t\t\ After a complete expression, hold down while pressing ,\n\t\t\ then release and press "v", the expression will be converted to\n\t\t\ - a variable declaration whose type is based on the type of the expression.\n\t\t\ + a variable declaration whose type is based on the type of the expression.\n\n\ Shift- i\n\t\t\ After an unresolvable identifier, hold down while pressing ,\n\t\t\ then release and press "i", and jshell will propose possible imports\n\t\t\ - which will resolve the identifier based on the content of the specified classpath.\n\t\t\ + which will resolve the identifier based on the content of the specified classpath. help.context.summary = the evaluation context options for /env /reload and /reset help.context =\ @@ -928,5 +928,5 @@ startup.feedback = \ /set format silent display '' \n jshell.fix.wrong.shortcut =\ -Invalid character. Use "i" for auto-import or "v" for variable creation. For more information see:\n\ +Unexpected character after Shift-Tab. Use "i" for auto-import or "v" for variable creation. For more information see:\n\ /help shortcuts diff --git a/langtools/test/jdk/jshell/CommandCompletionTest.java b/langtools/test/jdk/jshell/CommandCompletionTest.java index 83e0f78a63e..4424604fc23 100644 --- a/langtools/test/jdk/jshell/CommandCompletionTest.java +++ b/langtools/test/jdk/jshell/CommandCompletionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -23,7 +23,7 @@ /* * @test - * @bug 8144095 8164825 8169818 8153402 8165405 8177079 + * @bug 8144095 8164825 8169818 8153402 8165405 8177079 8178013 * @summary Test Command Completion * @modules jdk.compiler/com.sun.tools.javac.api * jdk.compiler/com.sun.tools.javac.main @@ -173,6 +173,8 @@ public class CommandCompletionTest extends ReplToolTesting { "/save ", "/set "), a -> assertCompletion(a, "/help /set |", false, "editor", "feedback", "format", "mode", "prompt", "start", "truncation"), + a -> assertCompletion(a, "/help set |", false, + "editor", "feedback", "format", "mode", "prompt", "start", "truncation"), a -> assertCompletion(a, "/help /edit |", false), a -> assertCompletion(a, "/help dr|", false, "drop ") From 9bb53e41931b2f3f58a75030a2265ec83bcd9e49 Mon Sep 17 00:00:00 2001 From: Jan Lahoda Date: Thu, 6 Apr 2017 16:19:33 +0200 Subject: [PATCH 8/9] 8178077: jshell tool: crash on ctrl-up or ctrl-down Adding a test for EditingHistory. Reviewed-by: rfield --- langtools/test/jdk/jshell/HistoryUITest.java | 83 ++++++ .../jdk/jshell/MergedTabShiftTabTest.java | 224 +-------------- langtools/test/jdk/jshell/UITesting.java | 272 ++++++++++++++++++ 3 files changed, 357 insertions(+), 222 deletions(-) create mode 100644 langtools/test/jdk/jshell/HistoryUITest.java create mode 100644 langtools/test/jdk/jshell/UITesting.java diff --git a/langtools/test/jdk/jshell/HistoryUITest.java b/langtools/test/jdk/jshell/HistoryUITest.java new file mode 100644 index 00000000000..3e6f52a0abd --- /dev/null +++ b/langtools/test/jdk/jshell/HistoryUITest.java @@ -0,0 +1,83 @@ +/* + * Copyright (c) 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. + * + * 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. + */ + +/** + * @test + * @bug 8178077 + * @summary Check the UI behavior of editing history. + * @modules + * jdk.compiler/com.sun.tools.javac.api + * jdk.compiler/com.sun.tools.javac.main + * jdk.jshell/jdk.jshell:open + * @library /tools/lib + * @build toolbox.ToolBox toolbox.JarTask toolbox.JavacTask + * @build Compiler UITesting + * @build HistoryUITest + * @run testng HistoryUITest + */ + +import org.testng.annotations.Test; + +@Test +public class HistoryUITest extends UITesting { + + public void testPrevNextSnippet() throws Exception { + doRunTest((inputSink, out) -> { + inputSink.write("void test1() {\nSystem.err.println(1);\n}\n"); + waitOutput(out, "\u0005"); + inputSink.write("void test2() {\nSystem.err.println(2);\n}\n"); + waitOutput(out, "\u0005"); + inputSink.write(CTRL_UP); + waitOutput(out, "^void test2\\(\\) \\{"); + inputSink.write(CTRL_UP); + waitOutput(out, "^" + clearOut("2() {") + "1\\(\\) \\{"); + inputSink.write(CTRL_DOWN); + waitOutput(out, "^" + clearOut("1() {") + "2\\(\\) \\{"); + inputSink.write(ENTER); + waitOutput(out, "^\n\u0006"); + inputSink.write(UP); + waitOutput(out, "^}"); + inputSink.write(UP); + waitOutput(out, "^" + clearOut("}") + "System.err.println\\(2\\);"); + inputSink.write(UP); + waitOutput(out, "^" + clearOut("System.err.println(2);") + "void test2\\(\\) \\{"); + inputSink.write(UP); + waitOutput(out, "^\u0007"); + inputSink.write(DOWN); + waitOutput(out, "^" + clearOut("void test2() {") + "System.err.println\\(2\\);"); + inputSink.write(DOWN); + waitOutput(out, "^" + clearOut("System.err.println(2);") + "}"); + inputSink.write(DOWN); + waitOutput(out, "^" + clearOut("}")); + inputSink.write(DOWN); + waitOutput(out, "^\u0007"); + }); + } + //where: + private static final String CTRL_UP = "\033[1;5A"; + private static final String CTRL_DOWN = "\033[1;5B"; + private static final String UP = "\033[A"; + private static final String DOWN = "\033[B"; + private static final String ENTER = "\n"; + +} diff --git a/langtools/test/jdk/jshell/MergedTabShiftTabTest.java b/langtools/test/jdk/jshell/MergedTabShiftTabTest.java index 73305051869..0ff1aea6633 100644 --- a/langtools/test/jdk/jshell/MergedTabShiftTabTest.java +++ b/langtools/test/jdk/jshell/MergedTabShiftTabTest.java @@ -31,37 +31,29 @@ * jdk.jshell/jdk.jshell:open * @library /tools/lib * @build toolbox.ToolBox toolbox.JarTask toolbox.JavacTask - * @build Compiler + * @build Compiler UITesting * @build MergedTabShiftTabTest * @run testng MergedTabShiftTabTest */ import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.OutputStreamWriter; -import java.io.PrintStream; -import java.io.Writer; import java.lang.reflect.Field; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.text.MessageFormat; import java.util.Arrays; -import java.util.HashMap; import java.util.Locale; import java.util.ResourceBundle; import java.util.jar.JarEntry; import java.util.jar.JarOutputStream; -import java.util.regex.Matcher; import java.util.regex.Pattern; import jdk.jshell.JShell; -import jdk.jshell.tool.JavaShellToolBuilder; import org.testng.annotations.Test; @Test -public class MergedTabShiftTabTest { +public class MergedTabShiftTabTest extends UITesting { public void testCommand() throws Exception { doRunTest((inputSink, out) -> { @@ -281,60 +273,6 @@ public class MergedTabShiftTabTest { }); } - private void doRunTest(Test test) throws Exception { - PipeInputStream input = new PipeInputStream(); - StringBuilder out = new StringBuilder(); - PrintStream outS = new PrintStream(new OutputStream() { - @Override public void write(int b) throws IOException { - synchronized (out) { - System.out.print((char) b); - out.append((char) b); - out.notifyAll(); - } - } - }); - Thread runner = new Thread(() -> { - try { - JavaShellToolBuilder.builder() - .in(input, input) - .out(outS) - .err(outS) - .promptCapture(true) - .persistence(new HashMap<>()) - .locale(Locale.US) - .run("--no-startup"); - } catch (Exception ex) { - throw new IllegalStateException(ex); - } - }); - - Writer inputSink = new OutputStreamWriter(input.createOutput()) { - @Override - public void write(String str) throws IOException { - super.write(str); - flush(); - } - }; - - runner.start(); - - try { - waitOutput(out, "\u0005"); - test.test(inputSink, out); - } finally { - inputSink.write("\003\003/exit"); - - runner.join(1000); - if (runner.isAlive()) { - runner.stop(); - } - } - } - - interface Test { - public void test(Writer inputSink, StringBuilder out) throws Exception; - } - private Path prepareZip() { String clazz1 = "package jshelltest;\n" + @@ -404,162 +342,4 @@ public class MergedTabShiftTabTest { return MessageFormat.format(resources.getString(key), args); } - private static final long TIMEOUT; - - static { - long factor; - - try { - factor = (long) Double.parseDouble(System.getProperty("test.timeout.factor", "1")); - } catch (NumberFormatException ex) { - factor = 1; - } - TIMEOUT = 60_000 * factor; - } - - private void waitOutput(StringBuilder out, String expected) { - expected = expected.replaceAll("\n", System.getProperty("line.separator")); - Pattern expectedPattern = Pattern.compile(expected, Pattern.DOTALL); - synchronized (out) { - long s = System.currentTimeMillis(); - - while (true) { - Matcher m = expectedPattern.matcher(out); - if (m.find()) { - out.delete(0, m.end() + 1); - return ; - } - long e = System.currentTimeMillis(); - if ((e - s) > TIMEOUT) { - throw new IllegalStateException("Timeout waiting for: " + quote(expected) + ", actual output so far: " + quote(out.toString())); - } - try { - out.wait(TIMEOUT); - } catch (InterruptedException ex) { - ex.printStackTrace(); - } - } - } - } - - private String quote(String original) { - StringBuilder output = new StringBuilder(); - - for (char c : original.toCharArray()) { - if (c < 32) { - output.append(String.format("\\u%04X", (int) c)); - } else { - output.append(c); - } - } - - return output.toString(); - } - - private static class PipeInputStream extends InputStream { - - private static final int INITIAL_SIZE = 128; - private int[] buffer = new int[INITIAL_SIZE]; - private int start; - private int end; - private boolean closed; - - @Override - public synchronized int read() throws IOException { - if (start == end && !closed) { - inputNeeded(); - } - while (start == end) { - if (closed) { - return -1; - } - try { - wait(); - } catch (InterruptedException ex) { - //ignore - } - } - try { - return buffer[start]; - } finally { - start = (start + 1) % buffer.length; - } - } - - @Override - public synchronized int read(byte[] b, int off, int len) throws IOException { - if (b == null) { - throw new NullPointerException(); - } else if (off < 0 || len < 0 || len > b.length - off) { - throw new IndexOutOfBoundsException(); - } else if (len == 0) { - return 0; - } - - int c = read(); - if (c == -1) { - return -1; - } - b[off] = (byte)c; - - int totalRead = 1; - while (totalRead < len && start != end) { - int r = read(); - if (r == (-1)) - break; - b[off + totalRead++] = (byte) r; - } - return totalRead; - } - - protected void inputNeeded() throws IOException {} - - private synchronized void write(int b) { - if (closed) { - throw new IllegalStateException("Already closed."); - } - int newEnd = (end + 1) % buffer.length; - if (newEnd == start) { - //overflow: - int[] newBuffer = new int[buffer.length * 2]; - int rightPart = (end > start ? end : buffer.length) - start; - int leftPart = end > start ? 0 : start - 1; - System.arraycopy(buffer, start, newBuffer, 0, rightPart); - System.arraycopy(buffer, 0, newBuffer, rightPart, leftPart); - buffer = newBuffer; - start = 0; - end = rightPart + leftPart; - newEnd = end + 1; - } - buffer[end] = b; - end = newEnd; - notifyAll(); - } - - @Override - public synchronized void close() { - closed = true; - notifyAll(); - } - - public OutputStream createOutput() { - return new OutputStream() { - @Override public void write(int b) throws IOException { - PipeInputStream.this.write(b); - } - @Override - public void write(byte[] b, int off, int len) throws IOException { - for (int i = 0 ; i < len ; i++) { - write(Byte.toUnsignedInt(b[off + i])); - } - } - @Override - public void close() throws IOException { - PipeInputStream.this.close(); - } - }; - } - - } - } diff --git a/langtools/test/jdk/jshell/UITesting.java b/langtools/test/jdk/jshell/UITesting.java new file mode 100644 index 00000000000..fffd54dfc37 --- /dev/null +++ b/langtools/test/jdk/jshell/UITesting.java @@ -0,0 +1,272 @@ +/* + * Copyright (c) 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. + * + * 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. + */ + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.io.PrintStream; +import java.io.Writer; +import java.util.HashMap; +import java.util.Locale; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import jdk.jshell.tool.JavaShellToolBuilder; + +public class UITesting { + + protected void doRunTest(Test test) throws Exception { + PipeInputStream input = new PipeInputStream(); + StringBuilder out = new StringBuilder(); + PrintStream outS = new PrintStream(new OutputStream() { + @Override public void write(int b) throws IOException { + synchronized (out) { + System.out.print((char) b); + out.append((char) b); + out.notifyAll(); + } + } + }); + Thread runner = new Thread(() -> { + try { + JavaShellToolBuilder.builder() + .in(input, input) + .out(outS) + .err(outS) + .promptCapture(true) + .persistence(new HashMap<>()) + .locale(Locale.US) + .run("--no-startup"); + } catch (Exception ex) { + throw new IllegalStateException(ex); + } + }); + + Writer inputSink = new OutputStreamWriter(input.createOutput()) { + @Override + public void write(String str) throws IOException { + super.write(str); + flush(); + } + }; + + runner.start(); + + try { + waitOutput(out, "\u0005"); + test.test(inputSink, out); + } finally { + inputSink.write("\003\003/exit"); + + runner.join(1000); + if (runner.isAlive()) { + runner.stop(); + } + } + } + + protected interface Test { + public void test(Writer inputSink, StringBuilder out) throws Exception; + } + + private static final long TIMEOUT; + + static { + long factor; + + try { + factor = (long) Double.parseDouble(System.getProperty("test.timeout.factor", "1")); + } catch (NumberFormatException ex) { + factor = 1; + } + TIMEOUT = 60_000 * factor; + } + + protected void waitOutput(StringBuilder out, String expected) { + expected = expected.replaceAll("\n", System.getProperty("line.separator")); + Pattern expectedPattern = Pattern.compile(expected, Pattern.DOTALL); + synchronized (out) { + long s = System.currentTimeMillis(); + + while (true) { + Matcher m = expectedPattern.matcher(out); + if (m.find()) { + out.delete(0, m.end() + 1); + return ; + } + long e = System.currentTimeMillis(); + if ((e - s) > TIMEOUT) { + throw new IllegalStateException("Timeout waiting for: " + quote(expected) + ", actual output so far: " + quote(out.toString())); + } + try { + out.wait(TIMEOUT); + } catch (InterruptedException ex) { + ex.printStackTrace(); + } + } + } + } + + private String quote(String original) { + StringBuilder output = new StringBuilder(); + + for (char c : original.toCharArray()) { + if (c < 32) { + output.append(String.format("\\u%04X", (int) c)); + } else { + output.append(c); + } + } + + return output.toString(); + } + + protected String clearOut(String what) { + return backspace(what.length()) + space(what.length()) + backspace(what.length()); + } + + protected String backspace(int n) { + return fill(n, '\010'); + } + + protected String space(int n) { + return fill(n, ' '); + } + + private String fill(int n, char c) { + StringBuilder result = new StringBuilder(n); + + while (n-- > 0) + result.append(c); + + return result.toString(); + } + + private static class PipeInputStream extends InputStream { + + private static final int INITIAL_SIZE = 128; + private int[] buffer = new int[INITIAL_SIZE]; + private int start; + private int end; + private boolean closed; + + @Override + public synchronized int read() throws IOException { + if (start == end && !closed) { + inputNeeded(); + } + while (start == end) { + if (closed) { + return -1; + } + try { + wait(); + } catch (InterruptedException ex) { + //ignore + } + } + try { + return buffer[start]; + } finally { + start = (start + 1) % buffer.length; + } + } + + @Override + public synchronized int read(byte[] b, int off, int len) throws IOException { + if (b == null) { + throw new NullPointerException(); + } else if (off < 0 || len < 0 || len > b.length - off) { + throw new IndexOutOfBoundsException(); + } else if (len == 0) { + return 0; + } + + int c = read(); + if (c == -1) { + return -1; + } + b[off] = (byte)c; + + int totalRead = 1; + while (totalRead < len && start != end) { + int r = read(); + if (r == (-1)) + break; + b[off + totalRead++] = (byte) r; + } + return totalRead; + } + + protected void inputNeeded() throws IOException {} + + private synchronized void write(int b) { + if (closed) { + throw new IllegalStateException("Already closed."); + } + int newEnd = (end + 1) % buffer.length; + if (newEnd == start) { + //overflow: + int[] newBuffer = new int[buffer.length * 2]; + int rightPart = (end > start ? end : buffer.length) - start; + int leftPart = end > start ? 0 : start - 1; + System.arraycopy(buffer, start, newBuffer, 0, rightPart); + System.arraycopy(buffer, 0, newBuffer, rightPart, leftPart); + buffer = newBuffer; + start = 0; + end = rightPart + leftPart; + newEnd = end + 1; + } + buffer[end] = b; + end = newEnd; + notifyAll(); + } + + @Override + public synchronized void close() { + closed = true; + notifyAll(); + } + + public OutputStream createOutput() { + return new OutputStream() { + @Override public void write(int b) throws IOException { + PipeInputStream.this.write(b); + } + @Override + public void write(byte[] b, int off, int len) throws IOException { + for (int i = 0 ; i < len ; i++) { + write(Byte.toUnsignedInt(b[off + i])); + } + } + @Override + public void close() throws IOException { + PipeInputStream.this.close(); + } + }; + } + + } + +} From 999a830a40287c74c2f1d3d656955261617d1ade Mon Sep 17 00:00:00 2001 From: Maurizio Cimadamore Date: Thu, 6 Apr 2017 17:27:52 +0100 Subject: [PATCH 9/9] 8177933: Stackoverflow during compilation, starting jdk-9+163 Avoid extra method call in Attr.attribTree Reviewed-by: vromero --- .../sun/tools/javac/comp/ArgumentAttr.java | 11 +-- .../com/sun/tools/javac/comp/Attr.java | 19 ++-- .../javac/lambda/speculative/T8177933.java | 89 +++++++++++++++++++ 3 files changed, 105 insertions(+), 14 deletions(-) create mode 100644 langtools/test/tools/javac/lambda/speculative/T8177933.java diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/ArgumentAttr.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/ArgumentAttr.java index d99bc73567a..eb8311d7f2c 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/ArgumentAttr.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/ArgumentAttr.java @@ -105,7 +105,7 @@ public class ArgumentAttr extends JCTree.Visitor { private Env env; /** Result of method attribution. */ - private Type result; + Type result; /** Cache for argument types; behavior is influences by the currrently selected cache policy. */ Map> argumentTypeCache = new LinkedHashMap<>(); @@ -215,13 +215,8 @@ public class ArgumentAttr extends JCTree.Visitor { processArg(that, () -> { T speculativeTree = (T)deferredAttr.attribSpeculative(that, env, attr.new MethodAttrInfo() { @Override - protected void attr(JCTree tree, Env env) { - //avoid speculative attribution loops - if (!new UniquePos(tree).equals(pos)) { - super.attr(tree, env); - } else { - visitTree(tree); - } + protected boolean needsArgumentAttr(JCTree tree) { + return !new UniquePos(tree).equals(pos); } }); return argumentTypeFactory.apply(speculativeTree); diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java index 4f47a589113..9ff0df058fd 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java @@ -505,9 +505,12 @@ public class Attr extends JCTree.Visitor { this.checkMode = checkMode; } - protected void attr(JCTree tree, Env env) { - tree.accept(Attr.this); - } + /** + * Should {@link Attr#attribTree} use the {@ArgumentAttr} visitor instead of this one? + * @param tree The tree to be type-checked. + * @return true if {@ArgumentAttr} should be used. + */ + protected boolean needsArgumentAttr(JCTree tree) { return false; } protected Type check(final DiagnosticPosition pos, final Type found) { return chk.checkType(pos, found, pt, checkContext); @@ -553,8 +556,8 @@ public class Attr extends JCTree.Visitor { } @Override - protected void attr(JCTree tree, Env env) { - result = argumentAttr.attribArg(tree, env); + protected boolean needsArgumentAttr(JCTree tree) { + return true; } protected ResultInfo dup(Type newPt) { @@ -644,7 +647,11 @@ public class Attr extends JCTree.Visitor { try { this.env = env; this.resultInfo = resultInfo; - resultInfo.attr(tree, env); + if (resultInfo.needsArgumentAttr(tree)) { + result = argumentAttr.attribArg(tree, env); + } else { + tree.accept(this); + } if (tree == breakTree && resultInfo.checkContext.deferredAttrContext().mode == AttrMode.CHECK) { throw new BreakAttr(copyEnv(env)); diff --git a/langtools/test/tools/javac/lambda/speculative/T8177933.java b/langtools/test/tools/javac/lambda/speculative/T8177933.java new file mode 100644 index 00000000000..2487f7bb1c4 --- /dev/null +++ b/langtools/test/tools/javac/lambda/speculative/T8177933.java @@ -0,0 +1,89 @@ +/* + * Copyright (c) 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. + */ + +/* + * @test + * @bug 8177933 + * @summary Stackoverflow during compilation, starting jdk-9+163 + * + * @library /tools/javac/lib + * @modules jdk.compiler/com.sun.tools.javac.api + * jdk.compiler/com.sun.tools.javac.code + * jdk.compiler/com.sun.tools.javac.comp + * jdk.compiler/com.sun.tools.javac.main + * jdk.compiler/com.sun.tools.javac.tree + * jdk.compiler/com.sun.tools.javac.util + * @build combo.ComboTestHelper + + * @run main/othervm -Xss512K T8177933 + */ + +import combo.ComboInstance; +import combo.ComboParameter; +import combo.ComboTask.Result; +import combo.ComboTestHelper; + +import javax.lang.model.element.Element; + +public class T8177933 extends ComboInstance { + + static final int MAX_DEPTH = 350; + + static class CallExpr implements ComboParameter { + @Override + public String expand(String optParameter) { + Integer n = Integer.parseInt(optParameter); + if (n == MAX_DEPTH) { + return "m()"; + } else { + return "m().#{CALL." + (n + 1) + "}"; + } + } + } + + static final String sourceTemplate = + "class Test {\n" + + " Test m() { return null; }\n" + + " void test() {\n" + + " #{CALL.0};\n" + + "} }\n"; + + public static void main(String[] args) { + new ComboTestHelper() + .withDimension("CALL", new CallExpr()) + .run(T8177933::new); + } + + @Override + protected void doWork() throws Throwable { + Result> result = newCompilationTask() + .withOption("-XDdev") + .withSourceFromTemplate(sourceTemplate) + .analyze(); + if (!result.get().iterator().hasNext()) { + fail("Exception occurred when compiling combo. " + result.compilationInfo()); + } + } +}
        Opened Packages Opens 
        PackageDescriptionAll Modules 
        All Packages " - + "Exported Packages" + + "Exports" + " " - + "Concealed Packages 
        concealedpkgmdlANone  
        (Implementation(s): TestClassInModuleB)
        All Packages " - + "Exported Packages " - + "Opened Packages Exported Packages Exports 
        PackageModule" + + "PublicChild​()private " + + "PrivateParent​(int i)" + + "