8344569: SwingUtilities2.makeIcon_Unprivileged is obsolete

Reviewed-by: psadhukhan
This commit is contained in:
Phil Race 2024-11-21 16:02:28 +00:00
parent 882d635807
commit eef156180c
2 changed files with 2 additions and 36 deletions

View File

@ -469,7 +469,7 @@ public abstract class LookAndFeel
* @see Class#getResourceAsStream(String)
*/
public static Object makeIcon(final Class<?> baseClass, final String gifFile) {
return SwingUtilities2.makeIcon_Unprivileged(baseClass, baseClass, gifFile);
return SwingUtilities2.makeIcon(baseClass, baseClass, gifFile);
}
/**

View File

@ -1671,42 +1671,8 @@ public class SwingUtilities2 {
public static Object makeIcon(final Class<?> baseClass,
final Class<?> rootClass,
final String imageFile) {
return makeIcon(baseClass, rootClass, imageFile, true);
}
/**
* Utility method that creates a {@code UIDefaults.LazyValue} that
* creates an {@code ImageIcon} {@code UIResource} for the
* specified image file name. The image is loaded using
* {@code getResourceAsStream}, starting with a call to that method
* on the base class parameter. If it cannot be found, searching will
* continue through the base class' inheritance hierarchy, up to and
* including {@code rootClass}.
*
* Finds an image with a given name without privileges enabled.
*
* @param baseClass the first class to use in searching for the resource
* @param rootClass an ancestor of {@code baseClass} to finish the
* search at
* @param imageFile the name of the file to be found
* @return a lazy value that creates the {@code ImageIcon}
* {@code UIResource} for the image,
* or null if it cannot be found
*/
public static Object makeIcon_Unprivileged(final Class<?> baseClass,
final Class<?> rootClass,
final String imageFile) {
return makeIcon(baseClass, rootClass, imageFile, false);
}
private static Object makeIcon(final Class<?> baseClass,
final Class<?> rootClass,
final String imageFile,
final boolean enablePrivileges) {
return (UIDefaults.LazyValue) (table) -> {
byte[] buffer = enablePrivileges ?
getIconBytes(baseClass, rootClass, imageFile)
: getIconBytes(baseClass, rootClass, imageFile);
byte[] buffer = getIconBytes(baseClass, rootClass, imageFile);
if (buffer == null) {
return null;