Skip to content

Commit e0620b8

Browse files
archiecobbsVicente Romero
authored and
Vicente Romero
committed
8296420: javac has long lines in its command-line help
Reviewed-by: jjg
1 parent 6b9b7d1 commit e0620b8

File tree

2 files changed

+126
-21
lines changed

2 files changed

+126
-21
lines changed

src/jdk.compiler/share/classes/com/sun/tools/javac/resources/javac.properties

+32-21
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ javac.opt.processorpath=\
6666
javac.opt.processormodulepath=\
6767
Specify a module path where to find annotation processors
6868
javac.opt.processor=\
69-
Names of the annotation processors to run; bypasses default discovery process
69+
Names of the annotation processors to run;\n\
70+
bypasses default discovery process
7071
javac.opt.parameters=\
7172
Generate metadata for reflection on method parameters
7273
javac.opt.proc.none.only=\
@@ -85,17 +86,20 @@ javac.opt.profile=\
8586
Check that API used is available in the specified profile.\n\
8687
This option is deprecated and may be removed in a future release.
8788
javac.opt.target=\
88-
Generate class files suitable for the specified Java SE release. Supported releases: {0}
89+
Generate class files suitable for the specified Java SE release.\n\
90+
Supported releases: {0}
8991
javac.opt.release=\
90-
Compile for the specified Java SE release. Supported releases: {0}
92+
Compile for the specified Java SE release.\n\
93+
Supported releases: {0}
9194
javac.opt.source=\
92-
Provide source compatibility with the specified Java SE release. Supported releases: {0}
95+
Provide source compatibility with the specified Java SE release.\n\
96+
Supported releases: {0}
9397
javac.opt.Werror=\
9498
Terminate compilation if warnings occur
9599
javac.opt.A=\
96100
Options to pass to annotation processors
97101
javac.opt.implicit=\
98-
Specify whether or not to generate class files for implicitly referenced files
102+
Specify whether to generate class files for implicitly referenced files
99103
javac.opt.pkginfo=\
100104
Specify handling of package-info files
101105
javac.opt.multi-release=\
@@ -291,17 +295,18 @@ javac.opt.Xdoclint.subopts = \
291295
# L10N: do not localize: public protected package private
292296
javac.opt.Xdoclint.custom=\
293297
Enable or disable specific checks for problems in javadoc comments,\n\
294-
where <group> is one of accessibility, html, missing, reference, or syntax,\n\
295-
and <access> is one of public, protected, package, or private.
298+
where <group> is one of accessibility, html, missing, reference,\n\
299+
or syntax, and <access> is one of public, protected, package,\n\
300+
or private.
296301

297302
javac.opt.Xdoclint.package.args = \
298303
[-]<packages>(,[-]<package>)*
299304

300305
javac.opt.Xdoclint.package.desc=\
301-
Enable or disable checks in specific packages. Each <package> is either the\n\
302-
qualified name of a package or a package name prefix followed by '.*', which\n\
303-
expands to all sub-packages of the given package. Each <package> can be prefixed\n\
304-
with '-' to disable checks for the specified package or packages.
306+
Enable or disable checks in specific packages. Each <package> is either\n\
307+
the qualified name of a package or a package name prefix followed by '.*',\n\
308+
which expands to all sub-packages of the given package. Each <package>\n\
309+
can be prefixed with '-' to disable checks for the specified package(s).
305310

