Path: blob/master/test/functional/RasapiTest/dummy_src/com/ibm/jvm/Dump.java
6005 views
/*******************************************************************************1* Copyright (c) 2006, 2021 IBM Corp. and others2*3* This program and the accompanying materials are made available under4* the terms of the Eclipse Public License 2.0 which accompanies this5* distribution and is available at https://www.eclipse.org/legal/epl-2.0/6* or the Apache License, Version 2.0 which accompanies this distribution and7* is available at https://www.apache.org/licenses/LICENSE-2.0.8*9* This Source Code may also be made available under the following10* Secondary Licenses when the conditions for such availability set11* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU12* General Public License, version 2 with the GNU Classpath13* Exception [1] and GNU General Public License, version 2 with the14* OpenJDK Assembly Exception [2].15*16* [1] https://www.gnu.org/software/classpath/license.html17* [2] http://openjdk.java.net/legal/assembly-exception.html18*19* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception20*******************************************************************************/21package com.ibm.jvm;2223import java.security.AccessController;24import java.security.PrivilegedAction;2526/**27* This class is used to trigger and configure the options used to produce different28* types of diagnostic dumps available from the IBM JVM.29* <p>30* -Xdump must be enabled on the command line or the functions that attempt to cause31* dumps to be created or set options will fail with a java.lang.RuntimeException.32* <p>33* The methods on this class can be used to trigger dumps, configure dump options and34* query those options.35* <p>36* The {@link #JavaDump()}, {@link #SystemDump()}, {@link #HeapDump()} and {@link #SnapDump()}37* methods trigger dumps of the given type with no options and no return value.38* Although they are not configurable they do provide an easy API to use via reflection39* if your code is likely to run on both IBM and non-IBM JVMs and you only need the most40* basic ability to create a dump.41* <p>42* The {@link #javaDumpToFile()}, {@link #systemDumpToFile()}, {@link #heapDumpToFile()} and43* {@link #snapDumpToFile()} methods allow a destination file to be optionally specified and44* will return the full path of the file that is created.45* <br>46* The recommended usage of the {@link #javaDumpToFile()}, {@link #systemDumpToFile()},47* {@link #heapDumpToFile()} and {@link #snapDumpToFile()}48* methods is to call the no argument versions of these calls rather than specifying a file49* name as this will trigger a dump to the default location. Your dump file will go to the50* default location specified by any -Xdump options given to the JVM at startup time following51* the user or administrators preferences.52* The location the dump file was written to will be returned as a String so the generated53* file can be located.54* <p>55* The {@link #triggerDump(String)} method offers similar functionality as the DumpToFile() methods56* but with the ability to specify any dump options that are meaningful for a dump that occurs57* immediately. The options are passed as a String that follows the same format as the option58* strings passed to -Xdump on the command line.<br>59* For example:60* <ul>61* <li>triggerDump("java") is equivalent to javaDumpToFile() or javaDumpToFile(null) all three62* will cause a javadump to be generated to the default location.</li>63* <li>triggerDump("heap:file=heapdump.phd") is equivalent to heapDumpToFile("heapdump.phd")</li>64* <li>triggerDump("heap:file=heapdump.txt,opts=CLASSIC") allows you to specify the CLASSIC65* option to triggerDump and produce a text format heap dump which is not possible through66* the *DumpToFile(String filename) or *Dump() methods.</li>67* <li>triggerDump("java:request=exclusive") will trigger a java dump with the request option set68* to "exclusive" and any other options, including the file name, taken from the default options69* for java dumps</li>70* </ul>71* <p>72* The {@link #setDumpOptions(String)} method allows dump options that will cause or change how73* a dump occurs for an event in the future to be specified. The options are specified in the74* format expected by the -Xdump command line. Not all options can be configured at runtime and75* this method will throw an InvalidDumpOption exception if it is passed an option that cannot be set.<p>76* For example:77* <ul>78* <li>setDumpOptions("java") - enable java dumps with the default settings.</li>79* <li>setDumpOptions("java:events=vmstop") - enable java dumps on the vmstop event (this will80* occur once when the JVM exits).</li>81* <li>setDumpOptions("none") - disable all dump agents on all events.</li>82* <li>setDumpOptions("heap:none") - disable all heap dump agents on all events.</li>83* <li>setDumpOptions("system:none:events=systhrow,filter=java/lang/OutOfMemoryError") - disable84* system dumps on systhrow events for OutOfMemory errors only.</li>85* </ul>86* For full details of dump options see the section on dump agents in the documentation for the IBM JVM.87* <p>88* The {@link #queryDumpOptions()} method returns a String array containing a snapshot of the currently89* configured dump options. Each String is in the format expected by the -Xdump command line90* option and setDumpOptions. The Strings can be passed back to setDumpOptions to recreate91* the current dump agent configuration at a later time.92* <p>93* The {@link #resetDumpOptions()} method resets the dump options to the settings specified when the94* JVM was started removing any additional configuration done since then.<br>95* If you wish to change the dump configuration at runtime and then reset it to an earlier96* state that included additional runtime configuration done through this API or JVMTI you should97* consider saving the result of queryDumpOptions and then later use {@link #setDumpOptions(String)}98* to restore that configuration after a call to setDumpOptions("none") to clear all dump agent99* configuration.100*/101public class Dump {102103public static void JavaDump() {104}105106public static void HeapDump() {107}108109public static void SystemDump() {110}111112private Dump() {113}114115public static void SnapDump() {116}117118public static String javaDumpToFile(String fileNamePattern ) throws InvalidDumpOptionException {119return null;120}121122public static String javaDumpToFile() {123return null;124}125126public static String heapDumpToFile(String fileNamePattern ) throws InvalidDumpOptionException {127return null;128}129130public static String heapDumpToFile() {131return null;132}133134135public static String systemDumpToFile(String fileNamePattern) throws InvalidDumpOptionException {136return null; }137138public static String systemDumpToFile() {139return null;140}141public static String snapDumpToFile(String fileNamePattern) throws InvalidDumpOptionException {142return null;143}144public static String snapDumpToFile() {145return null;146}147148public static String triggerDump(String dumpOptions) throws InvalidDumpOptionException {149return null;150}151152public static void setDumpOptions(String dumpOptions) throws InvalidDumpOptionException, DumpConfigurationUnavailableException {153}154155public static String[] queryDumpOptions() {156return null;157}158159public static void resetDumpOptions() throws DumpConfigurationUnavailableException {160}161162}163164165