Frederik Ramm wrote:
Dirk,

[...]

java.lang.ClassNotFoundException: org.openstreetmap.josm.plugins.fredprojection.FredProjection
        at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:169)
at org.openstreetmap.josm.gui.preferences.ProjectionPreference.setProjection(ProjectionPreference.java:206)

[...]


Class.forName(name).newInstance();

for the name of my projection (which is derived from that very instance!) fails. I'm afraid that my Java skills stop there - somehow the default class loader does not know about classes added by plugins, and would need to be made aware of them.

There are two approaches possible for this problem.
The simpler one would be to change ProjectionPreference to not call Class.forName(), but instead getProjections(), and iterate the registered _instances_ until getClass().getName() matches.

The more complex, but generally preferable (as it would solve many similar problems once for good) would be to code a delegating class loader that would try to fulfill the load request by trying each plugin's loader in sequence. This overall loader would be then set as the context class loader of every thread. Similar to http://hg.netbeans.org/main/file/tip/o.n.bootstrap/src/org/netbeans/ProxyClassLoader.java but many many revisions ago (before the packageCoverage optimization was implemented) and simplified...

Regards,
  Nenik

_______________________________________________
josm-dev mailing list
[email protected]
http://lists.openstreetmap.org/listinfo/josm-dev

Reply via email to