Merge remote-tracking branch 'origin/patch'

This commit is contained in:
ghidra1
2026-05-27 16:13:13 -04:00
38 changed files with 341 additions and 413 deletions

View File

@@ -1,13 +1,12 @@
/* ###
* IP: GHIDRA
* REVIEWED: YES
*
* 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.
@@ -18,8 +17,10 @@ package ghidra.app.util.headless;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.lang.reflect.InvocationTargetException;
import java.util.Locale;
import ghidra.util.classfinder.ClassSearcher;
import sun.java2d.HeadlessGraphicsEnvironment;
public class MyHeadlessGraphicsEnvironment extends GraphicsEnvironment {
@@ -78,17 +79,23 @@ public class MyHeadlessGraphicsEnvironment extends GraphicsEnvironment {
private void getRealGraphicsEnvironemnt() {
try {
localEnv = (GraphicsEnvironment) Class.forName(preferredGraphicsEnv).newInstance();
localEnv = ClassSearcher
.forNameSafe(preferredGraphicsEnv, GraphicsEnvironment.class,
getClass().getClassLoader())
.getConstructor()
.newInstance();
if (isHeadless()) {
localEnv = new HeadlessGraphicsEnvironment(localEnv);
}
} catch (ClassNotFoundException e) {
}
catch (ClassNotFoundException e) {
throw new Error("Could not find class: " + preferredGraphicsEnv);
} catch (InstantiationException e) {
}
catch (InstantiationException | NoSuchMethodException | InvocationTargetException e) {
throw new Error("Could not instantiate Graphics Environment: " + preferredGraphicsEnv);
} catch (IllegalAccessException e) {
}
catch (IllegalAccessException e) {
throw new Error("Could not access Graphics Environment: " + preferredGraphicsEnv);
}
}
}

View File

@@ -4,9 +4,9 @@
* 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.
@@ -22,10 +22,12 @@ import java.awt.datatransfer.Clipboard;
import java.awt.font.TextAttribute;
import java.awt.im.InputMethodHighlight;
import java.awt.image.*;
import java.lang.reflect.InvocationTargetException;
import java.net.URL;
import java.util.Map;
import java.util.Properties;
import ghidra.util.classfinder.ClassSearcher;
import sun.awt.HeadlessToolkit;
public class MyHeadlessToolkit extends Toolkit {
@@ -163,22 +165,23 @@ public class MyHeadlessToolkit extends Toolkit {
private void getRealToolkit() {
Class<?> cls = null;
Class<? extends Toolkit> cls = null;
try {
try {
cls = Class.forName(preferredToolkit);
cls = ClassSearcher.forNameSafe(preferredToolkit, Toolkit.class,
getClass().getClassLoader());
}
catch (ClassNotFoundException ee) {
throw new AWTError("Toolkit not found: " + preferredToolkit);
}
if (cls != null) {
localToolKit = (Toolkit) cls.newInstance();
localToolKit = cls.getConstructor().newInstance();
if (GraphicsEnvironment.isHeadless()) {
localToolKit = new HeadlessToolkit(localToolKit);
}
}
}
catch (InstantiationException e) {
catch (InstantiationException | NoSuchMethodException | InvocationTargetException e) {
throw new AWTError("Could not instantiate Toolkit: " + preferredToolkit);
}
catch (IllegalAccessException e) {