Skip to content

Commit

Permalink
8237542: JMapHeapConfigTest.java doesn't work with negative jlong values
Browse files Browse the repository at this point in the history
Reviewed-by: sspitsyn, shade
  • Loading branch information
plummercj committed Aug 25, 2023
1 parent d0cc043 commit 8a5db6b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -280,14 +280,10 @@ private void printValMB(String title, long value) {
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) {
Expand Down
15 changes: 9 additions & 6 deletions test/jdk/sun/tools/jhsdb/heapconfig/JMapHeapConfigTest.java
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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";

Expand Down Expand Up @@ -152,6 +150,11 @@ public static void main(String[] args) throws Exception {
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<String,String> parsedJmapOutput = parseJMapOutput(tmt.getToolOutput());
Map<String,String> parsedVMOutput = tmt.parseFlagsFinal();

Expand Down

1 comment on commit 8a5db6b

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.