Skip to content

Commit c0f44ae

Browse files
committed
incorporate review
1 parent 993e6b7 commit c0f44ae

2 files changed

Lines changed: 15 additions & 24 deletions

File tree

src/java.base/share/classes/java/io/Console.java

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,11 @@
2828
import java.util.*;
2929
import java.lang.annotation.Native;
3030
import java.nio.charset.Charset;
31-
import java.util.Optional;
3231
import java.util.concurrent.atomic.AtomicReference;
3332
import jdk.internal.access.JavaIOAccess;
3433
import jdk.internal.access.SharedSecrets;
35-
import jdk.internal.util.StaticProperty;
3634
import sun.nio.cs.StreamDecoder;
3735
import sun.nio.cs.StreamEncoder;
38-
import sun.nio.cs.UTF_8;
3936
import sun.security.action.GetPropertyAction;
4037

4138
/**
@@ -323,12 +320,12 @@ public char[] readPassword(String format, Object ... args) {
323320
// it should call this method to obtain a Console. This ensures only one Console
324321
// instance exists in the Java runtime.
325322
private static final AtomicReference<Optional<Console>> INSTANCE = new AtomicReference<>();
326-
/**
327-
* Returns a Console to be used by sun.security.util.Password, so tools like keytool can
328-
* use Console even when standard output is redirected.
329-
*
330-
* @return Returns a console.
331-
*/
323+
/**
324+
* Returns a Console to be used by sun.security.util.Password, so tools like keytool can
325+
* use Console even when standard output is redirected.
326+
*
327+
* @return Returns a console.
328+
*/
332329
private static Optional<Console> passwordConsole() {
333330
Optional<Console> result = INSTANCE.get();
334331
if (result != null) {
@@ -349,7 +346,7 @@ private static Optional<Console> passwordConsole() {
349346

350347
// If stdin is NOT redirected, return an Optional containing a Console
351348
// instance, otherwise an empty Optional.
352-
result = SharedSecrets.getJavaIOAccess().isStdinTty() ?
349+
result = isStdinTty() ?
353350
Optional.of(
354351
new Console()) :
355352
Optional.empty();
@@ -360,16 +357,14 @@ private static Optional<Console> passwordConsole() {
360357
}
361358

362359
// Dedicated entry for sun.security.util.Password when stdout is redirected.
363-
// This method strictly avoids producing any output by using noNewLine = true
364-
// and an empty format string.
365-
/**
366-
* This method strictly avoids producing any output by using noNewLine = true
367-
* and an empty format string.
368-
*
369-
* @return A character array containing the password or passphrase read
370-
* from the console, not including any line-termination characters,
371-
* or {@code null} if an end of stream has been reached.
372-
*/
360+
/**
361+
* This method strictly avoids producing any output by using noNewLine = true
362+
* and an empty format string.
363+
*
364+
* @return A character array containing the password or passphrase read
365+
* from the console, not including any line-termination characters,
366+
* or {@code null} if an end of stream has been reached.
367+
*/
373368
private char[] readPasswordNoNewLine() {
374369
return readPassword0(true, "");
375370
}
@@ -689,9 +684,6 @@ public Console console() {
689684
public Charset charset() {
690685
return CHARSET;
691686
}
692-
public boolean isStdinTty() {
693-
return Console.isStdinTty();
694-
}
695687
public Optional<Console> passwordConsole() {
696688
return Console.passwordConsole();
697689
}

src/java.base/share/classes/jdk/internal/access/JavaIOAccess.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
public interface JavaIOAccess {
3333
Console console();
3434
Charset charset();
35-
boolean isStdinTty();
3635
Optional<Console> passwordConsole();
3736
char[] readPasswordNoNewLine(Console c);
3837
}

0 commit comments

Comments
 (0)