mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +02:00
8330276
: Console methods with explicit Locale
Reviewed-by: joehw, rriggs, jlahoda
This commit is contained in:
parent
8a4315f833
commit
7cff04fc8a
8 changed files with 417 additions and 104 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2022, 2024, 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
|
||||
|
@ -26,6 +26,8 @@
|
|||
package java.io;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.Locale;
|
||||
|
||||
import jdk.internal.io.JdkConsole;
|
||||
|
||||
/**
|
||||
|
@ -83,9 +85,17 @@ final class ProxyingConsole extends Console {
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Console format(String fmt, Object ... args) {
|
||||
public Console format(String format, Object ... args) {
|
||||
return format(Locale.getDefault(Locale.Category.FORMAT), format, args);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Console format(Locale locale, String format, Object ... args) {
|
||||
synchronized (writeLock) {
|
||||
delegate.format(fmt, args);
|
||||
delegate.format(locale, format, args);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
@ -95,8 +105,16 @@ final class ProxyingConsole extends Console {
|
|||
*/
|
||||
@Override
|
||||
public Console printf(String format, Object ... args) {
|
||||
return printf(Locale.getDefault(Locale.Category.FORMAT), format, args);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Console printf(Locale locale, String format, Object ... args) {
|
||||
synchronized (writeLock) {
|
||||
delegate.printf(format, args);
|
||||
delegate.format(locale, format, args);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
@ -105,10 +123,18 @@ final class ProxyingConsole extends Console {
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String readLine(String fmt, Object ... args) {
|
||||
public String readLine(String format, Object ... args) {
|
||||
return readLine(Locale.getDefault(Locale.Category.FORMAT), format, args);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String readLine(Locale locale, String format, Object ... args) {
|
||||
synchronized (writeLock) {
|
||||
synchronized (readLock) {
|
||||
return delegate.readLine(fmt, args);
|
||||
return delegate.readLine(locale, format, args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -127,10 +153,18 @@ final class ProxyingConsole extends Console {
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public char[] readPassword(String fmt, Object ... args) {
|
||||
public char[] readPassword(String format, Object ... args) {
|
||||
return readPassword(Locale.getDefault(Locale.Category.FORMAT), format, args);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public char[] readPassword(Locale locale, String format, Object ... args) {
|
||||
synchronized (writeLock) {
|
||||
synchronized (readLock) {
|
||||
return delegate.readPassword(fmt, args);
|
||||
return delegate.readPassword(locale, format, args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue