Review request for 8016531: jconsole-plugin script demo does not work with nashorn
Andreas Rieber
rieberandreas at gmail.com
Sun Aug 4 06:18:16 PDT 2013
Hi Sundar,
thanks that you had this issue still on your list. I checked it again as
it is already a few days old. There are some fixes missing in
src/share/demo/scripting/jconsole-plugin/src/resources/jconsole.js
So i took your change, retested everything and added a few missing
lines, updated the readme + comments. The updated webrev is here:
http://cr.openjdk.java.net/~arieber/8016531/webrev.01/
On 02.08.13 16:55, A. Sundararajan wrote:
> Please review http://cr.openjdk.java.net/~sundar/8016531/
>
> This fix was contributed by Andreas Rieber ( arieber ).
>
> I combined another one fix by Andreas for :
>
> 7023754 : Jconsole javascript plugin demo throws exception on
> window.print
>
> as well as that fix is to make a class 'public' and the issue is related
> anyway.
>
> Thanks
> -Sundar
For those who want to test, i recorded the required steps here.
To start the jconsole plugin:
./JDK_HOME/bin/jconsole -pluginpath
JDK_HOME/demo/scripting/jconsole-plugin/jconsole-plugin.jar
This will start jconsole and ask for a new connection. Just connect to
jconsole itself or any other process you might have running (i use a
tomcat). If it says: "Secure connection failed...", use the insecure
connection.
To test 7023754 click on the "Script Shell" tab (and one click in the
empty window to get the focus), then type: help() RETURN. You will see
a list of available functions.
To test the jconsole scripts with Nashorn, copy the following lines
into the jconsole "Script Shell" panel (update your jdk8tl path):
----------------------------------------------------------------------
// set your jdk8tl path
var src =
"/usr/local/src/jdk8tl/jdk/src/share/demo/scripting/jconsole-plugin/src/scripts/";
// write a heapdump to /tmp
load(src + "heapdump.js");
heapdump("/tmp/heapdump");
print("heapdump done");
// prints "hello, world"
load(src + "hello.js");
print("hello done");
// reset the thread count
load(src + "invoke.js");
resetPeakThreadCount()
print("resetPeakThreadCount done");
// print a stack every 1 second for 5 seconds
load(src + "jstack.js");
var t = setInterval(function () { jstack(); }, 1000);
sleep(5000);
clearInterval(t);
print("jstack done");
// print jtop every 1 second for 5 seconds
load(src + "jtop.js");
var t = setInterval(function () { jtop(); }, 1000);
sleep(5000);
clearInterval(t);
print("jtop done");
// print sysprops every 1 seconds for 5 seconds
load(src + "sysprops.js");
var t = setInterval(function () { sysprops(); }, 1000);
sleep(5000);
clearInterval(t);
print("sysprops done");
// to see some GC logs on the shell where jconsole was started
load(src + "verbose.js");
verboseGC(true)
print("verboseGC done");
print("all done");
----------------------------------------------------------------------
That was the easy part, now you can also run this scripts with
scriptpad via jrunscript. Here how it goes:
Start a demo with jmx remote port 1090 in a 2nd shell:
./JDK_HOME/bin/java -Dcom.sun.management.jmxremote.port=1090
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false -jar
JDK_HOME/demo/jfc/Font2DTest/Font2DTest.jar
In your 1st shell go to the scriptpad samples:
cd JDK_HOME/sample/scripting/scriptpad/src/resources
./JDK_HOME/bin/jrunscript -f Main.js -f -
In the menu use: "Tools->JMX Connect" and type "localhost:1090".
It should say "connected!".
Now copy the following lines and hit CTRL-R to run it (update your
jdk8tl path):
----------------------------------------------------------------------
// set your jdk8tl path
var src =
"/usr/local/src/jdk8tl/jdk/src/share/demo/scripting/jconsole-plugin/src/scripts/";
// print a stack every 1 second for 5 seconds
load(src + "jstack.js");
var t = setInterval(function () { jstack(print); }, 1000);
sleep(5000);
clearInterval(t);
----------------------------------------------------------------------
happy scripting
Andreas
More information about the nashorn-dev
mailing list