From 7ac4926d72f3ce3051787629a021d5f3f3adfdf2 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Tue, 15 Oct 2024 15:12:32 -0500 Subject: [PATCH] ShadowMenu: load icon resources more robustly The Types.load method may not use the correct class loader. --- src/main/java/org/scijava/menu/ShadowMenu.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/scijava/menu/ShadowMenu.java b/src/main/java/org/scijava/menu/ShadowMenu.java index f6b6e53db..ce5d8e3cc 100644 --- a/src/main/java/org/scijava/menu/ShadowMenu.java +++ b/src/main/java/org/scijava/menu/ShadowMenu.java @@ -230,9 +230,8 @@ 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); @@ -240,7 +239,8 @@ public URL getIconURL() { 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;