1 /* 2 * Copyright (c) 2005, 2012, 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 26 package com.sun.management; 27 28 import java.util.List; 29 import java.lang.management.PlatformManagedObject; 30 31 /** 32 * Diagnostic management interface for the HotSpot Virtual Machine. 33 * 34 * <p>The diagnostic MBean is registered to the platform MBeanServer 35 * as are other platform MBeans. 36 * 37 * <p>The <tt>ObjectName</tt> for uniquely identifying the diagnostic 38 * MXBean within an MBeanServer is: 39 * <blockquote> 40 * <tt>com.sun.management:type=HotSpotDiagnostic</tt> 41 * </blockquote> 42 .* 43 * It can be obtained by calling the 44 * {@link PlatformManagedObject#getObjectName} method. 45 * 46 * All methods throw a {@code NullPointerException} if any input argument is 47 * {@code null} unless it's stated otherwise. 48 * 49 * @see ManagementFactory#getPlatformMXBeans(Class) 50 */ 51 public interface HotSpotDiagnosticMXBean extends PlatformManagedObject { 52 /** 53 * Dumps the heap to the <tt>outputFile</tt> file in the same 54 * format as the hprof heap dump. 55 * <p> 56 * If this method is called remotely from another process, 57 * the heap dump output is written to a file named <tt>outputFile</tt> 58 * on the machine where the target VM is running. If outputFile is 59 * a relative path, it is relative to the working directory where 60 * the target VM was started. 61 * 62 * @param outputFile the system-dependent filename 63 * @param live if <tt>true</tt> dump only <i>live</i> objects 64 * i.e. objects that are reachable from others 65 * @throws IOException if the <tt>outputFile</tt> 66 * cannot be created, opened, or written to. 67 * @throws UnsupportedOperationException if this operation is not supported. 68 * @throws NullPointerException if <tt>outputFile</tt> is <tt>null</tt>. 69 */ 70 public void dumpHeap(String outputFile, boolean live) throws java.io.IOException; 71 72 /** 73 * Returns a list of <tt>VMOption</tt> objects for all diagnostic options. 74 * A diagnostic option is a {@link VMOption#isWriteable writeable} 75 * VM option that can be set dynamically mainly for troubleshooting 76 * and diagnosis. 77 * 78 * @return a list of <tt>VMOption</tt> objects for all diagnostic options. 79 */ 80 public java.util.List<VMOption> getDiagnosticOptions(); 81 82 /** 83 * Returns a <tt>VMOption</tt> object for a VM option of the given 84 * name. 85 * 86 * @return a <tt>VMOption</tt> object for a VM option of the given name. 87 * @throws NullPointerException if name is <tt>null</tt>. 88 * @throws IllegalArgumentException if a VM option of the given name 89 * does not exist. 90 */ 91 public VMOption getVMOption(String name); 92 93 /** 94 * Sets a VM option of the given name to the specified value. 95 * The new value will be reflected in a new <tt>VMOption</tt> 96 * object returned by the {@link #getVMOption} method or 97 * the {@link #getDiagnosticOptions} method. This method does 98 * not change the value of this <tt>VMOption</tt> object. 99 * 100 * @param name Name of a VM option 101 * @param value New value of the VM option to be set 102 * 103 * @throws IllegalArgumentException if the VM option of the given name 104 * does not exist. 105 * @throws IllegalArgumentException if the new value is invalid. 106 * @throws IllegalArgumentException if the VM option is not writeable. 107 * @throws NullPointerException if name or value is <tt>null</tt>. 108 * 109 * @throws java.lang.SecurityException 110 * if a security manager exists and the caller does not have 111 * ManagementPermission("control"). 112 */ 113 public void setVMOption(String name, String value); 114 }