Skip to content

Commit f6e23ae

Browse files
committedJul 17, 2023
8310201: Reduce verbose locale output in -XshowSettings launcher option
Reviewed-by: jpai
1 parent a441216 commit f6e23ae

File tree

2 files changed

+22
-7
lines changed

2 files changed

+22
-7
lines changed
 

‎src/java.base/share/classes/sun/launcher/LauncherHelper.java

+13-5
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ static void showSettings(boolean printToStderr, String optionFlag,
170170
printProperties();
171171
break;
172172
case "locale":
173-
printLocale();
173+
printLocale(false);
174174
break;
175175
case "security":
176176
var opt = opts.length > 2 ? opts[2].trim() : "all";
@@ -184,7 +184,7 @@ static void showSettings(boolean printToStderr, String optionFlag,
184184
default:
185185
printVmSettings(initialHeapSize, maxHeapSize, stackSize);
186186
printProperties();
187-
printLocale();
187+
printLocale(true);
188188
SecuritySettings.printSecuritySummarySettings(ostream);
189189
if (OperatingSystem.isLinux()) {
190190
printSystemMetrics();
@@ -280,9 +280,15 @@ private static void printPropertyValue(String key, String value) {
280280
/*
281281
* prints the locale subopt/section
282282
*/
283-
private static void printLocale() {
283+
private static void printLocale(boolean summaryMode) {
284284
Locale locale = Locale.getDefault();
285-
ostream.println(LOCALE_SETTINGS);
285+
if (!summaryMode) {
286+
ostream.println(LOCALE_SETTINGS);
287+
} else {
288+
ostream.println("Locale settings summary:");
289+
ostream.println(INDENT + "Use \"-XshowSettings:locale\" " +
290+
"option for verbose locale settings options");
291+
}
286292
ostream.println(INDENT + "default locale = " +
287293
locale.getDisplayName());
288294
ostream.println(INDENT + "default display locale = " +
@@ -291,7 +297,9 @@ private static void printLocale() {
291297
Locale.getDefault(Category.FORMAT).getDisplayName());
292298
ostream.println(INDENT + "tzdata version = " +
293299
ZoneInfoFile.getVersion());
294-
printLocales();
300+
if (!summaryMode) {
301+
printLocales();
302+
}
295303
ostream.println();
296304
}
297305

‎test/jdk/tools/launcher/Settings.java

+9-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
/*
2727
* @test
28-
* @bug 6994753 7123582 8305950 8281658
28+
* @bug 6994753 7123582 8305950 8281658 8310201
2929
* @summary tests -XshowSettings options
3030
* @modules jdk.compiler
3131
* jdk.zipfs
@@ -67,6 +67,9 @@ static void checkNotContains(TestResult tr, String str) {
6767
private static final String VM_SETTINGS = "VM settings:";
6868
private static final String PROP_SETTINGS = "Property settings:";
6969
private static final String LOCALE_SETTINGS = "Locale settings:";
70+
private static final String LOCALE_SUMMARY_SETTINGS =
71+
"Locale settings summary:";
72+
private static final String AVAILABLE_LOCALES = "available locales";
7073
private static final String SEC_PROPS_SETTINGS = "Security properties:";
7174
private static final String SEC_SUMMARY_PROPS_SETTINGS =
7275
"Security settings summary:";
@@ -81,7 +84,9 @@ static void checkNotContains(TestResult tr, String str) {
8184
static void containsAllOptions(TestResult tr) {
8285
checkContains(tr, VM_SETTINGS);
8386
checkContains(tr, PROP_SETTINGS);
84-
checkContains(tr, LOCALE_SETTINGS);
87+
checkNotContains(tr, LOCALE_SETTINGS);
88+
checkNotContains(tr, AVAILABLE_LOCALES);
89+
checkContains(tr, LOCALE_SUMMARY_SETTINGS);
8590
// no verbose security settings unless "security" used
8691
checkNotContains(tr, SEC_PROPS_SETTINGS);
8792
checkContains(tr, SEC_SUMMARY_PROPS_SETTINGS);
@@ -153,6 +158,8 @@ static void runTestOptionLocale() throws IOException {
153158
checkNotContains(tr, VM_SETTINGS);
154159
checkNotContains(tr, PROP_SETTINGS);
155160
checkContains(tr, LOCALE_SETTINGS);
161+
checkContains(tr, AVAILABLE_LOCALES);
162+
checkNotContains(tr, LOCALE_SUMMARY_SETTINGS);
156163
checkContains(tr, TZDATA_SETTINGS);
157164
}
158165

0 commit comments

Comments
 (0)
Please sign in to comment.