This content has been marked as final. Show 4 replies
Both JConsole and JVisualVM use non-standardized Sun-only APIs to achieve this effect.
I don't remember what it is called, but I think it's bundled in tools.jar.
For a fun exercise try this:
The JConsole code checks at runtime if the necessary class is available and disables the feature if it isn't.
$ jconsole # note how you get the feature $ java -jar PATH_TO_JDK_LIB_DIRECTORY/jconsole.jar # note how you DONT get the feature $ java -cp PATH_TO_JDK_LIB_DIRECTORY/jconsole.jar:PATH_TO_JDK_LIB_DIRECTORY/tools.jar sun.tools.jconsole.JConsole # note how you get the feature again
Now it's a simple case of checking the JConsole path to find that codepath.
kajbj wrote:Looks like it.
I'm not sure, but I think that they are using the Attach API.
Seems like I've been spreading outdated info.
From what I've gathered: In Java 5 they used a proprietary, undocumented, internal API to achieve the goal and in Java 6 they used the Sun-specific, but documented Attach API ...