Skip to content

Commit

Permalink
ShadowMenu: load icon resources more robustly
Browse files Browse the repository at this point in the history
The Types.load method may not use the correct class loader.
  • Loading branch information
ctrueden committed Oct 15, 2024
1 parent ee1e7c1 commit 7ac4926
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/main/java/org/scijava/menu/ShadowMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -230,17 +230,17 @@ public URL getIconURL() {
if (isLeaf()) iconPath = DEFAULT_ICON_PATH;
else return null;
}
final String className = moduleInfo.getDelegateClassName();
try {
final Class<?> c = Types.load(className, false);
final Class<?> c = moduleInfo.loadDelegateClass();
final URL iconURL = c.getResource(iconPath);
if (iconURL == null) {
if (log != null) log.error("Could not load icon: " + iconPath);
}
return iconURL;
}
catch (final IllegalArgumentException exc) {
final String message = "Could not load icon for class: " + className;
final String message = "Could not load icon for class: " +
moduleInfo.getDelegateClassName();
if (log.isDebug()) log.debug(message, exc);
else log.error(message);
return null;
Expand Down

0 comments on commit 7ac4926

Please sign in to comment.