File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -142,8 +142,17 @@ private[scala] trait PropertiesTrait {
142142 private [scala] lazy  val  isAvian  =  javaVmName.contains(" Avian"  )
143143
144144 private [scala] def  coloredOutputEnabled :  Boolean  =  propOrElse(" scala.color"  , " auto"  ) match  {
145-  case  " auto"   =>  System .console() !=  null  &&  ! isWin
146-  case  s =>  s ==  " "   ||  " true"  .equalsIgnoreCase(s)
145+  case  " auto"   =>  ! isWin &&  consoleIsTerminal
146+  case  s =>  " "   ==  s ||  " true"  .equalsIgnoreCase(s)
147+  }
148+ 
149+  /**  System.console.isTerminal, or just check for null console on JDK < 22 */  
150+  private [scala] lazy  val  consoleIsTerminal :  Boolean  =  {
151+  val  console  =  System .console
152+  def  isTerminal :  Boolean  = 
153+  try  classOf [java.io.Console ].getMethod(" isTerminal"  , null ).invoke(console).asInstanceOf [Boolean ]
154+  catch  { case  _ : NoSuchMethodException  =>  false  }
155+  console !=  null  &&  (! isJavaAtLeast(" 22"  ) ||  isTerminal)
147156 }
148157
149158 //  This is looking for javac, tools.jar, etc.
                                 You can’t perform that action at this time. 
               
                  
0 commit comments