JDK-8228448 : Jconsole can't connect to itself
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: svc
  • Affected Version: 11,14
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2019-07-19
  • Updated: 2020-11-12
  • Resolved: 2019-12-06
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 11 JDK 13 JDK 14
11.0.9-oracleFixed 13.0.6Fixed 14 b27Fixed
Description
When you start JConsole, a list is shown of the JVMs you can connect to (obtained from VirtualMachine.list()), but since JDK 9, it is not possible to attach to yourself, so when you try, it fails without any explanation.

It is possible to override this behavior by specifying -Djdk.attach.allowAttachSelf=true at command line. It would be good if this was added to jconsole launcher, located at:
 
make/launcher/Launcher-jdk.jconsole.gmk

Self-attach was blocked to prevent users from programatically breaking the integrity of the runtime by loading an agent into the current VM. This is not an issue for jconsole

An alternative would be remove the running process from the list you see in start dialog, but it is very convenient to have it for demo purposes, tutorials and exploration of JDK MBeans, so I don't think that is the correct action to take. 
Comments
Fix request (13u) on behalf of Olga Mikhaltsova I'd like to port the fix to jdk13u, too. The patch applied cleanly.
12-11-2020

Fix request (11u) -- will label after testing completed. I would like to downport this for parity with 11.0.9-oracle. I had to do a trivial resolve: http://mail.openjdk.java.net/pipermail/jdk-updates-dev/2020-June/003341.html
22-06-2020

URL: https://hg.openjdk.java.net/jdk/jdk/rev/d6fe7d58d994 User: rraghavan Date: 2019-12-06 08:16:17 +0000
06-12-2019

I support this. I was exploring monitoring tools recently and wish they were easier to explore. I wondered why visualvm was able to explore itself, but not jconsole.
04-12-2019

It's convenient for tutorials, demos and to discover MBeans (which you may want to access programmatically). There is no need to start a separate process. Both VisualVM and JMC allows this.
09-11-2019

I think this sets a bad precedence, why would a jconsole user want to connect to itself? Is this for testing MXBeans in the current VM?
07-11-2019