Skip to content

Commit 78355b7

Browse files
author
duke
committedJun 8, 2021
Automatic merge of jdk:master into master
2 parents 300c27d + fafc4d9 commit 78355b7

File tree

9 files changed

+126
-126
lines changed

9 files changed

+126
-126
lines changed
 

‎src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ElementsTable.java

+15-15
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ public class ElementsTable {
165165
private final List<Location> locations;
166166
private final Modules modules;
167167
private final ToolOptions options;
168-
private final Messager messager;
168+
private final JavadocLog log;
169169
private final JavaCompiler compiler;
170170

171171
private final Map<String, Entry> entries = new LinkedHashMap<>();
@@ -210,7 +210,7 @@ public class ElementsTable {
210210
this.fm = toolEnv.fileManager;
211211
this.modules = Modules.instance(context);
212212
this.options = options;
213-
this.messager = Messager.instance0(context);
213+
this.log = JavadocLog.instance0(context);
214214
this.compiler = JavaCompiler.instance(context);
215215
Source source = Source.instance(context);
216216

@@ -370,19 +370,19 @@ void sanityCheckSourcePathModules(List<String> moduleNames) throws ToolException
370370
return;
371371

372372
if (moduleNames.size() > 1) {
373-
String text = messager.getText("main.cannot_use_sourcepath_for_modules",
373+
String text = log.getText("main.cannot_use_sourcepath_for_modules",
374374
String.join(", ", moduleNames));
375375
throw new ToolException(CMDERR, text);
376376
}
377377

378378
String foundModule = getModuleName(StandardLocation.SOURCE_PATH);
379379
if (foundModule == null) {
380-
String text = messager.getText("main.module_not_found_on_sourcepath", moduleNames.get(0));
380+
String text = log.getText("main.module_not_found_on_sourcepath", moduleNames.get(0));
381381
throw new ToolException(CMDERR, text);
382382
}
383383

384384
if (!moduleNames.get(0).equals(foundModule)) {
385-
String text = messager.getText("main.sourcepath_does_not_contain_module", moduleNames.get(0));
385+
String text = log.getText("main.sourcepath_does_not_contain_module", moduleNames.get(0));
386386
throw new ToolException(CMDERR, text);
387387
}
388388
}
@@ -399,7 +399,7 @@ private String getModuleName(Location location) throws ToolException {
399399
}
400400
}
401401
} catch (IOException ioe) {
402-
String text = messager.getText("main.file.manager.list", location);
402+
String text = log.getText("main.file.manager.list", location);
403403
throw new ToolException(SYSERR, text, ioe);
404404
}
405405
return null;
@@ -413,7 +413,7 @@ ElementsTable scanSpecifiedItems() throws ToolException {
413413
for (String m : modules) {
414414
List<Location> moduleLocations = getModuleLocation(locations, m);
415415
if (moduleLocations.isEmpty()) {
416-
String text = messager.getText("main.module_not_found", m);
416+
String text = log.getText("main.module_not_found", m);
417417
throw new ToolException(CMDERR, text);
418418
}
419419
if (moduleLocations.contains(StandardLocation.SOURCE_PATH)) {
@@ -520,7 +520,7 @@ private Iterable<JavaFileObject> fmList(Location location,
520520
try {
521521
return fm.list(location, packagename, kinds, recurse);
522522
} catch (IOException ioe) {
523-
String text = messager.getText("main.file.manager.list", packagename);
523+
String text = log.getText("main.file.manager.list", packagename);
524524
throw new ToolException(SYSERR, text, ioe);
525525
}
526526
}
@@ -567,7 +567,7 @@ private Set<ModuleElement> getModuleRequires(ModuleElement mdle, boolean onlyTra
567567
if (!isMandated(mdle, rd) && onlyTransitive == rd.isTransitive()) {
568568
if (!haveModuleSources(dep)) {
569569
if (!warnedNoSources.contains(dep)) {
570-
messager.printWarningUsingKey(dep, "main.module_source_not_found", dep.getQualifiedName());
570+
log.printWarningUsingKey(dep, "main.module_source_not_found", dep.getQualifiedName());
571571
warnedNoSources.add(dep);
572572
}
573573
}
@@ -759,7 +759,7 @@ private void computeSpecifiedPackages() throws ToolException {
759759
if (pkg != null) {
760760
packlist.add(pkg);
761761
} else {
762-
messager.printWarningUsingKey("main.package_not_found", modpkg.toString());
762+
log.printWarningUsingKey("main.package_not_found", modpkg.toString());
763763
}
764764
});
765765
specifiedPackageElements = Collections.unmodifiableSet(packlist);
@@ -780,7 +780,7 @@ private void computeSpecifiedTypes() throws ToolException {
780780
for (String className : classArgList) {
781781
TypeElement te = toolEnv.loadClass(className);
782782
if (te == null) {
783-
String text = messager.getText("javadoc.class_not_found", className);
783+
String text = log.getText("javadoc.class_not_found", className);
784784
throw new ToolException(CMDERR, text);
785785
} else {
786786
addAllClasses(classes, te, true);
@@ -796,7 +796,7 @@ private void addFilesForParser(Collection<JavaFileObject> result,
796796
toolEnv.notice("main.Loading_source_files_for_package", modpkg.toString());
797797
List<JavaFileObject> files = getFiles(modpkg, recurse);
798798
if (files.isEmpty()) {
799-
String text = messager.getText("main.no_source_files_for_package",
799+
String text = log.getText("main.no_source_files_for_package",
800800
modpkg.toString());
801801
throw new ToolException(CMDERR, text);
802802
} else {
@@ -909,7 +909,7 @@ private Location getModuleLocation(Location location, String msymName) throws To
909909
try {
910910
return fm.getLocationForModule(location, msymName);
911911
} catch (IOException ioe) {
912-
String text = messager.getText("main.doclet_could_not_get_location", msymName);
912+
String text = log.getText("main.doclet_could_not_get_location", msymName);
913913
throw new ToolException(ERROR, text, ioe);
914914
}
915915
}
@@ -956,9 +956,9 @@ private void addAllClasses(Collection<TypeElement> list, TypeElement typeElement
956956
}
957957
} catch (CompletionFailure e) {
958958
if (e.getMessage() != null)
959-
messager.printWarning(e.getMessage());
959+
log.printWarning(e.getMessage());
960960
else
961-
messager.printWarningUsingKey("main.unexpected.exception", e);
961+
log.printWarningUsingKey("main.unexpected.exception", e);
962962
}
963963
}
964964

‎src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/JavadocEnter.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -61,24 +61,24 @@ public static void preRegister(Context context) {
6161

6262
protected JavadocEnter(Context context) {
6363
super(context);
64-
messager = Messager.instance0(context);
64+
log = JavadocLog.instance0(context);
6565
toolEnv = ToolEnvironment.instance(context);
6666
compiler = JavaCompiler.instance(context);
6767
}
6868

69-
final Messager messager;
69+
final JavadocLog log;
7070
final ToolEnvironment toolEnv;
7171
final JavaCompiler compiler;
7272

7373
@Override
7474
public void main(List<JCCompilationUnit> trees) {
7575
// cache the error count if we need to convert Enter errors as warnings.
76-
int nerrors = messager.nerrors;
76+
int nerrors = log.nerrors;
7777
super.main(trees);
7878
compiler.enterDone();
7979
if (toolEnv.ignoreSourceErrors) {
80-
messager.nwarnings += (messager.nerrors - nerrors);
81-
messager.nerrors = nerrors;
80+
log.nwarnings += (log.nerrors - nerrors);
81+
log.nerrors = nerrors;
8282
}
8383
}
8484

‎src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/Messager.java ‎src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/JavadocLog.java

+10-10
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@
123123
* @see java.util.ResourceBundle
124124
* @see java.text.MessageFormat
125125
*/
126-
public class Messager extends Log implements Reporter {
126+
public class JavadocLog extends Log implements Reporter {
127127
/** The overall context for the documentation run. */
128128
private final Context context;
129129

@@ -138,22 +138,22 @@ public class Messager extends Log implements Reporter {
138138
*/
139139
private final LinkedHashMap<JavaFileObject, SoftReference<DiagnosticSource>> diagSourceCache;
140140

141-
/** Get the current messager, which is also the compiler log. */
142-
public static Messager instance0(Context context) {
141+
/** Get the current javadoc log, which is also the compiler log. */
142+
public static JavadocLog instance0(Context context) {
143143
Log instance = context.get(logKey);
144-
if (!(instance instanceof Messager m))
145-
throw new InternalError("no messager instance!");
146-
return m;
144+
if (!(instance instanceof JavadocLog l))
145+
throw new InternalError("no JavadocLog instance!");
146+
return l;
147147
}
148148

149149
public static void preRegister(Context context,
150150
final String programName) {
151-
context.put(logKey, (Factory<Log>)c -> new Messager(c, programName));
151+
context.put(logKey, (Factory<Log>)c -> new JavadocLog(c, programName));
152152
}
153153

154154
public static void preRegister(Context context, final String programName,
155155
final PrintWriter outWriter, final PrintWriter errWriter) {
156-
context.put(logKey, (Factory<Log>)c -> new Messager(c, programName, outWriter, errWriter));
156+
context.put(logKey, (Factory<Log>)c -> new JavadocLog(c, programName, outWriter, errWriter));
157157
}
158158

159159
final String programName;
@@ -176,7 +176,7 @@ public void close() {
176176
* Constructor
177177
* @param programName Name of the program (for error messages).
178178
*/
179-
public Messager(Context context, String programName) {
179+
public JavadocLog(Context context, String programName) {
180180
// use the current values of System.out, System.err, in case they have been redirected
181181
this(context, programName,
182182
createPrintWriter(System.out, false),
@@ -189,7 +189,7 @@ public Messager(Context context, String programName) {
189189
* @param outWriter Stream for notices etc.
190190
* @param errWriter Stream for errors and warnings
191191
*/
192-
public Messager(Context context, String programName, PrintWriter outWriter, PrintWriter errWriter) {
192+
public JavadocLog(Context context, String programName, PrintWriter outWriter, PrintWriter errWriter) {
193193
super(context, outWriter, errWriter);
194194
messages = JavacMessages.instance(context);
195195
messages.add(locale -> ResourceBundle.getBundle("jdk.javadoc.internal.tool.resources.javadoc",

‎src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/JavadocTool.java

+18-18
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
public class JavadocTool extends com.sun.tools.javac.main.JavaCompiler {
7171
ToolEnvironment toolEnv;
7272

73-
final Messager messager;
73+
final JavadocLog log;
7474
final ClassFinder javadocFinder;
7575
final DeferredCompletionFailureHandler dcfh;
7676
final Enter javadocEnter;
@@ -82,7 +82,7 @@ public class JavadocTool extends com.sun.tools.javac.main.JavaCompiler {
8282
*/
8383
protected JavadocTool(Context context) {
8484
super(context);
85-
messager = Messager.instance0(context);
85+
log = JavadocLog.instance0(context);
8686
javadocFinder = JavadocClassFinder.instance(context);
8787
dcfh = DeferredCompletionFailureHandler.instance(context);
8888
javadocEnter = JavadocEnter.instance(context);
@@ -101,7 +101,7 @@ protected boolean keepComments() {
101101
* Construct a new javadoc tool.
102102
*/
103103
public static JavadocTool make0(Context context) {
104-
Messager messager = null;
104+
JavadocLog log = null;
105105
try {
106106
// force the use of Javadoc's class finder
107107
JavadocClassFinder.preRegister(context);
@@ -115,13 +115,13 @@ public static JavadocTool make0(Context context) {
115115
// force the use of Javadoc's own todo phase
116116
JavadocTodo.preRegister(context);
117117

118-
// force the use of Messager as a Log
119-
messager = Messager.instance0(context);
118+
// force the use of Javadoc's subtype of Log
119+
log = JavadocLog.instance0(context);
120120

121121
return new JavadocTool(context);
122122
} catch (CompletionFailure ex) {
123-
assert messager != null;
124-
messager.error(Position.NOPOS, ex.getMessage());
123+
assert log != null;
124+
log.error(Position.NOPOS, ex.getMessage());
125125
return null;
126126
}
127127
}
@@ -142,11 +142,11 @@ public DocletEnvironment getEnvironment(ToolOptions toolOptions,
142142
// If -Xclasses is set, the args should be a list of class names
143143
for (String arg: javaNames) {
144144
if (!isValidPackageName(arg)) { // checks
145-
String text = messager.getText("main.illegal_class_name", arg);
145+
String text = log.getText("main.illegal_class_name", arg);
146146
throw new ToolException(CMDERR, text);
147147
}
148148
}
149-
if (messager.hasErrors()) {
149+
if (log.hasErrors()) {
150150
return null;
151151
}
152152
etable.setClassArgList(javaNames);
@@ -171,14 +171,14 @@ public DocletEnvironment getEnvironment(ToolOptions toolOptions,
171171
packageNames.add(arg);
172172
} else if (arg.endsWith(".java")) {
173173
if (fm == null) {
174-
String text = messager.getText("main.assertion.error", "fm == null");
174+
String text = log.getText("main.assertion.error", "fm == null");
175175
throw new ToolException(ABNORMAL, text);
176176
} else {
177-
String text = messager.getText("main.file_not_found", arg);
177+
String text = log.getText("main.file_not_found", arg);
178178
throw new ToolException(ERROR, text);
179179
}
180180
} else {
181-
String text = messager.getText("main.illegal_package_name", arg);
181+
String text = log.getText("main.illegal_package_name", arg);
182182
throw new ToolException(CMDERR, text);
183183
}
184184
}
@@ -191,7 +191,7 @@ public DocletEnvironment getEnvironment(ToolOptions toolOptions,
191191
.scanSpecifiedItems();
192192

193193
// abort, if errors were encountered during modules initialization
194-
if (messager.hasErrors()) {
194+
if (log.hasErrors()) {
195195
return null;
196196
}
197197

@@ -202,15 +202,15 @@ public DocletEnvironment getEnvironment(ToolOptions toolOptions,
202202
modules.newRound();
203203
modules.initModules(allTrees.toList());
204204

205-
if (messager.hasErrors()) {
205+
if (log.hasErrors()) {
206206
return null;
207207
}
208208

209209
// Enter symbols for all files
210210
toolEnv.notice("main.Building_tree");
211211
javadocEnter.main(allTrees.toList());
212212

213-
if (messager.hasErrors()) {
213+
if (log.hasErrors()) {
214214
return null;
215215
}
216216

@@ -232,17 +232,17 @@ public DocletEnvironment getEnvironment(ToolOptions toolOptions,
232232
} catch (CompletionFailure cf) {
233233
throw new ToolException(ABNORMAL, cf.getMessage(), cf);
234234
} catch (Abort abort) {
235-
if (messager.hasErrors()) {
235+
if (log.hasErrors()) {
236236
// presumably a message has been emitted, keep silent
237237
throw new ToolException(ABNORMAL, "", abort);
238238
} else {
239-
String text = messager.getText("main.internal.error");
239+
String text = log.getText("main.internal.error");
240240
Throwable t = abort.getCause() == null ? abort : abort.getCause();
241241
throw new ToolException(ABNORMAL, text, t);
242242
}
243243
}
244244

245-
if (messager.hasErrors())
245+
if (log.hasErrors())
246246
return null;
247247

248248
toolEnv.docEnv = new DocEnvImpl(toolEnv, etable);

‎src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/Start.java

+55-55
Large diffs are not rendered by default.

‎src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ToolEnvironment.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public static ToolEnvironment instance(Context context) {
8383
return instance;
8484
}
8585

86-
final Messager messager;
86+
final JavadocLog log;
8787

8888
/** Predefined symbols known to the compiler. */
8989
public final Symtab syms;
@@ -137,7 +137,7 @@ protected ToolEnvironment(Context context) {
137137
context.put(ToolEnvKey, this);
138138
this.context = context;
139139

140-
messager = Messager.instance0(context);
140+
log = JavadocLog.instance0(context);
141141
syms = Symtab.instance(context);
142142
finder = JavadocClassFinder.instance(context);
143143
enter = JavadocEnter.instance(context);
@@ -199,7 +199,7 @@ public void notice(String key) {
199199
if (quiet) {
200200
return;
201201
}
202-
messager.noticeUsingKey(key);
202+
log.noticeUsingKey(key);
203203
}
204204

205205
/**
@@ -212,7 +212,7 @@ public void notice(String key, String a1) {
212212
if (quiet) {
213213
return;
214214
}
215-
messager.noticeUsingKey(key, a1);
215+
log.noticeUsingKey(key, a1);
216216
}
217217

218218
TreePath getTreePath(JCCompilationUnit tree) {

‎src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ToolOptions.java

+13-13
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -168,9 +168,9 @@ public class ToolOptions {
168168
private final OptionHelper compilerOptionHelper;
169169

170170
/**
171-
* The messager to be used to report diagnostics..
171+
* The log to be used to report diagnostics..
172172
*/
173-
private final Messager messager;
173+
private final JavadocLog log;
174174

175175
/**
176176
* The helper for help and version options
@@ -181,10 +181,10 @@ public class ToolOptions {
181181
* Creates an object to handle tool options.
182182
*
183183
* @param context the context used to find other tool-related components
184-
* @param messager the messager to be used to report diagnostics
184+
* @param log the log to be used to report diagnostics
185185
*/
186-
ToolOptions(Context context, Messager messager, ShowHelper showHelper) {
187-
this.messager = messager;
186+
ToolOptions(Context context, JavadocLog log, ShowHelper showHelper) {
187+
this.log = log;
188188
this.showHelper = showHelper;
189189
compOpts = Options.instance(context);
190190
fileManagerOpts = new LinkedHashMap<>();
@@ -200,7 +200,7 @@ private ToolOptions() {
200200
compOpts = null;
201201
compilerOptionHelper = null;
202202
fileManagerOpts = null;
203-
messager = null;
203+
log = null;
204204
showHelper = null;
205205
}
206206

@@ -646,14 +646,14 @@ List<String> getNames() {
646646
return names;
647647
}
648648

649-
String getParameters(Messager messager) {
649+
String getParameters(JavadocLog log) {
650650
return (hasArg || primaryName.endsWith(":"))
651-
? messager.getText(getKey(primaryName, ".arg"))
651+
? log.getText(getKey(primaryName, ".arg"))
652652
: null;
653653
}
654654

655-
String getDescription(Messager messager) {
656-
return messager.getText(getKey(primaryName, ".desc"));
655+
String getDescription(JavadocLog log) {
656+
return log.getText(getKey(primaryName, ".desc"));
657657
}
658658

659659
private String getKey(String optionName, String suffix) {
@@ -833,7 +833,7 @@ Map<Option, String> fileManagerOptions() {
833833
* @return the exception
834834
*/
835835
private IllegalOptionValue illegalOptionValue(String arg) {
836-
return new IllegalOptionValue(showHelper::usage, messager.getText("main.illegal_option_value", arg));
836+
return new IllegalOptionValue(showHelper::usage, log.getText("main.illegal_option_value", arg));
837837
}
838838

839839
/**
@@ -864,7 +864,7 @@ private void processCompilerOption(Option option, String opt, String arg) throws
864864
* @return the helper
865865
*/
866866
private OptionHelper getOptionHelper() {
867-
return new OptionHelper.GrumpyHelper(messager) {
867+
return new OptionHelper.GrumpyHelper(log) {
868868
@Override
869869
public String get(com.sun.tools.javac.main.Option option) {
870870
return compOpts.get(option);

‎test/langtools/jdk/javadoc/tool/CheckResourceKeys.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ Set<String> getCodeKeys() throws IOException {
227227
}
228228

229229
// special handling for code strings synthesized in
230-
// jdk.javadoc.internal.tool.Messager
230+
// jdk.javadoc.internal.tool.JavadocLog
231231
results.add("javadoc.error.msg");
232232
results.add("javadoc.note.msg");
233233
results.add("javadoc.note.pos.msg");

‎test/langtools/jdk/javadoc/tool/api/basic/JavadocTaskImplTest.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -46,7 +46,7 @@
4646
import com.sun.tools.javac.file.JavacFileManager;
4747
import com.sun.tools.javac.util.Context;
4848
import jdk.javadoc.internal.api.JavadocTaskImpl;
49-
import jdk.javadoc.internal.tool.Messager;
49+
import jdk.javadoc.internal.tool.JavadocLog;
5050

5151
/**
5252
* Misc tests for JavacTaskImpl.
@@ -81,7 +81,7 @@ public void testDirectAccess1() throws Exception {
8181
JavaFileObject srcFile = createSimpleJavaFileObject();
8282
Iterable<? extends JavaFileObject> files = Arrays.asList(srcFile);
8383
Context c = new Context();
84-
Messager.preRegister(c, "javadoc");
84+
JavadocLog.preRegister(c, "javadoc");
8585
try (StandardJavaFileManager fm = new JavacFileManager(c, true, null)) {
8686
File outDir = getOutDir();
8787
fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
@@ -99,7 +99,7 @@ public void testDirectAccess2() throws Exception {
9999
JavaFileObject srcFile = null; // error, provokes NPE
100100
Iterable<? extends JavaFileObject> files = Arrays.asList(srcFile);
101101
Context c = new Context();
102-
Messager.preRegister(c, "javadoc");
102+
JavadocLog.preRegister(c, "javadoc");
103103
try (StandardJavaFileManager fm = new JavacFileManager(c, true, null)) {
104104
File outDir = getOutDir();
105105
fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));

0 commit comments

Comments
 (0)
Please sign in to comment.