Dirk,
Dirk Stöcker wrote:
To make it simpler I added the addProjections() function myself in
r3872. I don't understand what is so complicated about this function
that 3 people failed to do it, one of them the original maintainer. :-)
I didn't know Imi was still on board ;)
Thank you for trying to help but it seems to me that things are not so
easy.
The problem is that JOSM's class loader seems to prevent it from
instantiating a class defined in a plugin. I wrote a plugin that
provides a custom projection, FredProjection. In the plugin's
constructor I call your addProjection() method. Just to be safe, I put a
println in my plugin, and sure enough it prints:
loaded class org.openstreetmap.josm.plugins.fredprojection.FredProjection
But milliseconds later, as it executes line 359 of Main.java,
ProjectionPreference.setProjection();
it catches an exception:
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)
...
(the printStackTrace was added by me, normally it would only show a
dialog saying "the projection cannot be loaded, using Mercator").
Initially I thought that was because the above happens in
preConstructorInit() which is executed before loading plugins, but I
have flagged my plugin as "Early Plugin" (<attribute name="Plugin-Early"
value="true"/> in the Manifest), and these are loaded before the
preConstructorInit.
So, even though my plugin is loaded, and indeed manages to add an
instance of its projection to your projection list, the attempt to call
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.
Bye
Frederik
--
Frederik Ramm ## eMail frede...@remote.org ## N49°00'09" E008°23'33"
_______________________________________________
josm-dev mailing list
josm-dev@openstreetmap.org
http://lists.openstreetmap.org/listinfo/josm-dev