< prev index next >

test/com/sun/management/HotSpotDiagnosticMXBean/DumpHeap.java

Print this page
rev 17272 : 8181391: remove explicit @build actions for the top level testlibary classes
Reviewed-by: duke


  23 
  24 import static jdk.testlibrary.Asserts.assertTrue;
  25 import static jdk.testlibrary.Asserts.fail;
  26 
  27 import java.io.File;
  28 import java.lang.management.*;
  29 import java.util.List;
  30 
  31 import jdk.test.lib.hprof.HprofParser;
  32 import jdk.testlibrary.ProcessTools;
  33 
  34 import com.sun.management.HotSpotDiagnosticMXBean;
  35 
  36 /*
  37  * @test
  38  * @bug 6455258
  39  * @summary Sanity test for com.sun.management.HotSpotDiagnosticMXBean.dumpHeap method
  40  * @library /lib/testlibrary
  41  * @library /test/lib
  42  * @build jdk.testlibrary.*
  43  * @build jdk.test.lib.hprof.*
  44  * @build jdk.test.lib.hprof.model.*
  45  * @build jdk.test.lib.hprof.parser.*
  46  * @build jdk.test.lib.hprof.util.*
  47  * @run main DumpHeap
  48  */
  49 public class DumpHeap {
  50 
  51     public static void main(String[] args) throws Exception {
  52         List<HotSpotDiagnosticMXBean> list = ManagementFactory.getPlatformMXBeans(HotSpotDiagnosticMXBean.class);
  53         File dump = new File(ProcessTools.getProcessId() + ".hprof");
  54         if (dump.exists()) {
  55             dump.delete();
  56         }
  57         System.out.println("Dumping to file: " + dump.getAbsolutePath());
  58         list.get(0).dumpHeap(dump.getAbsolutePath(), true);
  59 
  60         verifyDumpFile(dump);
  61 
  62         dump.delete();
  63     }
  64 
  65     private static void verifyDumpFile(File dump) {
  66         assertTrue(dump.exists() && dump.isFile(), "Could not create dump file");


  23 
  24 import static jdk.testlibrary.Asserts.assertTrue;
  25 import static jdk.testlibrary.Asserts.fail;
  26 
  27 import java.io.File;
  28 import java.lang.management.*;
  29 import java.util.List;
  30 
  31 import jdk.test.lib.hprof.HprofParser;
  32 import jdk.testlibrary.ProcessTools;
  33 
  34 import com.sun.management.HotSpotDiagnosticMXBean;
  35 
  36 /*
  37  * @test
  38  * @bug 6455258
  39  * @summary Sanity test for com.sun.management.HotSpotDiagnosticMXBean.dumpHeap method
  40  * @library /lib/testlibrary
  41  * @library /test/lib
  42  * @build jdk.testlibrary.*




  43  * @run main DumpHeap
  44  */
  45 public class DumpHeap {
  46 
  47     public static void main(String[] args) throws Exception {
  48         List<HotSpotDiagnosticMXBean> list = ManagementFactory.getPlatformMXBeans(HotSpotDiagnosticMXBean.class);
  49         File dump = new File(ProcessTools.getProcessId() + ".hprof");
  50         if (dump.exists()) {
  51             dump.delete();
  52         }
  53         System.out.println("Dumping to file: " + dump.getAbsolutePath());
  54         list.get(0).dumpHeap(dump.getAbsolutePath(), true);
  55 
  56         verifyDumpFile(dump);
  57 
  58         dump.delete();
  59     }
  60 
  61     private static void verifyDumpFile(File dump) {
  62         assertTrue(dump.exists() && dump.isFile(), "Could not create dump file");
< prev index next >