diff --git a/src/jdk.jconsole/share/classes/sun/tools/jconsole/ProxyClient.java b/src/jdk.jconsole/share/classes/sun/tools/jconsole/ProxyClient.java index ec2290421a4bd..0ff2d0e366588 100644 --- a/src/jdk.jconsole/share/classes/sun/tools/jconsole/ProxyClient.java +++ b/src/jdk.jconsole/share/classes/sun/tools/jconsole/ProxyClient.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,6 +34,7 @@ import static java.lang.management.ManagementFactory.*; import java.lang.ref.WeakReference; import java.lang.reflect.*; +import java.net.URI; import java.rmi.*; import java.rmi.registry.*; import java.rmi.server.*; @@ -133,7 +134,24 @@ private ProxyClient(String url, this.advancedUrl = url; this.connectionName = getConnectionName(url, userName); this.displayName = connectionName; - setParameters(new JMXServiceURL(url), userName, password); + JMXServiceURL jmxServiceURL = new JMXServiceURL(url); + setParameters(jmxServiceURL, userName, password); + if ("rmi".equals(jmxServiceURL.getProtocol())) { + String path = jmxServiceURL.getURLPath(); + if (path.startsWith("/jndi/")) { + int end = path.indexOf(';'); + if (end < 0) end = path.length(); + String registryURIStr = path.substring(6, end); + URI registryURI = URI.create(registryURIStr); + if ("rmi".equals(registryURI.getScheme()) + && "/jmxrmi".equals(registryURI.getPath())) { + this.registryHostName = registryURI.getHost(); + this.registryPort = registryURI.getPort(); + this.vmConnector = true; + checkSslConfig(); + } + } + } } private ProxyClient(LocalVirtualMachine lvm) throws IOException {