Changeset 14232 in josm for trunk/src/org/openstreetmap


Ignore:
Timestamp:
2018-09-09T00:50:46+02:00 (6 years ago)
Author:
Don-vip
Message:

see #16047 - make JOSM able to load JAXB as a plugin:

  • JAXB initialize itself through ServiceLoader and context class loader so it must be set correctly when initializing a plugin
  • plugin class loaders were not loading resources correctly
Location:
trunk/src/org/openstreetmap/josm/plugins
Files:
2 edited

Legend:

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

    r13849 r14232  
    8181
    8282    @Override
     83    public URL findResource(String name) {
     84        URL resource = super.findResource(name);
     85        if (resource == null) {
     86            for (PluginClassLoader dep : dependencies) {
     87                resource = dep.findResource(name);
     88                if (resource != null) {
     89                    break;
     90                }
     91            }
     92        }
     93        return resource;
     94    }
     95
     96    @Override
    8397    public String toString() {
    8498        return "PluginClassLoader [urls=" + Arrays.toString(getURLs()) +
  • trunk/src/org/openstreetmap/josm/plugins/PluginInformation.java

    r14186 r14232  
    345345        try {
    346346            Constructor<?> c = klass.getConstructor(PluginInformation.class);
    347             Object plugin = c.newInstance(this);
    348             return new PluginProxy(plugin, this, classLoader);
     347            ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
     348            Thread.currentThread().setContextClassLoader(classLoader);
     349            try {
     350                return new PluginProxy(c.newInstance(this), this, classLoader);
     351            } finally {
     352                Thread.currentThread().setContextClassLoader(contextClassLoader);
     353            }
    349354        } catch (ReflectiveOperationException e) {
    350355            throw new PluginException(name, e);
Note: See TracChangeset for help on using the changeset viewer.