Skip to content

Commit db22f49

Browse files
committed
Backport PR 10758 to 2.12
Don't check `isTerminal` for using JLine or not, only use it in `Properties.coloredOutputEnabled`.
1 parent 5de064e commit db22f49

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

library/src/scala/util/Properties.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,10 @@ private[scala] trait PropertiesTrait {
164164

165165
/** System.console.isTerminal, or just check for null console on JDK < 22 */
166166
private[scala] lazy val consoleIsTerminal: Boolean = {
167+
import language.reflectiveCalls
167168
val console = System.console
168169
def isTerminal: Boolean =
169-
try classOf[java.io.Console].getMethod("isTerminal", null).invoke(console).asInstanceOf[Boolean]
170+
try console.asInstanceOf[{ def isTerminal(): Boolean }].isTerminal()
170171
catch { case _: NoSuchMethodException => false }
171172
console != null && (!isJavaAtLeast("22") || isTerminal)
172173
}

0 commit comments

Comments
 (0)