Cross Plugin use of classes
Paul Wölfel
paul at woelfel.at
Sat Jul 15 19:03:41 UTC 2017
I think I found the cause of my issue, it is the plugin ClassLoader change
in 12322 (
https://josm.openstreetmap.de/changeset?sfp_email=&sfph_mail=&reponame=josm&new=12322%40trunk&old=12321%40trunk)
which relates to #14901 (https://josm.openstreetmap.de/ticket/14901).
I've added austriaaddresshelper to the required plugins (
https://github.com/JOSM/areaselector/commit/2f08c13dd0f5d9fd3cb2b62e6091bd696f0f8a8c),
but I'm still not able to access the class.
<property name="plugin.requires" value="log4j;austriaaddresshelper"/>
If I read the code diff of 12322 (
https://josm.openstreetmap.de/changeset?sfp_email=&sfph_mail=&reponame=josm&new=12322%40trunk&old=12321%40trunk)
correctly, this should do the trick, but it's still not working out.
for (String depName : info.getRequiredPlugins()) {
Is there someone who can help me with that issue, or should I open a bug
tracker?
Paul Wölfel <paul at woelfel.at> schrieb am Sa., 15. Juli 2017 um 20:27 Uhr:
> Hi Josm Devs!
>
> TLDR: I can't access any classes from other plugins, I receive a
> ClassNotFoundException.
> This did work before (working on 12321, broken on 12327)
>
> I wanted to update the areaselector plugin (
> https://github.com/JOSM/areaselector) and include new functionality which
> is based on utilsplugin2. I am able to compile my code, but on runtime it
> failed to load the ReplaceGeometryUtils class with a
> ClassNotFoundException. The strange thing is, that the utilsplugin2 had
> already been loaded and included in the requirements of areaselector. With
> a reference to ReplaceGeometryUtils my plugin failed to load with a
> ClassNotFoundException even if the class was not accessed.(
> https://github.com/JOSM/areaselector/blob/master/src/org/openstreetmap/josm/plugins/areaselector/AreaSelectorPlugin.java#L39)
> As this did not work I implemented the logic myself.
>
> I'm using a second optional plugin called austriaaddresshelper (
> https://github.com/JOSM/austriaaddresshelper). This did work before and I
> was getting a ClassNotFoundException, if the plugin wasn't loaded. This
> exception is thrown at AreaSelectorAction line 263 (
> https://github.com/JOSM/areaselector/blob/master/src/org/openstreetmap/josm/plugins/areaselector/AreaSelectorAction.java#L263
> ).
>
> Starting from some version after 12327 of JOSM a ClassNotFoundException is
> thrown, even if the plugin is loaded and can be used. I even played around
> with the Scripting plugin and
> Class.forName("org.openstreetmap.josm.plugins.austriaaddresshelper.AustriaAddressHelperAction")
> or even
> Class.forName("org.openstreetmap.josm.plugins.areaselector.AreaSelectorAction")
> always fails.
>
> So finally my question:
> Have there been any changes to the ClassLoader which prevent accessing
> classes from another plugin and how can I fix this?
>
> This issue can be reproduced with the Scripting plugin an Groovy with this
> simple line of Code (you need areaselector plugin installed):
> println
> Class.forName("org.openstreetmap.josm.plugins.areaselector.AreaSelectorAction").toString()
>
> Script execution has failed.
> javax.script.ScriptException: javax.script.ScriptException:
> java.lang.ClassNotFoundException:
> org.openstreetmap.josm.plugins.areaselector.AreaSelectorAction
> at
> org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:155)
>
>
>
> --
>
>
> Mit freundlichen Grüßen
> Paul Wölfel
>
> Email paul at woelfel.at
> Tel. +43 664 88 533 801
> Pappelweg 9/2/6
> 7100 Neusiedl am See
> Austria
>
--
Mit freundlichen Grüßen
Paul Wölfel
Email paul at woelfel.at
Tel. +43 664 88 533 801
Pappelweg 9/2/6
7100 Neusiedl am See
Austria
More information about the josm-dev
mailing list