Gubaer / josm-scripting-plugin

Task automation in the OpenStreetMap editor JOSM
https://gubaer.github.io/josm-scripting-plugin
GNU General Public License v3.0
26 stars 9 forks source link

Console.clear() doesn't work #104

Closed pl71 closed 1 year ago

pl71 commented 1 year ago
import * as console from 'josm/scriptingconsole'
console.print('Hello world!')
console.clear()

The above code will print "Hello world!", but will throw an error on console.clear():

TypeError: invokeMember (getInstance) on org.openstreetmap.josm.plugins.scripting.ui.console.ScriptingConsole failed due to: Unknown identifier: getInstance
josm/scriptingconsole: line=91
Unnamed: line=3
--------------------------------------------------------
org.openstreetmap.josm.plugins.scripting.graalvm.GraalVMEvalException: failed to eval script
    at org.openstreetmap.josm.plugins.scripting.graalvm.GraalVMFacade.eval(GraalVMFacade.java:184)
    at org.openstreetmap.josm.plugins.scripting.ui.ScriptExecutor.lambda$runScriptWithGraalEngine$2(ScriptExecutor.java:243)
    at org.openstreetmap.josm.plugins.scripting.ui.ScriptExecutor.runOnSwingEDT(ScriptExecutor.java:108)
    at org.openstreetmap.josm.plugins.scripting.ui.ScriptExecutor.runScriptWithGraalEngine(ScriptExecutor.java:250)
    at org.openstreetmap.josm.plugins.scripting.ui.console.ScriptingConsolePanel$RunScriptAction.actionPerformed(ScriptingConsolePanel.java:236)
    at java.desktop/javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1972)
    at java.desktop/javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2313)
    at java.desktop/javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:405)
    at java.desktop/javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:262)
    at java.desktop/javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:279)
    at java.desktop/java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:297)
    at java.desktop/java.awt.Component.processMouseEvent(Component.java:6626)
    at java.desktop/javax.swing.JComponent.processMouseEvent(JComponent.java:3389)
    at java.desktop/java.awt.Component.processEvent(Component.java:6391)
    at java.desktop/java.awt.Container.processEvent(Container.java:2266)
    at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:5001)
    at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2324)
    at java.desktop/java.awt.Component.dispatchEvent(Component.java:4833)
    at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4948)
    at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Container.java:4575)
    at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Container.java:4516)
    at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2310)
    at java.desktop/java.awt.Window.dispatchEventImpl(Window.java:2780)
    at java.desktop/java.awt.Component.dispatchEvent(Component.java:4833)
    at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:773)
    at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:722)
    at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:716)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
    at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
    at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:97)
    at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:746)
    at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:744)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
    at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
    at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:743)
    at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
Caused by: org.graalvm.polyglot.PolyglotException: TypeError: invokeMember (getInstance) on org.openstreetmap.josm.plugins.scripting.ui.console.ScriptingConsole failed due to: Unknown identifier: getInstance
    at <js>.clear(josm/scriptingconsole:91)
    at <js>.:module:eval(Unnamed:3)
    at org.graalvm.sdk/org.graalvm.polyglot.Context.eval(Context.java:399)
    at org.openstreetmap.josm.plugins.scripting.graalvm.GraalVMFacade.eval(GraalVMFacade.java:172)
    ... 40 more

Scriptng plugin 0.2.7

Identification: JOSM/1.5 (18746 bg) Windows 10 64-Bit OS Build number: Windows 10 Education 2009 (19044) Memory Usage: 1814 MB / 4014 MB (1061 MB allocated, but free) Java version: 17.0.7+7-jvmci-22.3-b18, GraalVM Community, OpenJDK 64-Bit Server VM

Gubaer commented 1 year ago

Should be fixed in release v0.2.8