Changeset 14978 in josm for trunk


Ignore:
Timestamp:
2019-04-09T19:37:28+02:00 (5 years ago)
Author:
Don-vip
Message:

fix #17574 - fix IAE when plugins modify preferences (regression from r14977)

Location:
trunk/src/org/openstreetmap/josm
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/Preferences.java

    r14977 r14978  
    228228
    229229    protected void firePreferenceChanged(String key, Setting<?> oldValue, Setting<?> newValue) {
     230        final Class<?> source = ReflectionUtils.findCallerClass(preferencesClasses);
    230231        final PreferenceChangeEvent evt =
    231                 new DefaultPreferenceChangeEvent(ReflectionUtils.findCallerClass(preferencesClasses), key, oldValue, newValue);
     232                new DefaultPreferenceChangeEvent(source != null ? source : getClass(), key, oldValue, newValue);
    232233        listeners.fireEvent(listener -> listener.preferenceChanged(evt));
    233234
  • trunk/src/org/openstreetmap/josm/plugins/PluginHandler.java

    r14962 r14978  
    300300    }
    301301
     302    /**
     303     * Plugin class loaders.
     304     */
     305    private static final Map<PluginInformation, PluginClassLoader> classLoaders = new HashMap<>();
     306
    302307    private static PluginDownloadTask pluginDownloadTask;
    303308
     
    317322    public static Collection<ClassLoader> getResourceClassLoaders() {
    318323        return Collections.unmodifiableCollection(sources);
     324    }
     325
     326    /**
     327     * Returns all plugin classloaders.
     328     * @return all plugin classloaders
     329     * @since 14978
     330     */
     331    public static Collection<PluginClassLoader> getPluginClassLoaders() {
     332        return Collections.unmodifiableCollection(classLoaders.values());
    319333    }
    320334
     
    837851                return;
    838852
    839             Map<PluginInformation, PluginClassLoader> classLoaders = new HashMap<>();
     853            classLoaders.clear();
    840854            for (PluginInformation info : toLoad) {
    841855                PluginClassLoader cl = AccessController.doPrivileged((PrivilegedAction<PluginClassLoader>)
  • trunk/src/org/openstreetmap/josm/tools/ReflectionUtils.java

    r14977 r14978  
    77import java.util.Collection;
    88import java.util.function.Function;
     9
     10import org.openstreetmap.josm.plugins.PluginHandler;
    911
    1012/**
     
    4648                return Class.forName(x.getClassName());
    4749            } catch (ClassNotFoundException e) {
     50                for (ClassLoader cl : PluginHandler.getPluginClassLoaders()) {
     51                    try {
     52                        return Class.forName(x.getClassName(), true, cl);
     53                    } catch (ClassNotFoundException ex) {
     54                        Logging.trace(ex);
     55                    }
     56                }
    4857                Logging.error(e);
    4958                return null;
Note: See TracChangeset for help on using the changeset viewer.