8213323: sa/TestJmapCoreMetaspace.java and sa/TestJmapCore.java fail with ZGC
Avoid creating the hprof file and throw an exception in HeapHprofBinWriter for ZGC and handle this in the TestJmap* testcases Reviewed-by: gadams, jcbeyler, cjplummer
This commit is contained in:
parent
54dda86a98
commit
ea532aa075
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2004, 2018, 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
|
||||
@ -182,7 +182,7 @@ public class JMap extends Tool {
|
||||
hgw.write(fileName);
|
||||
System.out.println("heap written to " + fileName);
|
||||
return true;
|
||||
} catch (IOException exp) {
|
||||
} catch (IOException | RuntimeException exp) {
|
||||
System.err.println(exp.getMessage());
|
||||
return false;
|
||||
}
|
||||
|
@ -32,6 +32,7 @@ import sun.jvm.hotspot.memory.*;
|
||||
import sun.jvm.hotspot.oops.*;
|
||||
import sun.jvm.hotspot.runtime.*;
|
||||
import sun.jvm.hotspot.classfile.*;
|
||||
import sun.jvm.hotspot.gc.z.ZCollectedHeap;
|
||||
|
||||
/*
|
||||
* This class writes Java heap in hprof binary format. This format is
|
||||
@ -388,11 +389,15 @@ public class HeapHprofBinWriter extends AbstractHeapGraphWriter {
|
||||
}
|
||||
|
||||
public synchronized void write(String fileName) throws IOException {
|
||||
VM vm = VM.getVM();
|
||||
if (vm.getUniverse().heap() instanceof ZCollectedHeap) {
|
||||
throw new RuntimeException("This operation is not supported with ZGC.");
|
||||
}
|
||||
|
||||
// open file stream and create buffered data output stream
|
||||
fos = new FileOutputStream(fileName);
|
||||
out = new DataOutputStream(new BufferedOutputStream(fos));
|
||||
|
||||
VM vm = VM.getVM();
|
||||
dbg = vm.getDebugger();
|
||||
objectHeap = vm.getObjectHeap();
|
||||
|
||||
|
@ -37,6 +37,7 @@ import jdk.test.lib.classloader.GeneratingClassLoader;
|
||||
import jdk.test.lib.hprof.HprofParser;
|
||||
import jdk.test.lib.process.ProcessTools;
|
||||
import jdk.test.lib.process.OutputAnalyzer;
|
||||
import jdk.test.lib.Utils;
|
||||
import jtreg.SkippedException;
|
||||
|
||||
import java.io.File;
|
||||
@ -134,10 +135,24 @@ public class TestJmapCore {
|
||||
System.out.println(out.getStdout());
|
||||
System.err.println(out.getStderr());
|
||||
|
||||
Asserts.assertTrue(dumpFile.exists() && dumpFile.isFile(),
|
||||
"Could not find dump file " + dumpFile.getAbsolutePath());
|
||||
if (dumpFile.exists() && dumpFile.isFile()) {
|
||||
HprofParser.parse(dumpFile);
|
||||
} else {
|
||||
boolean ZGCUsed = false;
|
||||
|
||||
for (String opt: Utils.getFilteredTestJavaOpts()) {
|
||||
if (opt.contains("+UseZGC")) {
|
||||
ZGCUsed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!ZGCUsed) {
|
||||
throw new RuntimeException(
|
||||
"Could not find dump file " + dumpFile.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
|
||||
HprofParser.parse(dumpFile);
|
||||
System.out.println("PASSED");
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user