RFR: 8255934: JConsole 14 and greater fails to connect to older JVM
Alex Menkov
amenkov at openjdk.java.net
Fri Nov 20 22:13:11 UTC 2020
On Fri, 20 Nov 2020 21:55:43 GMT, Chris Plummer <cjplummer at openjdk.org> wrote:
>> OperatingSystemMXBean was changed in jdk14 (see JDK-8226575):
>> New methods getTotalMemorySize and getFreeMemorySize were added, old getTotalPhysicalMemorySize and getFreePhysicalMemorySize were deprecated.
>>
>> The fix adds fallbacks for the values (i.e. if new methods fail, jconsole calls old methods)
>
> src/jdk.jconsole/share/classes/sun/tools/jconsole/SummaryTab.java line 268:
>
>> 266: sunOSMBean::getTotalPhysicalMemorySize),
>> 267: tryToGet(sunOSMBean::getFreeMemorySize,
>> 268: sunOSMBean::getFreePhysicalMemorySize),
>
> What happens if/when `getTotalPhysicalMemorySize()` and `getFreePhysicalMemorySize()` are removed. This code will fail to compile, right? I guess at that point the fix would be to try the new API, and if it throws an exception, then just use -1. In other words, there would be no way to get the value from older JVMs.
Yes, that's right. If/when the methods are removed, this code will require an update too.
But I think it would be better to show the values as long as the methods exist
-------------
PR: https://git.openjdk.java.net/jdk/pull/1243
More information about the serviceability-dev
mailing list