JDK-7023754 : Jconsole javascript plugin demo throws exception on window.print
  • Type: Bug
  • Component: tools
  • Sub-Component: jconsole
  • Affected Version: 7
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2011-03-02
  • Updated: 2014-05-09
  • Resolved: 2013-08-21
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 7
7u60 b01Fixed
Related Reports
Duplicate :  
Description
Found in jdk7-u21 b02

If i follow the readme.txt in the demo/scripting/jconsole-plugin directory to 
* start jconsole with the script-plugin, 
* then type "load()" in the Script Shell-tab to get the file chooser, 
* choose hello.js (which calls echo defined in javascript.js)

The following exception occur:
Exception in thread "AWT-EventQueue-0" java.lang.reflect.UndeclaredThrowableException
	at $Proxy13.run(Unknown Source)
	at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:660)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:211)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
Caused by: java.security.PrivilegedActionException: javax.script.ScriptException: sun.org.mozilla.javascript.internal.EvaluatorException: Can't find method javax.swing.JComponent.print(string). (<built-in jconsole.js>#781) in <built-in jconsole.js> at line number 781
	at java.security.AccessController.doPrivileged(Native Method)
	at com.sun.script.util.InterfaceImplementor$InterfaceImplementorInvocationHandler.invoke(InterfaceImplementor.java:66)
	... 9 more
Caused by: javax.script.ScriptException: sun.org.mozilla.javascript.internal.EvaluatorException: Can't find method javax.swing.JComponent.print(string). (<built-in jconsole.js>#781) in <built-in jconsole.js> at line number 781
	at com.sun.script.javascript.RhinoScriptEngine.invoke(RhinoScriptEngine.java:226)
	at com.sun.script.javascript.RhinoScriptEngine.invokeMethod(RhinoScriptEngine.java:192)
	at com.sun.script.util.InterfaceImplementor$InterfaceImplementorInvocationHandler$1.run(InterfaceImplementor.java:71)
	... 11 more

Didn't happen on 1.6.0-b105 at least.

Comments
Verified 7u60 b01 windows 7
10-12-2013

See my comment above: This issue is fixed in "8016531: jconsole-plugin script demo does not work with nashorn"
30-10-2013

does this need fixing in jdk8 ? If so, create a backport, if not, add "8-na"
25-10-2013

Sundararajan, I had a fix ready, when I saw your fix ;) I refactored out a public Window class so the ScriptShellPanel isn't exposed at all to the script.
07-08-2013

This issue is fixed in "8016531: jconsole-plugin script demo does not work with nashorn" To fix this particular window.print issue, I have made ScriptShellPanel class "public". Script should allow only public methods/field access on public classes (which explains why Component.print is matched when ScriptShellPanel is non-public)
07-08-2013

Impact=High, can't use script plugin Likelihood=Low, only happens with script plugn Workaround=High, no known workaround exists HLH => P2. This is also a regression
31-07-2013

The problem is that instead of ScriptShellPanel.print() method Rhino interpreter tries to invoke JComponent.print() method which does not exist. This happens only since JDK7 (6u39 works properly, didn't check 6-open). Maybe while making project open-source and moving some classes to the closed part something was broken.
21-12-2012

ScriptJConsolePlugin.getTabs() creates window = new ScriptShellPanel(this); placed it to hashTab: tabs = new HashMap<String, JPanel>(); tabs.put("Script Shell", window);
23-10-2012

EVALUATION echo function in jconsole.js uses windows.print(String), but we down't have such function anymore.
20-03-2012