codeconsole commented on PR #3309: URL: https://github.com/apache/groovy/pull/3309#issuecomment-7000148736
Thanks both. Both points reproduced, and they're addressed in 9bb03d5667, e2c0a85070 and 4f31e60c14: - `IO` only opens JLine's console for `jansi.mode=force`, or on a terminal when the mode isn't `strip` (`System.console()`, plus `Console.isTerminal()` on JDKs that have it), so piped, CI and daemon runs never load the native library (9bb03d5667). - There's no JDK API that identifies the JVM's original stdout once a host has replaced it, so color is now opt-in: `new IO()` and the stream constructor are plain, as they were on master, and only an IO from the new `IO.forConsole()`, which groovydoc's `Main` uses, can color. The Ant task and anything else that goes through `Logger` never load JLine (9bb03d5667). This adds public methods on `IO`; `IO` isn't in the ABI registry. - The console is created lazily, as Paul suggested (4f31e60c14). `out` and `err` stay plain and `ansiSupported` stays final, decided without opening the console. `Logger` opens the console through the new `IO.getAnsiOut()` on its first colored line, and prints plain text if the console can't render ANSI or `System.out` has been replaced since the IO was created. A groovydoc run that logs nothing never opens it. - The `groovydoc` and `groovydoc.bat` launchers pass `--enable-native-access=ALL-UNNAMED`, as `groovysh` does (e2c0a85070). - New forked tests: `System.out` replaced before `Logger` creates its IO and replaced before the first line, the console still closed when nothing has been logged, `strip` mode, and Jansi off the classpath. The redirected test also asserts that no console was opened and no restricted-method warning appears on stderr. Each of these fails when the check it covers is disabled. - `ansiSupported`'s Javadoc now says what it decides, and that `out` and `err` are always plain. Checked in a pseudo-terminal on JDK 25 and 17: `groovydoc --debug` is colored on a terminal and plain when piped or with `-Djansi.mode=strip`, with no warning in either case, and a run that logs nothing sends no terminal probe. The one remaining case is code that calls `IO.forConsole()` itself on a JDK 24+ terminal without `--enable-native-access`, which gets the warning on its first colored line. That would be the release-note item. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
