2828import java .util .*;
2929import java .lang .annotation .Native ;
3030import java .nio .charset .Charset ;
31- import java .util .Optional ;
3231import java .util .concurrent .atomic .AtomicReference ;
3332import jdk .internal .access .JavaIOAccess ;
3433import jdk .internal .access .SharedSecrets ;
35- import jdk .internal .util .StaticProperty ;
3634import sun .nio .cs .StreamDecoder ;
3735import sun .nio .cs .StreamEncoder ;
38- import sun .nio .cs .UTF_8 ;
3936import 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 }
0 commit comments