diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/HeapSummary.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/HeapSummary.java index c586a20e866..83a820eed07 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/HeapSummary.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/HeapSummary.java @@ -280,14 +280,10 @@ public class HeapSummary extends Tool { printValMB(System.out, title, value); } - private static final double FACTOR = 1024*1024; private void printValMB(PrintStream tty, String title, long value) { - if (value < 0) { - tty.println(alignment + title + (value >>> 20) + " MB"); - } else { - double mb = value/FACTOR; - tty.println(alignment + title + value + " (" + mb + "MB)"); - } + double valueMB = value >>> 20; // unsigned divide by 1024*1024 + String valueUnsigned = Long.toUnsignedString(value, 10); + tty.println(alignment + title + valueUnsigned + " (" + valueMB + "MB)"); } private void printValue(String title, long value) { diff --git a/test/jdk/sun/tools/jhsdb/heapconfig/JMapHeapConfigTest.java b/test/jdk/sun/tools/jhsdb/heapconfig/JMapHeapConfigTest.java index 119ab55afca..53330c08618 100644 --- a/test/jdk/sun/tools/jhsdb/heapconfig/JMapHeapConfigTest.java +++ b/test/jdk/sun/tools/jhsdb/heapconfig/JMapHeapConfigTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2023, 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 @@ -53,15 +53,13 @@ public class JMapHeapConfigTest { "MaxHeapFreeRatio", "MaxHeapSize", "NewSize", + "MaxNewSize", "OldSize", "NewRatio", "SurvivorRatio", "MetaspaceSize", - "CompressedClassSpaceSize"}; - - // Test can't deal with negative jlongs: - // ignoring MaxMetaspaceSize - // ignoring MaxNewSize + "CompressedClassSpaceSize", + "MaxMetaspaceSize"}; static final String desiredMaxHeapSize = "-Xmx128m"; @@ -152,6 +150,11 @@ public class JMapHeapConfigTest { throw new RuntimeException("Test FAILED jmap exits with non zero exit code " + exitcode); } + System.out.println("Jmap Output:"); + for (String line : tmt.getToolOutput()) { + System.out.println(line); + } + Map parsedJmapOutput = parseJMapOutput(tmt.getToolOutput()); Map parsedVMOutput = tmt.parseFlagsFinal();