Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed isJansiConsoleInstalled performance issue #1976

Merged
merged 8 commits into from
Mar 24, 2023
7 changes: 7 additions & 0 deletions src/main/java/picocli/CommandLine.java
Original file line number Diff line number Diff line change
Expand Up @@ -17805,7 +17805,14 @@ static boolean ansiPossible() {
if (!isTTY() && !isPseudoTTY()) { return false; }
return hintEnabled() || !isWindows() || isXterm() || isCygwin() || hasOsType();
}
/** Cache the result for isJansiConsoleInstalled so it doesn't repeatedly
* call Class#forName, which can cause performance issues. */
static Boolean jansiConsole;
static boolean isJansiConsoleInstalled() {
if (jansiConsole == null) { jansiConsole = calcIsJansiConsoleInstalled(); }
return jansiConsole;
}
static boolean calcIsJansiConsoleInstalled() {
try {
// first check if JANSI was explicitly disabled _without loading any JANSI classes_:
// see https://github.com/remkop/picocli/issues/1106
Expand Down