Skip to content

Commit a4be3e8

Browse files
authored
Merge pull request scala/scala#10758 from som-snytt/fix/repl-color-redux
Restrict fix to Properties
2 parents 6845f54 + 47295a9 commit a4be3e8

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
@@ -148,9 +148,10 @@ private[scala] trait PropertiesTrait {
148148

149149
/** System.console.isTerminal, or just check for null console on JDK < 22 */
150150
private[scala] lazy val consoleIsTerminal: Boolean = {
151+
import language.reflectiveCalls
151152
val console = System.console
152153
def isTerminal: Boolean =
153-
try classOf[java.io.Console].getMethod("isTerminal", null).invoke(console).asInstanceOf[Boolean]
154+
try console.asInstanceOf[{ def isTerminal(): Boolean }].isTerminal()
154155
catch { case _: NoSuchMethodException => false }
155156
console != null && (!isJavaAtLeast("22") || isTerminal)
156157
}

0 commit comments

Comments
 (0)