306311
javac.opt.Xstdout=\
307312
Redirect standard output
@@ -318,25 +323,30 @@ javac.opt.print=\
318323
javac.opt.printRounds=\
319324
Print information about rounds of annotation processing
320325
javac.opt.printProcessorInfo=\
321-
Print information about which annotations a processor is asked to process
326+
Print information about which annotations a processor\n\
327+
is asked to process
322328
javac.opt.userpathsfirst=\
323329
Search classpath and sourcepath for classes before the bootclasspath instead of after
324330
javac.opt.prefer=\
325-
Specify which file to read when both a source file and class file are found for an implicitly compiled class
331+
Specify which file to read when both a source file and class file\n\
332+
are found for an implicitly compiled class
326333
javac.opt.preview=\
327-
Enable preview language features. To be used in conjunction with either -source or --release.
334+
Enable preview language features.\n\
335+
To be used in conjunction with either -source or --release.
328336
javac.opt.AT=\
329337
Read options and filenames from file
330338
javac.opt.diags=\
331339
Select a diagnostic mode
332340
javac.opt.addExports=\
333-
Specify a package to be considered as exported from its defining module\n\
334-
to additional modules, or to all unnamed modules if <other-module> is ALL-UNNAMED.
341+
Specify a package to be considered as exported from its\n\
342+
defining module to additional modules, or to all unnamed modules\n\
343+
if <other-module> is ALL-UNNAMED.
335344
javac.opt.arg.addExports=\
336345
<module>/<package>=<other-module>(,<other-module>)*
337346
javac.opt.addReads=\
338-
Specify additional modules to be considered as required by a given module.\n\
339-
<other-module> may be ALL-UNNAMED to require the unnamed module.
347+
Specify additional modules to be considered as required by\n\
348+
a given module; <other-module> may be ALL-UNNAMED to require\n\
349+
the unnamed module.
340350
javac.opt.arg.addReads=\
341351
<module>=<other-module>(,<other-module>)*
342352
javac.opt.patch=\
@@ -345,8 +355,8 @@ javac.opt.patch=\
345355
javac.opt.arg.patch=\
346356
<module>=<file>(:<file>)*
347357
javac.opt.addmods=\
348-
Root modules to resolve in addition to the initial modules, or all modules\n\
349-
on the module path if <module> is ALL-MODULE-PATH.
358+
Root modules to resolve in addition to the initial modules,\n\
359+
or all modules on the module path if <module> is ALL-MODULE-PATH.
350360
javac.opt.arg.addmods=\
351361
<module>(,<module>)*
352362
javac.opt.limitmods=\
@@ -360,7 +370,8 @@ javac.opt.arg.module.version=\
360370
javac.opt.inherit_runtime_environment=\
361371
Inherit module system configuration options from the runtime environment.
362372
javac.opt.default.module.for.created.files=\
363-
Fallback target module for files created by annotation processors, if none specified or inferred.
373+
Fallback target module for files created by annotation processors,\n\
374+
if none specified or inferred.
364375

365376
## messages
366377

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
/*
2+
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation.
8+
*
9+
* This code is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* version 2 for more details (a copy is included in the LICENSE file that
13+
* accompanied this code).
14+
*
15+
* You should have received a copy of the GNU General Public License version
16+
* 2 along with this work; if not, write to the Free Software Foundation,
17+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18+
*
19+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20+
* or visit www.oracle.com if you need additional information or have any
21+
* questions.
22+
*/
23+
24+
/**
25+
* @test
26+
* @bug 8296420
27+
* @summary Verify command line help output does not exceed maximum column width
28+
* @library /tools/lib
29+
* @modules jdk.compiler/com.sun.tools.javac.api
30+
* jdk.compiler/com.sun.tools.javac.main
31+
* jdk.compiler/com.sun.tools.javac.util
32+
* @build toolbox.ToolBox toolbox.JavacTask
33+
* @run main HelpOutputColumnWidthTest
34+
*/
35+
36+
import java.io.IOException;
37+
import java.nio.file.Path;
38+
import java.nio.file.Paths;
39+
import java.util.List;
40+
import java.util.regex.Pattern;
41+
import java.util.stream.Collectors;
42+
43+
import toolbox.TestRunner;
44+
import toolbox.ToolBox;
45+
import toolbox.JavacTask;
46+
import toolbox.Task;
47+
48+
public class HelpOutputColumnWidthTest extends TestRunner {
49+
50+
public static final int MAX_COLUMNS = 80;
51+
52+
protected ToolBox tb;
53+
54+
public HelpOutputColumnWidthTest() {
55+
super(System.err);
56+
tb = new ToolBox();
57+
}
58+
59+
protected void runTests() throws Exception {
60+
runTests(m -> new Object[] { Paths.get(m.getName()) });
61+
}
62+
63+
@Test
64+
public void testHelp(Path base) throws Exception {
65+
this.checkColumnWidth("--help");
66+
}
67+
68+
@Test
69+
public void testHelpExtra(Path base) throws Exception {
70+
this.checkColumnWidth("--help-extra");
71+
}
72+
73+
private void checkColumnWidth(String... args) throws Exception {
74+
75+
// Compile source
76+
List<String> log = new JavacTask(tb, Task.Mode.CMDLINE)
77+
.options(args)
78+
.run(Task.Expect.SUCCESS)
79+
.writeAll()
80+
.getOutputLines(Task.OutputKind.DIRECT);
81+
82+
// Check column width
83+
final String tooLongLines = log.stream()
84+
.filter(line -> line.length() > MAX_COLUMNS)
85+
.map(String::trim)
86+
.collect(Collectors.joining("]\n ["));
87+
if (!tooLongLines.isEmpty())
88+
throw new Exception("output line(s) too long:\n [" + tooLongLines + "]");
89+
}
90+
91+
public static void main(String... args) throws Exception {
92+
new HelpOutputColumnWidthTest().runTests();
93+
}
94+
}

0 commit comments

Comments
 (0)