From ae39310243b0486f5a6f1049c6ec5f29db31170c Mon Sep 17 00:00:00 2001 From: Naoto Sato Date: Thu, 6 Feb 2020 10:10:54 -0800 Subject: [PATCH 01/29] 8238605: Correct the CLDR version number in cldr.md files Reviewed-by: joehw, alanb --- src/java.base/share/legal/cldr.md | 2 +- src/jdk.localedata/share/legal/cldr.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/java.base/share/legal/cldr.md b/src/java.base/share/legal/cldr.md index 7e07378f2c1..fba90f6e9d4 100644 --- a/src/java.base/share/legal/cldr.md +++ b/src/java.base/share/legal/cldr.md @@ -1,4 +1,4 @@ -## Unicode Common Local Data Repository (CLDR) v35.1 +## Unicode Common Local Data Repository (CLDR) v36 ### CLDR License diff --git a/src/jdk.localedata/share/legal/cldr.md b/src/jdk.localedata/share/legal/cldr.md index 7e07378f2c1..fba90f6e9d4 100644 --- a/src/jdk.localedata/share/legal/cldr.md +++ b/src/jdk.localedata/share/legal/cldr.md @@ -1,4 +1,4 @@ -## Unicode Common Local Data Repository (CLDR) v35.1 +## Unicode Common Local Data Repository (CLDR) v36 ### CLDR License From 5ed4b9f2c0a1572da09fef84aaf0ce899689c4c2 Mon Sep 17 00:00:00 2001 From: Jesper Wilhelmsson Date: Fri, 7 Feb 2020 00:17:01 +0100 Subject: [PATCH 02/29] Added tag jdk-14+36 for changeset bc54620a3848 --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index 96c22bf7a44..a0c6d841593 100644 --- a/.hgtags +++ b/.hgtags @@ -610,3 +610,4 @@ decd3d2953b640f1043ee76953ff89238bff92e8 jdk-14+31 f728b6c7f4910d6bd6070cb4dde8393f4ba95113 jdk-14+33 a96bc204e3b31ddbf909b20088964112f052927e jdk-14+34 4a87bb7ebfd7f6a25ec59a5982fe3607242777f8 jdk-14+35 +bc54620a3848c26cff9766e5e2a6e5ddab98ed18 jdk-14+36 From 214edaf9c200c0614d841054c5040702c7cb76b6 Mon Sep 17 00:00:00 2001 From: Mikhailo Seledtsov Date: Fri, 7 Feb 2020 13:04:00 -0800 Subject: [PATCH 03/29] 8219999: TestJFREvents container test should not use jdk.CPUInformation event for container CPU values Updated the testcase not to test jdk.CPUInformation Reviewed-by: egahlin --- .../containers/docker/TestJFREvents.java | 29 ++++++++++--------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/test/hotspot/jtreg/containers/docker/TestJFREvents.java b/test/hotspot/jtreg/containers/docker/TestJFREvents.java index 0b30e66b20f..6b27ee03baf 100644 --- a/test/hotspot/jtreg/containers/docker/TestJFREvents.java +++ b/test/hotspot/jtreg/containers/docker/TestJFREvents.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2020, 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 @@ -60,11 +60,6 @@ public class TestJFREvents { DockerTestUtils.buildJdkDockerImage(imageName, "Dockerfile-BasicTest", "jdk-docker"); try { - // leave one CPU for system and tools, otherwise this test may be unstable - int maxNrOfAvailableCpus = availableCPUs - 1; - for (int i=1; i < maxNrOfAvailableCpus; i = i * 2) { - testCPUInfo(i, i); - } long MB = 1024*1024; testMemory("200m", "" + 200*MB); @@ -79,18 +74,26 @@ public class TestJFREvents { } } + // This test case is currently not in use. + // Once new Container events are available, this test case can be used to test + // processor-related configuration such as active processor count (see JDK-8203359). + private static void cpuTestCase() throws Exception { + // leave one CPU for system and tools, otherwise this test may be unstable + int maxNrOfAvailableCpus = availableCPUs - 1; + for (int i=1; i < maxNrOfAvailableCpus; i = i * 2) { + testCPUInfo("jdk.ContainerConfiguration", i, i); + } + } - private static void testCPUInfo(int valueToSet, int expectedValue) throws Exception { + private static void testCPUInfo(String eventName, int valueToSet, int expectedValue) throws Exception { Common.logNewTestCase("CPUInfo: --cpus = " + valueToSet); + String fieldName = "activeProcessorCount"; DockerTestUtils.dockerRunJava( commonDockerOpts() .addDockerOpts("--cpus=" + valueToSet) - .addClassOptions("jdk.CPUInformation")) - .shouldHaveExitValue(0); - // The following assertion is currently disabled due to JFR reporting incorrect values. - // JFR reports values for the host system as opposed to values for the container. - // @ignore 8219999 - // .shouldContain("cores = " + expectedValue"); + .addClassOptions(eventName)) + .shouldHaveExitValue(0) + .shouldContain(fieldName + " = " + expectedValue); } From c33107053b6bd22e16a86d25d414a92b496348ed Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Fri, 7 Feb 2020 16:16:01 -0800 Subject: [PATCH 04/29] 8238648: Rename and simplify Utils.WeakSoftHashMap Reviewed-by: hannesw --- .../internal/doclets/toolkit/util/Utils.java | 135 +++++++----------- 1 file changed, 48 insertions(+), 87 deletions(-) diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Utils.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Utils.java index d2aa865035f..3ee748dfa26 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Utils.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Utils.java @@ -32,9 +32,28 @@ import java.text.CollationKey; import java.text.Collator; import java.text.ParseException; import java.text.RuleBasedCollator; -import java.util.*; -import java.util.AbstractMap.SimpleEntry; +import java.util.ArrayDeque; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.Comparator; +import java.util.Deque; +import java.util.EnumSet; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Locale; +import java.util.Map; import java.util.Map.Entry; +import java.util.Objects; +import java.util.Set; +import java.util.SortedSet; +import java.util.TreeMap; +import java.util.TreeSet; import java.util.function.Predicate; import java.util.stream.Collectors; @@ -937,7 +956,7 @@ public class Utils { * @return */ public TypeMirror getDeclaredType(Collection values, - TypeElement enclosing, TypeMirror target) { + TypeElement enclosing, TypeMirror target) { TypeElement targetElement = asTypeElement(target); List targetTypeArgs = targetElement.getTypeParameters(); if (targetTypeArgs.isEmpty()) { @@ -2546,7 +2565,7 @@ public class Utils { }.visit(e); } - EnumSet nestedKinds = EnumSet.of(ANNOTATION_TYPE, CLASS, ENUM, INTERFACE); + Set nestedKinds = EnumSet.of(ANNOTATION_TYPE, CLASS, ENUM, INTERFACE); void recursiveGetItems(Collection list, Element e, boolean filter, ElementKind... select) { list.addAll(getItems0(e, filter, select)); List classes = getItems0(e, filter, nestedKinds); @@ -2559,7 +2578,7 @@ public class Utils { } private List getItems0(Element te, boolean filter, ElementKind... select) { - EnumSet kinds = EnumSet.copyOf(Arrays.asList(select)); + Set kinds = EnumSet.copyOf(Arrays.asList(select)); return getItems0(te, filter, kinds); } @@ -3002,14 +3021,14 @@ public class Utils { return doctree.getKind() == match; } - private final WeakSoftHashMap wksMap = new WeakSoftHashMap(this); + private final CommentHelperCache commentHelperCache = new CommentHelperCache(this); public CommentHelper getCommentHelper(Element element) { - return wksMap.computeIfAbsent(element); + return commentHelperCache.computeIfAbsent(element); } public void removeCommentHelper(Element element) { - wksMap.remove(element); + commentHelperCache.remove(element); } public List getBlockTags(Element element) { @@ -3177,13 +3196,13 @@ public class Utils { } public DocCommentTree getDocCommentTree(Element element) { - CommentHelper ch = wksMap.get(element); + CommentHelper ch = commentHelperCache.get(element); if (ch != null) { return ch.dctree; } DocCommentTree dcTree = getDocCommentTree0(element); if (dcTree != null) { - wksMap.put(element, new CommentHelper(configuration, element, getTreePath(element), dcTree)); + commentHelperCache.put(element, new CommentHelper(configuration, element, getTreePath(element), dcTree)); } return dcTree; } @@ -3297,106 +3316,48 @@ public class Utils { return outer; } - static class WeakSoftHashMap implements Map { + /** + * A memory-sensitive cache for {@link CommentHelper} objects, + * which are expensive to compute. + */ + private static class CommentHelperCache { - private final WeakHashMap> wkMap; + private final Map> map; private final Utils utils; - public WeakSoftHashMap(Utils utils) { - wkMap = new WeakHashMap<>(); + + public CommentHelperCache(Utils utils) { + map = new HashMap<>(); this.utils = utils; } - @Override - public boolean containsKey(Object key) { - return wkMap.containsKey(key); - } - - @Override - public Collection values() { - Set out = new LinkedHashSet<>(); - for (SoftReference v : wkMap.values()) { - out.add(v.get()); - } - return out; - } - - @Override - public boolean containsValue(Object value) { - return wkMap.containsValue(new SoftReference<>((CommentHelper)value)); - } - - @Override - public CommentHelper remove(Object key) { - SoftReference value = wkMap.remove(key); + public CommentHelper remove(Element key) { + SoftReference value = map.remove(key); return value == null ? null : value.get(); } - - @Override public CommentHelper put(Element key, CommentHelper value) { - SoftReference nvalue = wkMap.put(key, new SoftReference<>(value)); - return nvalue == null ? null : nvalue.get(); + SoftReference prev = map.put(key, new SoftReference<>(value)); + return prev == null ? null : prev.get(); } - @Override public CommentHelper get(Object key) { - SoftReference value = wkMap.get(key); + SoftReference value = map.get(key); return value == null ? null : value.get(); } - @Override - public int size() { - return wkMap.size(); - } - - @Override - public boolean isEmpty() { - return wkMap.isEmpty(); - } - - @Override - public void clear() { - wkMap.clear(); - } - public CommentHelper computeIfAbsent(Element key) { - if (wkMap.containsKey(key)) { - SoftReference value = wkMap.get(key); + SoftReference refValue = map.get(key); + if (refValue != null) { + CommentHelper value = refValue.get(); if (value != null) { - CommentHelper cvalue = value.get(); - if (cvalue != null) { - return cvalue; - } + return value; } } CommentHelper newValue = new CommentHelper(utils.configuration, key, utils.getTreePath(key), utils.getDocCommentTree(key)); - wkMap.put(key, new SoftReference<>(newValue)); + map.put(key, new SoftReference<>(newValue)); return newValue; } - - - @Override - public void putAll(Map map) { - for (Map.Entry entry : map.entrySet()) { - put(entry.getKey(), entry.getValue()); - } - } - - @Override - public Set keySet() { - return wkMap.keySet(); - } - - @Override - public Set> entrySet() { - Set> out = new LinkedHashSet<>(); - for (Element e : wkMap.keySet()) { - SimpleEntry n = new SimpleEntry<>(e, get(e)); - out.add(n); - } - return out; - } } /** From faa88c1da68a94c520f947832614ef5816f43c9f Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Fri, 7 Feb 2020 16:43:09 -0800 Subject: [PATCH 05/29] 8238506: fix obsolete comments and inconsistent exceptions in BaseTaglet Reviewed-by: prappo --- .../toolkit/taglets/BasePropertyTaglet.java | 16 ++----- .../doclets/toolkit/taglets/BaseTaglet.java | 10 +++++ .../doclets/toolkit/taglets/Taglet.java | 39 +++++++++-------- .../doclets/toolkit/taglets/ThrowsTaglet.java | 42 +++++++++---------- .../jdk/javadoc/internal/tool/Start.java | 14 +++---- 5 files changed, 59 insertions(+), 62 deletions(-) diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/BasePropertyTaglet.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/BasePropertyTaglet.java index dae3c7bcf01..b7c58ff3826 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/BasePropertyTaglet.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/BasePropertyTaglet.java @@ -49,23 +49,13 @@ public abstract class BasePropertyTaglet extends BaseTaglet { } /** - * This method returns the text to be put in the resulting javadoc before - * the property name. + * Returns the text to be included in the documentation before the property name. * - * @param tagletWriter the taglet writer for output - * @return the string to be put in the resulting javadoc. + * @param tagletWriter the taglet-writer used by the doclet + * @return the text to be included in the documentation before the property name */ abstract String getText(TagletWriter tagletWriter); - /** - * Given the Tag representation of this custom - * tag, return its string representation, which is output - * to the generated page. - * @param element - * @param tag the Tag representation of this custom tag. - * @param tagletWriter the taglet writer for output. - * @return the TagletOutput representation of this Tag. - */ @Override public Content getTagletOutput(Element element, DocTree tag, TagletWriter tagletWriter) { return tagletWriter.propertyTagOutput(element, tag, getText(tagletWriter)); diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/BaseTaglet.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/BaseTaglet.java index 9958e10b4a7..ffd7303a21d 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/BaseTaglet.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/BaseTaglet.java @@ -188,11 +188,21 @@ public class BaseTaglet implements Taglet { : tree.getKind() == tagKind; } + /** + * {@inheritDoc} + * + * @implSpec This implementation throws {@link UnsupportedTagletOperationException}. + */ @Override public Content getTagletOutput(Element element, DocTree tag, TagletWriter writer) { throw new UnsupportedTagletOperationException("Method not supported in taglet " + getName() + "."); } + /** + * {@inheritDoc} + * + * @implSpec This implementation throws {@link UnsupportedTagletOperationException} + */ @Override public Content getTagletOutput(Element holder, TagletWriter writer) { throw new UnsupportedTagletOperationException("Method not supported in taglet " + getName() + "."); diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/Taglet.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/Taglet.java index 3d355a2e5a9..0d360a88dc0 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/Taglet.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/Taglet.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2020, 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 @@ -135,29 +135,28 @@ public interface Taglet { String getName(); /** - * Given the Tag representation of this custom - * tag, return its Content representation, which is output - * to the generated page. - * @param holder the element holding the tag - * @param tag the Tag representation of this custom tag. - * @param writer a {@link TagletWriter} Taglet writer. - * @throws UnsupportedOperationException thrown when the method is not supported by the taglet. - * @return the Content representation of this Tag. + * Returns the content to be included in the generated output for an + * instance of a tag handled by this taglet. + * + * @param element the element for the enclosing doc comment + * @param tag the tag + * @param writer the taglet-writer used in this doclet + * @return the output for this tag + * @throws UnsupportedTagletOperationException thrown when the method is not supported by the taglet */ - Content getTagletOutput(Element holder, DocTree tag, TagletWriter writer) throws - UnsupportedOperationException; + Content getTagletOutput(Element element, DocTree tag, TagletWriter writer) throws + UnsupportedTagletOperationException; /** - * Given an element object, check if it holds any tags of - * this type. If it does, return the content representing the output. - * If it does not, return null. - * @param holder an element holding the custom tag. - * @param writer a {@link TagletWriter} Taglet writer. - * @throws UnsupportedTagletOperationException thrown when the method is not - * supported by the taglet. - * @return the content representation of this Tag. + * Returns the content to be included in the generated output for all + * instances of tags handled by this taglet. + * + * @param element the element for the enclosing doc comment + * @param writer the taglet-writer used in this doclet + * @return the output for this tag + * @throws UnsupportedTagletOperationException thrown when the method is not supported by the taglet */ - Content getTagletOutput(Element holder, TagletWriter writer) throws + Content getTagletOutput(Element element, TagletWriter writer) throws UnsupportedTagletOperationException; class UnsupportedTagletOperationException extends UnsupportedOperationException { diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/ThrowsTaglet.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/ThrowsTaglet.java index dc7318b692e..4342cd30917 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/ThrowsTaglet.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/ThrowsTaglet.java @@ -77,21 +77,20 @@ public class ThrowsTaglet extends BaseTaglet ? ch.getExceptionName(input.docTreeInfo.docTree).getSignature() : utils.getFullyQualifiedName(exception); } else { - TypeElement element = input.utils.findClass(input.element, input.tagId); - exception = (element == null) ? null : element; + exception = input.utils.findClass(input.element, input.tagId); } for (DocTree dt : input.utils.getThrowsTrees(input.element)) { - Element texception = ch.getException(utils.configuration, dt); - if (texception != null && (input.tagId.equals(utils.getSimpleName(texception)) || - (input.tagId.equals(utils.getFullyQualifiedName(texception))))) { + Element exc = ch.getException(utils.configuration, dt); + if (exc != null && (input.tagId.equals(utils.getSimpleName(exc)) || + (input.tagId.equals(utils.getFullyQualifiedName(exc))))) { output.holder = input.element; output.holderTag = dt; output.inlineTags = ch.getBody(input.utils.configuration, output.holderTag); output.tagList.add(dt); - } else if (exception != null && texception != null && - utils.isTypeElement(texception) && utils.isTypeElement(exception) && - utils.isSubclassOf((TypeElement)texception, (TypeElement)exception)) { + } else if (exception != null && exc != null && + utils.isTypeElement(exc) && utils.isTypeElement(exception) && + utils.isSubclassOf((TypeElement)exc, (TypeElement)exception)) { output.tagList.add(dt); } } @@ -106,15 +105,15 @@ public class ThrowsTaglet extends BaseTaglet Content result = writer.getOutputInstance(); //Add links to the exceptions declared but not documented. for (TypeMirror declaredExceptionType : declaredExceptionTypes) { - TypeElement klass = utils.asTypeElement(declaredExceptionType); - if (klass != null && + TypeElement te = utils.asTypeElement(declaredExceptionType); + if (te != null && !alreadyDocumented.contains(declaredExceptionType.toString()) && - !alreadyDocumented.contains(utils.getFullyQualifiedName(klass, false))) { + !alreadyDocumented.contains(utils.getFullyQualifiedName(te, false))) { if (alreadyDocumented.isEmpty()) { result.add(writer.getThrowsHeader()); } result.add(writer.throwsTagOutput(declaredExceptionType)); - alreadyDocumented.add(utils.getSimpleName(klass)); + alreadyDocumented.add(utils.getSimpleName(te)); } } return result; @@ -176,18 +175,17 @@ public class ThrowsTaglet extends BaseTaglet } /** - * Given an array of Tags representing this custom - * tag, return its string representation. - * @param throwTags the array of ThrowsTags to convert. - * @param writer the TagletWriter that will write this tag. - * @param alreadyDocumented the set of exceptions that have already - * been documented. - * @param allowDups True if we allow duplicate throws tags to be documented. - * @return the Content representation of this Tag. + * Returns the generated content for a collection of {@code @throws} tags. + * + * @param throwTags the collection of tags to be converted + * @param writer the taglet-writer used by the doclet + * @param alreadyDocumented the set of exceptions that have already been documented + * @param allowDuplicates {@code true} if we allow duplicate tags to be documented + * @return the generated content for the tags */ protected Content throwsTagsOutput(Map, ExecutableElement> throwTags, TagletWriter writer, Set alreadyDocumented, - Map typeSubstitutions, boolean allowDups) { + Map typeSubstitutions, boolean allowDuplicates) { Utils utils = writer.configuration().utils; Content result = writer.getOutputInstance(); if (!throwTags.isEmpty()) { @@ -198,7 +196,7 @@ public class ThrowsTaglet extends BaseTaglet Element te = ch.getException(utils.configuration, dt); String excName = ch.getExceptionName(dt).toString(); TypeMirror substituteType = typeSubstitutions.get(excName); - if ((!allowDups) && + if ((!allowDuplicates) && (alreadyDocumented.contains(excName) || (te != null && alreadyDocumented.contains(utils.getFullyQualifiedName(te, false)))) || (substituteType != null && alreadyDocumented.contains(substituteType.toString()))) { diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/Start.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/Start.java index 3e54c82c6bc..106f7c971bf 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/Start.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/Start.java @@ -399,14 +399,14 @@ public class Start { Throwable t = e.getCause(); dumpStack(t == null ? e : t); return ERROR; - } catch (OptionException toe) { - if (toe.message != null) - messager.printError(toe.message); + } catch (OptionException oe) { + if (oe.message != null) + messager.printError(oe.message); - toe.m.run(); - Throwable t = toe.getCause(); - dumpStack(t == null ? toe : t); - return toe.result; + oe.m.run(); + Throwable t = oe.getCause(); + dumpStack(t == null ? oe : t); + return oe.result; } catch (ToolException exc) { if (exc.message != null) { messager.printError(exc.message); From 3461ce98003534b0fb5e13a50b1ec8dae26c17d1 Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Fri, 7 Feb 2020 17:00:23 -0800 Subject: [PATCH 06/29] 8238437: Support separate locales for console messages and HTML content Reviewed-by: prappo --- .../formats/html/AbstractMemberWriter.java | 2 +- .../doclets/formats/html/Contents.java | 4 +- .../formats/html/HtmlConfiguration.java | 40 +++-- .../formats/html/HtmlDocletWriter.java | 2 +- .../doclets/formats/html/HtmlOptions.java | 49 +++--- .../doclets/formats/html/LinkFactoryImpl.java | 2 +- .../formats/html/SourceToHTMLConverter.java | 2 +- .../formats/html/TagletWriterImpl.java | 2 +- .../formats/html/markup/Navigation.java | 2 +- .../doclets/toolkit/AbstractDoclet.java | 2 +- .../doclets/toolkit/BaseConfiguration.java | 28 ++-- .../internal/doclets/toolkit/BaseOptions.java | 4 +- .../doclets/toolkit/CommentUtils.java | 4 +- .../internal/doclets/toolkit/Messages.java | 20 ++- .../internal/doclets/toolkit/Resources.java | 1 - .../toolkit/builders/AbstractBuilder.java | 2 +- .../doclets/toolkit/taglets/ParamTaglet.java | 4 +- .../toolkit/taglets/PropertyGetterTaglet.java | 11 +- .../toolkit/taglets/PropertySetterTaglet.java | 4 +- .../toolkit/taglets/TagletManager.java | 2 +- .../internal/doclets/toolkit/util/Extern.java | 4 +- .../internal/doclets/toolkit/util/Group.java | 8 +- .../doclets/toolkit/util/MetaKeywords.java | 2 +- .../toolkit/util/StandardDocFileFactory.java | 2 +- .../internal/doclets/toolkit/util/Utils.java | 2 +- .../jdk/javadoc/internal/tool/Start.java | 23 +-- .../javadoc/doclet/testSearch/TestSearch.java | 75 +++++++-- .../testLocaleOption/TestLocaleOption.java | 150 ++++++++++++------ 28 files changed, 267 insertions(+), 186 deletions(-) diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractMemberWriter.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractMemberWriter.java index 67c5869504a..11cf718aac1 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractMemberWriter.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractMemberWriter.java @@ -89,7 +89,7 @@ public abstract class AbstractMemberWriter implements MemberSummaryWriter { this.typeElement = typeElement; this.utils = configuration.utils; this.contents = configuration.contents; - this.resources = configuration.resources; + this.resources = configuration.docResources; this.links = writer.links; } diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/Contents.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/Contents.java index a453ff78b5a..e722b3560f4 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/Contents.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/Contents.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2020, 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 @@ -182,7 +182,7 @@ public class Contents { * resources used to look up resource keys, and other details. */ Contents(HtmlConfiguration configuration) { - this.resources = configuration.getResources(); + this.resources = configuration.getDocResources(); allClassesLabel = getNonBreakContent("doclet.All_Classes"); allImplementedInterfacesLabel = getContent("doclet.All_Implemented_Interfaces"); diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlConfiguration.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlConfiguration.java index 93f3762fe34..3dc3d0febdf 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlConfiguration.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlConfiguration.java @@ -78,7 +78,7 @@ public class HtmlConfiguration extends BaseConfiguration { */ public static final String HTML_DEFAULT_CHARSET = "utf-8"; - public final Resources resources; + public final Resources docResources; /** * First file to appear in the right-hand frame in the generated @@ -133,17 +133,31 @@ public class HtmlConfiguration extends BaseConfiguration { */ public HtmlConfiguration(Doclet doclet, Locale locale, Reporter reporter) { super(doclet, locale, reporter); - resources = new Resources(locale, + + // Use the default locale for console messages. + Resources msgResources = new Resources(Locale.getDefault(), BaseConfiguration.sharedResourceBundleName, "jdk.javadoc.internal.doclets.formats.html.resources.standard"); - messages = new Messages(this); + // Use the provided locale for generated docs + // Ideally, the doc resources would be in different resource files than the + // message resources, so that we do not have different copies of the same resources. + if (locale.equals(Locale.getDefault())) { + docResources = msgResources; + } else { + docResources = new Resources(locale, + BaseConfiguration.sharedResourceBundleName, + "jdk.javadoc.internal.doclets.formats.html.resources.standard"); + } + + messages = new Messages(this, msgResources); contents = new Contents(this); options = new HtmlOptions(this); String v; try { - ResourceBundle rb = ResourceBundle.getBundle(versionBundleName, getLocale()); + // the version bundle is not localized + ResourceBundle rb = ResourceBundle.getBundle(versionBundleName, Locale.getDefault()); try { v = rb.getString("release"); } catch (MissingResourceException e) { @@ -166,10 +180,15 @@ public class HtmlConfiguration extends BaseConfiguration { } @Override - public Resources getResources() { - return resources; + public Resources getDocResources() { + return docResources; } + /** + * Returns a utility object providing commonly used fragments of content. + * + * @return a utility object providing commonly used fragments of content + */ public Contents getContents() { return contents; } @@ -335,12 +354,7 @@ public class HtmlConfiguration extends BaseConfiguration { Character unicode = (tagLabel.length() == 0) ? '*' : Character.toUpperCase(tagLabel.charAt(0)); - List list = tagSearchIndexMap.get(unicode); - if (list == null) { - list = new ArrayList<>(); - tagSearchIndexMap.put(unicode, list); - } - list.add(sii); + tagSearchIndexMap.computeIfAbsent(unicode, k -> new ArrayList<>()).add(sii); } tagSearchIndexKeys = tagSearchIndexMap.keySet(); } @@ -359,7 +373,7 @@ public class HtmlConfiguration extends BaseConfiguration { if (options.charset() == null) { options.setCharset(options.docEncoding()); } else if (!options.charset().equals(options.docEncoding())) { - reporter.print(ERROR, resources.getText("doclet.Option_conflict", "-charset", "-docencoding")); + messages.error("doclet.Option_conflict", "-charset", "-docencoding"); return false; } } diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java index bcd8ec13a8a..34062eba539 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java @@ -213,7 +213,7 @@ public class HtmlDocletWriter { this.options = configuration.getOptions(); this.contents = configuration.contents; this.messages = configuration.messages; - this.resources = configuration.resources; + this.resources = configuration.docResources; this.links = new Links(path); this.utils = configuration.utils; this.path = path; diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlOptions.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlOptions.java index ba1848bf42a..8f1b9051de3 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlOptions.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlOptions.java @@ -33,15 +33,12 @@ import java.util.Set; import java.util.TreeSet; import com.sun.tools.doclint.DocLint; -import jdk.javadoc.doclet.Reporter; import jdk.javadoc.internal.doclets.toolkit.BaseOptions; +import jdk.javadoc.internal.doclets.toolkit.Messages; import jdk.javadoc.internal.doclets.toolkit.Resources; import jdk.javadoc.internal.doclets.toolkit.util.DocFile; import jdk.javadoc.internal.doclets.toolkit.util.Utils; -import static javax.tools.Diagnostic.Kind.ERROR; -import static javax.tools.Diagnostic.Kind.WARNING; - /** * Storage for all options supported by the * {@link jdk.javadoc.doclet.StandardDoclet standard doclet}, @@ -199,8 +196,8 @@ public class HtmlOptions extends BaseOptions { @Override public Set getSupportedOptions() { - Resources resources = config.getResources(); - Reporter reporter = config.getReporter(); + Messages messages = config.getMessages(); + Resources resources = messages.getResources(); List