GP-1304: Removing illegal access to java.desktop/sun.awt.X11. Has side

effect of changing application name on Linux from "Ghidra" to
"ghidra.Ghidra".
This commit is contained in:
Ryan Kurtz 2021-09-16 14:22:34 -04:00
parent 1508f3fee8
commit e088d2a4ea
11 changed files with 91 additions and 33 deletions

View file

@ -0,0 +1,49 @@
/* ###
* IP: GHIDRA
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ghidra;
import java.awt.Taskbar;
/**
* Ghidra entry point that forwards the command line arguments to {@link GhidraLaunchable}.
* <p>
* This class was introduced so Ghidra's application name can be set to "ghidra-Ghidra" on Linux,
* rather than "ghidra-GhidraLauncher".
* @see <a href="https://bugs.java.com/bugdatabase/view_bug.do?bug_id=6528430">JDK-6528430</a>
*/
public class Ghidra {
/**
* Launches the given {@link GhidraLaunchable} specified in the first command line argument
*
* @param args The first argument is the name of the {@link GhidraLaunchable} to launch.
* The remaining args get passed through to the class's {@link GhidraLaunchable#launch}
* method.
* @throws Exception If there was a problem launching. See the exception's message for more
* details on what went wrong.
*/
public static void main(String[] args) throws Exception {
// Poke the Taskbar class in order to set the Linux application name to this class's
// 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".
Taskbar.isTaskbarSupported();
// Forward args to GhidraLauncher, which will perform the launch
GhidraLauncher.launch(args);
}
}

View file

@ -42,7 +42,7 @@ public class GhidraLauncher {
* @throws Exception If there was a problem launching. See the exception's message for more
* details on what went wrong.
*/
public static void main(String[] args) throws Exception {
public static void launch(String[] args) throws Exception {
// Initialize the Ghidra environment
GhidraApplicationLayout layout = initializeGhidraEnvironment();
@ -59,6 +59,21 @@ public class GhidraLauncher {
launchable.launch(layout, Arrays.copyOfRange(args, 1, args.length));
}
/**
* Launches the given {@link GhidraLaunchable} specified in the first command line argument
*
* @param args The first argument is the name of the {@link GhidraLaunchable} to launch.
* The remaining args get passed through to the class's {@link GhidraLaunchable#launch}
* method.
* @throws Exception If there was a problem launching. See the exception's message for more
* details on what went wrong.
* @deprecated Use {@link Ghidra#main(String[])} instead
*/
@Deprecated(since = "10.1", forRemoval = true)
public static void main(String[] args) throws Exception {
launch(args);
}
/**
* Initializes the Ghidra environment by discovering its {@link GhidraApplicationLayout layout}
* and adding all relevant modules and libraries to the classpath