1/* 2 * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26package com.sun.management; 27 28import java.lang.management.PlatformManagedObject; 29 30/** 31 * Diagnostic management interface for the HotSpot Virtual Machine. 32 * 33 * <p>The diagnostic MBean is registered to the platform MBeanServer 34 * as are other platform MBeans. 35 * 36 * <p>The {@code ObjectName} for uniquely identifying the diagnostic 37 * MXBean within an MBeanServer is: 38 * <blockquote> 39 * {@code com.sun.management:type=HotSpotDiagnostic} 40 * </blockquote> 41.* 42 * It can be obtained by calling the 43 * {@link PlatformManagedObject#getObjectName} method. 44 * 45 * All methods throw a {@code NullPointerException} if any input argument is 46 * {@code null} unless it's stated otherwise. 47 * 48 * @see java.lang.management.ManagementFactory#getPlatformMXBeans(Class) 49 */ 50public interface HotSpotDiagnosticMXBean extends PlatformManagedObject { 51 /** 52 * Dumps the heap to the {@code outputFile} file in the same 53 * format as the hprof heap dump. 54 * <p> 55 * If this method is called remotely from another process, 56 * the heap dump output is written to a file named {@code outputFile} 57 * on the machine where the target VM is running. If outputFile is 58 * a relative path, it is relative to the working directory where 59 * the target VM was started. 60 * 61 * @param outputFile the system-dependent filename 62 * @param live if {@code true} dump only <i>live</i> objects 63 * i.e. objects that are reachable from others 64 * @throws IOException if the {@code outputFile} already exists, 65 * cannot be created, opened, or written to. 66 * @throws UnsupportedOperationException if this operation is not supported. 67 * @throws IllegalArgumentException if {@code outputFile} does not end with ".hprof" suffix. 68 * @throws NullPointerException if {@code outputFile} is {@code null}. 69 * @throws SecurityException 70 * If a security manager exists and its {@link 71 * java.lang.SecurityManager#checkWrite(java.lang.String)} 72 * method denies write access to the named file 73 * or the caller does not have ManagmentPermission("control"). 74 */ 75 public void dumpHeap(String outputFile, boolean live) throws java.io.IOException; 76 77 /** 78 * Returns a list of {@code VMOption} objects for all diagnostic options. 79 * A diagnostic option is a {@link VMOption#isWriteable writeable} 80 * VM option that can be set dynamically mainly for troubleshooting 81 * and diagnosis. 82 * 83 * @return a list of {@code VMOption} objects for all diagnostic options. 84 */ 85 public java.util.List<VMOption> getDiagnosticOptions(); 86 87 /** 88 * Returns a {@code VMOption} object for a VM option of the given 89 * name. 90 * 91 * @return a {@code VMOption} object for a VM option of the given name. 92 * @throws NullPointerException if name is {@code null}. 93 * @throws IllegalArgumentException if a VM option of the given name 94 * does not exist. 95 */ 96 public VMOption getVMOption(String name); 97 98 /** 99 * Sets a VM option of the given name to the specified value. 100 * The new value will be reflected in a new {@code VMOption} 101 * object returned by the {@link #getVMOption} method or 102 * the {@link #getDiagnosticOptions} method. This method does 103 * not change the value of this {@code VMOption} object. 104 * 105 * @param name Name of a VM option 106 * @param value New value of the VM option to be set 107 * 108 * @throws IllegalArgumentException if the VM option of the given name 109 * does not exist. 110 * @throws IllegalArgumentException if the new value is invalid. 111 * @throws IllegalArgumentException if the VM option is not writable. 112 * @throws NullPointerException if name or value is {@code null}. 113 * 114 * @throws java.lang.SecurityException 115 * if a security manager exists and the caller does not have 116 * ManagementPermission("control"). 117 */ 118 public void setVMOption(String name, String value); 119} 120