Closed AndrewKvalheim closed 2 years ago
I'm currently working on a new version of the scripting plugin, which will replace Rhino with GraalJS.
Unfortunately, the version with GraalJS will be less convenient than the current version. Due to class loading issues, I can't ship GraalJS as part of the plugin jar. In the future, users will have to start JOSM with GraalJS already on the classpath. They will either have to use the GraalVM java
executable or java
from another JDK, which is started with the GraalJS .jar
dependencies on the classpath.
I today released v0.2.0 of the plugin. It's the first release to support GraalJS as scripting engine. Mozilla Rhino is now deprecated and I plan to remove it together with the JavaScript API V1 end of 2022.
Clipboard access seems to work with GraalJS and the JavaScript API V2. Here's an example:
Amazing, thank you.
With plugin version 30798 in JOSM 18387 on JDK 11, using the clipboard API (as in the example) causes a warning:
On JDK 17, strong encapsulation is enabled by default so it now fails:
I’ve found that starting JOSM with the following Java options allows it to work—
--add-opens java.desktop/sun.awt.datatransfer=ALL-UNNAMED
--add-opens java.desktop/sun.awt.X11=ALL-UNNAMED
—but I’m not sure what an appropriate solution would look like, e.g. using some other API internally, adding those permissions via some kind of plugin metadata or initialization step, adding them in JOSM, just documenting that they’re necessary, contacting the maintainers of
org.mozilla.javascript.MemberBox
as instructed above, updating to a newer version of that library, etc.