Ghidra is a software reverse engineering (SRE) framework
GP-2269: Preventing AWTError when checking Taskbar.isTaskbarSupported()
Ryan Kurtz6845463e064c
diff --git a/Ghidra/Framework/Utility/src/main/java/ghidra/Ghidra.java b/Ghidra/Framework/Utility/src/main/java/ghidra/Ghidra.javaindex 5c9e5ce985..9b9bc35e9b 100644--- a/Ghidra/Framework/Utility/src/main/java/ghidra/Ghidra.java+++ b/Ghidra/Framework/Utility/src/main/java/ghidra/Ghidra.java@@ -15,6 +15,7 @@*/package ghidra;+import java.awt.AWTError;import java.awt.Taskbar;/**@@ -41,9 +42,13 @@ public class Ghidra {// fully qualified class name (with . replaced by -). If we don't do this here, the next// time it gets done is in a new thread, which results in the application name being set to// "java-lang-thread".- if (!Boolean.getBoolean("java.awt.headless")) {+ try {Taskbar.isTaskbarSupported();}+ catch (AWTError e) {+ // This can happen if we are running in a headless environment. We don't need to+ // worry about setting the application name in this case.+ }// Forward args to GhidraLauncher, which will perform the launchGhidraLauncher.launch(args);diff --git a/Ghidra/RuntimeScripts/Linux/support/analyzeHeadless b/Ghidra/RuntimeScripts/Linux/support/analyzeHeadlessindex f7d05f8d59..4ce2c330dd 100755--- a/Ghidra/RuntimeScripts/Linux/support/analyzeHeadless+++ b/Ghidra/RuntimeScripts/Linux/support/analyzeHeadless@@ -15,14 +15,10 @@ LAUNCH_MODE=fg# NOTE: This variable is ignored if not launching in a debugging mode.DEBUG_ADDRESS=127.0.0.1:13002-# Run Java in headless mode-VMARG_LIST="-Djava.awt.headless=true "-# Limit the # of garbage collection and JIT compiler threads in case many headless# instances are run in parallel. By default, Java will assign one thread per core# which does not scale well on servers with many cores.-VMARG_LIST+="-XX:ParallelGCThreads=2 "-VMARG_LIST+="-XX:CICompilerCount=2 "+VMARG_LIST="-XX:ParallelGCThreads=2 -XX:CICompilerCount=2 "# Resolve symbolic link if present and get the directory this script lives in.# NOTE: "readlink -f" is best but works on Linux only, "readlink" will only work if your PWDdiff --git a/Ghidra/RuntimeScripts/Windows/support/analyzeHeadless.bat b/Ghidra/RuntimeScripts/Windows/support/analyzeHeadless.batindex 2df715a609..e577293f24 100644--- a/Ghidra/RuntimeScripts/Windows/support/analyzeHeadless.bat+++ b/Ghidra/RuntimeScripts/Windows/support/analyzeHeadless.bat@@ -16,14 +16,10 @@ set LAUNCH_MODE=fg:: NOTE: This variable is ignored if not launching in a debugging mode.set DEBUG_ADDRESS=127.0.0.1:13002-:: Run Java in headless mode-set VMARG_LIST=-Djava.awt.headless=true-:: Limit the # of garbage collection and JIT compiler threads in case many headless:: instances are run in parallel. By default, Java will assign one thread per core:: which does not scale well on servers with many cores.-set VMARG_LIST=%VMARG_LIST% -XX:ParallelGCThreads=2-set VMARG_LIST=%VMARG_LIST% -XX:CICompilerCount=2+set VMARG_LIST=-XX:ParallelGCThreads=2 -XX:CICompilerCount=2:: Store current path (%0 gets modified below by SHIFT)set "SCRIPT_DIR=%~dp0"