Changeset 12323 in josm


Ignore:
Timestamp:
2017-06-06T19:43:38+02:00 (7 years ago)
Author:
bastiK
Message:

see #14901 - some cleanup

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/plugins/PluginClassLoader.java

    r12322 r12323  
    5050                    return result;
    5151                }
    52             } catch (ClassNotFoundException e) {}
     52            } catch (ClassNotFoundException e) {
     53                // do nothing
     54            }
    5355        }
    5456        Class<?> result = super.loadClass(name, resolve);
  • trunk/src/org/openstreetmap/josm/plugins/PluginHandler.java

    r12322 r12323  
    827827            Map<PluginInformation, PluginClassLoader> classLoaders = new HashMap<>();
    828828            for (PluginInformation info : toLoad) {
    829                 classLoaders.put(info, new PluginClassLoader(
     829                PluginClassLoader cl = AccessController.doPrivileged((PrivilegedAction<PluginClassLoader>)
     830                    () -> new PluginClassLoader(
    830831                        info.libraries.toArray(new URL[0]),
    831832                        Main.class.getClassLoader(),
    832833                        null));
     834                classLoaders.put(info, cl);
    833835            }
    834836
     
    12131215    }
    12141216
     1217    /**
     1218     * Returns the plugin class loader for the plugin of the specified name.
     1219     * @param name The plugin name
     1220     * @return The plugin class loader for the plugin of the specified name, if
     1221     * installed and loaded, or {@code null} otherwise.
     1222     * @since 12323
     1223     */
     1224    public static PluginClassLoader getPluginClassLoader(String name) {
     1225        for (PluginProxy plugin : pluginList) {
     1226            if (plugin.getPluginInformation().name.equals(name))
     1227                return plugin.getClassLoader();
     1228        }
     1229        return null;
     1230    }
     1231
    12151232    public static void addDownloadSelection(List<DownloadSelection> downloadSelections) {
    12161233        for (PluginProxy p : pluginList) {
  • trunk/test/unit/org/openstreetmap/josm/plugins/PluginHandlerTestIT.java

    r10988 r12323  
    127127
    128128    private static String findFaultyPlugin(Collection<PluginInformation> plugins, Throwable root) {
    129         DynamicURLClassLoader cl = PluginHandler.getPluginClassLoader();
    130129        for (PluginInformation p : plugins) {
    131130            try {
     131                ClassLoader cl = PluginHandler.getPluginClassLoader(p.getName());
    132132                String pluginPackage = cl.loadClass(p.className).getPackage().getName();
    133133                for (StackTraceElement e : root.getStackTrace()) {
Note: See TracChangeset for help on using the changeset viewer.