feat(jdk8): move files to new folder to avoid resources compiled.

This commit is contained in:
2025-09-07 15:25:52 +08:00
parent 3f0047bf6f
commit 8c35cfb1c0
17415 changed files with 217 additions and 213 deletions

View File

@@ -0,0 +1,220 @@
/*
* Copyright (c) 2013, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.management;
import java.lang.management.PlatformManagedObject;
import javax.management.DynamicMBean;
/**
* Management interface for the diagnostic commands for the HotSpot Virtual Machine.
*
* <p>The {code DiagnosticCommandMBean} is registered to the
* {@linkplain java.lang.management.ManagementFactory#getPlatformMBeanServer
* platform MBeanServer} as are other platform MBeans.
*
* <p>The {@link javax.management.ObjectName ObjectName} for uniquely identifying
* the diagnostic MBean within an MBeanServer is:
* <blockquote>
* {@code com.sun.management:type=DiagnosticCommand}
* </blockquote>
*
* <p>This MBean is a {@link javax.management.DynamicMBean DynamicMBean}
* and also a {@link javax.management.NotificationEmitter}.
* The {@code DiagnosticCommandMBean} is generated at runtime and is subject to
* modifications during the lifetime of the Java virtual machine.
*
* A <em>diagnostic command</em> is represented as an operation of
* the {@code DiagnosticCommandMBean} interface. Each diagnostic command has:
* <ul>
* <li>the diagnostic command name which is the name being referenced in
* the HotSpot Virtual Machine</li>
* <li>the MBean operation name which is the
* {@linkplain javax.management.MBeanOperationInfo#getName() name}
* generated for the diagnostic command operation invocation.
* The MBean operation name is implementation dependent</li>
* </ul>
*
* The recommended way to transform a diagnostic command name into a MBean
* operation name is as follows:
* <ul>
* <li>All characters from the first one to the first dot are set to be
* lower-case characters</li>
* <li>Every dot or underline character is removed and the following
* character is set to be an upper-case character</li>
* <li>All other characters are copied without modification</li>
* </ul>
*
* <p>The diagnostic command name is always provided with the meta-data on the
* operation in a field named {@code dcmd.name} (see below).
*
* <p>A diagnostic command may or may not support options or arguments.
* All the operations return {@code String} and either take
* no parameter for operations that do not support any option or argument,
* or take a {@code String[]} parameter for operations that support at least
* one option or argument.
* Each option or argument must be stored in a single String.
* Options or arguments split across several String instances are not supported.
*
* <p>The distinction between options and arguments: options are identified by
* the option name while arguments are identified by their position in the
* command line. Options and arguments are processed in the order of the array
* passed to the invocation method.
*
* <p>Like any operation of a dynamic MBean, each of these operations is
* described by {@link javax.management.MBeanOperationInfo MBeanOperationInfo}
* instance. Here's the values returned by this object:
* <ul>
* <li>{@link javax.management.MBeanOperationInfo#getName() getName()}
* returns the operation name generated from the diagnostic command name</li>
* <li>{@link javax.management.MBeanOperationInfo#getDescription() getDescription()}
* returns the diagnostic command description
* (the same as the one return in the 'help' command)</li>
* <li>{@link javax.management.MBeanOperationInfo#getImpact() getImpact()}
* returns <code>ACTION_INFO</code></li>
* <li>{@link javax.management.MBeanOperationInfo#getReturnType() getReturnType()}
* returns {@code java.lang.String}</li>
* <li>{@link javax.management.MBeanOperationInfo#getDescriptor() getDescriptor()}
* returns a Descriptor instance (see below)</li>
* </ul>
*
* <p>The {@link javax.management.Descriptor Descriptor}
* is a collection of fields containing additional
* meta-data for a JMX element. A field is a name and an associated value.
* The additional meta-data provided for an operation associated with a
* diagnostic command are described in the table below:
* <p>
*
* <table border="1" cellpadding="5">
* <tr>
* <th>Name</th><th>Type</th><th>Description</th>
* </tr>
* <tr>
* <td>dcmd.name</td><td>String</td>
* <td>The original diagnostic command name (not the operation name)</td>
* </tr>
* <tr>
* <td>dcmd.description</td><td>String</td>
* <td>The diagnostic command description</td>
* </tr>
* <tr>
* <td>dcmd.help</td><td>String</td>
* <td>The full help message for this diagnostic command (same output as
* the one produced by the 'help' command)</td>
* </tr>
* <tr>
* <td>dcmd.vmImpact</td><td>String</td>
* <td>The impact of the diagnostic command,
* this value is the same as the one printed in the 'impact'
* section of the help message of the diagnostic command, and it
* is different from the getImpact() of the MBeanOperationInfo</td>
* </tr>
* <tr>
* <td>dcmd.enabled</td><td>boolean</td>
* <td>True if the diagnostic command is enabled, false otherwise</td>
* </tr>
* <tr>
* <td>dcmd.permissionClass</td><td>String</td>
* <td>Some diagnostic command might require a specific permission to be
* executed, in addition to the MBeanPermission to invoke their
* associated MBean operation. This field returns the fully qualified
* name of the permission class or null if no permission is required
* </td>
* </tr>
* <tr>
* <td>dcmd.permissionName</td><td>String</td>
* <td>The fist argument of the permission required to execute this
* diagnostic command or null if no permission is required</td>
* </tr>
* <tr>
* <td>dcmd.permissionAction</td><td>String</td>
* <td>The second argument of the permission required to execute this
* diagnostic command or null if the permission constructor has only
* one argument (like the ManagementPermission) or if no permission
* is required</td>
* </tr>
* <tr>
* <td>dcmd.arguments</td><td>Descriptor</td>
* <td>A Descriptor instance containing the descriptions of options and
* arguments supported by the diagnostic command (see below)</td>
* </tr>
* </table>
* <p>
*
* <p>The description of parameters (options or arguments) of a diagnostic
* command is provided within a Descriptor instance. In this Descriptor,
* each field name is a parameter name, and each field value is itself
* a Descriptor instance. The fields provided in this second Descriptor
* instance are described in the table below:
*
* <table border="1" cellpadding="5">
* <tr>
* <th>Name</th><th>Type</th><th>Description</th>
* </tr>
* <tr>
* <td>dcmd.arg.name</td><td>String</td>
* <td>The name of the parameter</td>
* </tr>
* <tr>
* <td>dcmd.arg.type</td><td>String</td>
* <td>The type of the parameter. The returned String is the name of a type
* recognized by the diagnostic command parser. These types are not
* Java types and are implementation dependent.
* </td>
* </tr>
* <tr>
* <td>dcmd.arg.description</td><td>String</td>
* <td>The parameter description</td>
* </tr>
* <tr>
* <td>dcmd.arg.isMandatory</td><td>boolean</td>
* <td>True if the parameter is mandatory, false otherwise</td>
* </tr>
* <tr>
* <td>dcmd.arg.isOption</td><td>boolean</td>
* <td>True if the parameter is an option, false if it is an argument</td>
* </tr>
* <tr>
* <td>dcmd.arg.isMultiple</td><td>boolean</td>
* <td>True if the parameter can be specified several times, false
* otherwise</td>
* </tr>
* </table>
*
* <p>When the set of diagnostic commands currently supported by the Java
* Virtual Machine is modified, the {@code DiagnosticCommandMBean} emits
* a {@link javax.management.Notification} with a
* {@linkplain javax.management.Notification#getType() type} of
* <a href="{@docRoot}/../../../../api/javax/management/MBeanInfo.html#info-changed">
* {@code "jmx.mbean.info.changed"}</a> and a
* {@linkplain javax.management.Notification#getUserData() userData} that
* is the new {@code MBeanInfo}.
*
* @since 8
*/
public interface DiagnosticCommandMBean extends DynamicMBean
{
}

View File

@@ -0,0 +1,238 @@
/*
* Copyright (c) 2011, 2013, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.management;
import javax.management.Notification;
import javax.management.openmbean.CompositeData;
import javax.management.openmbean.CompositeDataView;
import javax.management.openmbean.CompositeType;
import java.util.Collection;
import java.util.Collections;
import sun.management.GarbageCollectionNotifInfoCompositeData;
/**
* The information about a garbage collection
*
* <p>
* A garbage collection notification is emitted by {@link GarbageCollectorMXBean}
* when the Java virtual machine completes a garbage collection action
* The notification emitted will contain the garbage collection notification
* information about the status of the memory:
* <u1>
* <li>The name of the garbage collector used perform the collection.</li>
* <li>The action performed by the garbage collector.</li>
* <li>The cause of the garbage collection action.</li>
* <li>A {@link GcInfo} object containing some statistics about the GC cycle
(start time, end time) and the memory usage before and after
the GC cycle.</li>
* </u1>
*
* <p>
* A {@link CompositeData CompositeData} representing
* the {@code GarbageCollectionNotificationInfo} object
* is stored in the
* {@linkplain javax.management.Notification#setUserData userdata}
* of a {@linkplain javax.management.Notification notification}.
* The {@link #from from} method is provided to convert from
* a {@code CompositeData} to a {@code GarbageCollectionNotificationInfo}
* object. For example:
*
* <blockquote><pre>
* Notification notif;
*
* // receive the notification emitted by a GarbageCollectorMXBean and set to notif
* ...
*
* String notifType = notif.getType();
* if (notifType.equals(GarbageCollectionNotificationInfo.GARBAGE_COLLECTION_NOTIFICATION)) {
* // retrieve the garbage collection notification information
* CompositeData cd = (CompositeData) notif.getUserData();
* GarbageCollectionNotificationInfo info = GarbageCollectionNotificationInfo.from(cd);
* ....
* }
* </pre></blockquote>
*
* <p>
* The type of the notification emitted by a {@code GarbageCollectorMXBean} is:
* <ul>
* <li>A {@linkplain #GARBAGE_COLLECTION_NOTIFICATION garbage collection notification}.
* <br>Used by every notification emitted by the garbage collector, the details about
* the notification are provided in the {@linkplain #getGcAction action} String
* <p></li>
* </ul>
**/
@jdk.Exported
public class GarbageCollectionNotificationInfo implements CompositeDataView {
private final String gcName;
private final String gcAction;
private final String gcCause;
private final GcInfo gcInfo;
private final CompositeData cdata;
/**
* Notification type denoting that
* the Java virtual machine has completed a garbage collection cycle.
* This notification is emitted by a {@link GarbageCollectorMXBean}.
* The value of this notification type is
* {@code com.sun.management.gc.notification}.
*/
public static final String GARBAGE_COLLECTION_NOTIFICATION =
"com.sun.management.gc.notification";
/**
* Constructs a {@code GarbageCollectionNotificationInfo} object.
*
* @param gcName The name of the garbage collector used to perform the collection
* @param gcAction The name of the action performed by the garbage collector
* @param gcCause The cause the garbage collection action
* @param gcInfo a GcInfo object providing statistics about the GC cycle
*/
public GarbageCollectionNotificationInfo(String gcName,
String gcAction,
String gcCause,
GcInfo gcInfo) {
if (gcName == null) {
throw new NullPointerException("Null gcName");
}
if (gcAction == null) {
throw new NullPointerException("Null gcAction");
}
if (gcCause == null) {
throw new NullPointerException("Null gcCause");
}
this.gcName = gcName;
this.gcAction = gcAction;
this.gcCause = gcCause;
this.gcInfo = gcInfo;
this.cdata = new GarbageCollectionNotifInfoCompositeData(this);
}
GarbageCollectionNotificationInfo(CompositeData cd) {
GarbageCollectionNotifInfoCompositeData.validateCompositeData(cd);
this.gcName = GarbageCollectionNotifInfoCompositeData.getGcName(cd);
this.gcAction = GarbageCollectionNotifInfoCompositeData.getGcAction(cd);
this.gcCause = GarbageCollectionNotifInfoCompositeData.getGcCause(cd);
this.gcInfo = GarbageCollectionNotifInfoCompositeData.getGcInfo(cd);
this.cdata = cd;
}
/**
* Returns the name of the garbage collector used to perform the collection
*
* @return the name of the garbage collector used to perform the collection
*/
public String getGcName() {
return gcName;
}
/**
* Returns the action of the performed by the garbage collector
*
* @return the the action of the performed by the garbage collector
*/
public String getGcAction() {
return gcAction;
}
/**
* Returns the cause the garbage collection
*
* @return the the cause the garbage collection
*/
public String getGcCause() {
return gcCause;
}
/**
* Returns the GC information related to the last garbage collection
*
* @return the GC information related to the
* last garbage collection
*/
public GcInfo getGcInfo() {
return gcInfo;
}
/**
* Returns a {@code GarbageCollectionNotificationInfo} object represented by the
* given {@code CompositeData}.
* The given {@code CompositeData} must contain
* the following attributes:
* <blockquote>
* <table border>
* <tr>
* <th align=left>Attribute Name</th>
* <th align=left>Type</th>
* </tr>
* <tr>
* <td>gcName</td>
* <td>{@code java.lang.String}</td>
* </tr>
* <tr>
* <td>gcAction</td>
* <td>{@code java.lang.String}</td>
* </tr>
* <tr>
* <td>gcCause</td>
* <td>{@code java.lang.String}</td>
* </tr>
* <tr>
* <td>gcInfo</td>
* <td>{@code javax.management.openmbean.CompositeData}</td>
* </tr>
* </table>
* </blockquote>
*
* @param cd {@code CompositeData} representing a
* {@code GarbageCollectionNotificationInfo}
*
* @throws IllegalArgumentException if {@code cd} does not
* represent a {@code GarbaageCollectionNotificationInfo} object.
*
* @return a {@code GarbageCollectionNotificationInfo} object represented
* by {@code cd} if {@code cd} is not {@code null};
* {@code null} otherwise.
*/
public static GarbageCollectionNotificationInfo from(CompositeData cd) {
if (cd == null) {
return null;
}
if (cd instanceof GarbageCollectionNotifInfoCompositeData) {
return ((GarbageCollectionNotifInfoCompositeData) cd).getGarbageCollectionNotifInfo();
} else {
return new GarbageCollectionNotificationInfo(cd);
}
}
public CompositeData toCompositeData(CompositeType ct) {
return cdata;
}
}

View File

@@ -0,0 +1,60 @@
/*
* Copyright (c) 2003, 2013, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.management;
import javax.management.openmbean.CompositeData;
import javax.management.openmbean.CompositeType;
/**
* Platform-specific management interface for a garbage collector
* which performs collections in cycles.
*
* <p> This platform extension is only available to the garbage
* collection implementation that supports this extension.
*
* @author Mandy Chung
* @since 1.5
*/
@jdk.Exported
public interface GarbageCollectorMXBean
extends java.lang.management.GarbageCollectorMXBean {
/**
* Returns the GC information about the most recent GC.
* This method returns a {@link GcInfo}.
* If no GC information is available, <tt>null</tt> is returned.
* The collector-specific attributes, if any, can be obtained
* via the {@link CompositeData CompositeData} interface.
* <p>
* <b>MBeanServer access:</b>
* The mapped type of <tt>GcInfo</tt> is <tt>CompositeData</tt>
* with attributes specified in {@link GcInfo#from GcInfo}.
*
* @return a <tt>GcInfo</tt> object representing
* the most GC information; or <tt>null</tt> if no GC
* information available.
*/
public GcInfo getLastGcInfo();
}

View File

@@ -0,0 +1,289 @@
/*
* Copyright (c) 2003, 2013, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.management;
import java.lang.management.MemoryUsage;
import javax.management.openmbean.CompositeData;
import javax.management.openmbean.CompositeDataView;
import javax.management.openmbean.CompositeType;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.List;
import sun.management.GcInfoCompositeData;
import sun.management.GcInfoBuilder;
/**
* Garbage collection information. It contains the following
* information for one garbage collection as well as GC-specific
* attributes:
* <blockquote>
* <ul>
* <li>Start time</li>
* <li>End time</li>
* <li>Duration</li>
* <li>Memory usage before the collection starts</li>
* <li>Memory usage after the collection ends</li>
* </ul>
* </blockquote>
*
* <p>
* <tt>GcInfo</tt> is a {@link CompositeData CompositeData}
* The GC-specific attributes can be obtained via the CompositeData
* interface. This is a historical relic, and other classes should
* not copy this pattern. Use {@link CompositeDataView} instead.
*
* <h4>MXBean Mapping</h4>
* <tt>GcInfo</tt> is mapped to a {@link CompositeData CompositeData}
* with attributes as specified in the {@link #from from} method.
*
* @author Mandy Chung
* @since 1.5
*/
@jdk.Exported
public class GcInfo implements CompositeData, CompositeDataView {
private final long index;
private final long startTime;
private final long endTime;
private final Map<String, MemoryUsage> usageBeforeGc;
private final Map<String, MemoryUsage> usageAfterGc;
private final Object[] extAttributes;
private final CompositeData cdata;
private final GcInfoBuilder builder;
private GcInfo(GcInfoBuilder builder,
long index, long startTime, long endTime,
MemoryUsage[] muBeforeGc,
MemoryUsage[] muAfterGc,
Object[] extAttributes) {
this.builder = builder;
this.index = index;
this.startTime = startTime;
this.endTime = endTime;
String[] poolNames = builder.getPoolNames();
this.usageBeforeGc = new HashMap<String, MemoryUsage>(poolNames.length);
this.usageAfterGc = new HashMap<String, MemoryUsage>(poolNames.length);
for (int i = 0; i < poolNames.length; i++) {
this.usageBeforeGc.put(poolNames[i], muBeforeGc[i]);
this.usageAfterGc.put(poolNames[i], muAfterGc[i]);
}
this.extAttributes = extAttributes;
this.cdata = new GcInfoCompositeData(this, builder, extAttributes);
}
private GcInfo(CompositeData cd) {
GcInfoCompositeData.validateCompositeData(cd);
this.index = GcInfoCompositeData.getId(cd);
this.startTime = GcInfoCompositeData.getStartTime(cd);
this.endTime = GcInfoCompositeData.getEndTime(cd);
this.usageBeforeGc = GcInfoCompositeData.getMemoryUsageBeforeGc(cd);
this.usageAfterGc = GcInfoCompositeData.getMemoryUsageAfterGc(cd);
this.extAttributes = null;
this.builder = null;
this.cdata = cd;
}
/**
* Returns the identifier of this garbage collection which is
* the number of collections that this collector has done.
*
* @return the identifier of this garbage collection which is
* the number of collections that this collector has done.
*/
public long getId() {
return index;
}
/**
* Returns the start time of this GC in milliseconds
* since the Java virtual machine was started.
*
* @return the start time of this GC.
*/
public long getStartTime() {
return startTime;
}
/**
* Returns the end time of this GC in milliseconds
* since the Java virtual machine was started.
*
* @return the end time of this GC.
*/
public long getEndTime() {
return endTime;
}
/**
* Returns the elapsed time of this GC in milliseconds.
*
* @return the elapsed time of this GC in milliseconds.
*/
public long getDuration() {
return endTime - startTime;
}
/**
* Returns the memory usage of all memory pools
* at the beginning of this GC.
* This method returns
* a <tt>Map</tt> of the name of a memory pool
* to the memory usage of the corresponding
* memory pool before GC starts.
*
* @return a <tt>Map</tt> of memory pool names to the memory
* usage of a memory pool before GC starts.
*/
public Map<String, MemoryUsage> getMemoryUsageBeforeGc() {
return Collections.unmodifiableMap(usageBeforeGc);
}
/**
* Returns the memory usage of all memory pools
* at the end of this GC.
* This method returns
* a <tt>Map</tt> of the name of a memory pool
* to the memory usage of the corresponding
* memory pool when GC finishes.
*
* @return a <tt>Map</tt> of memory pool names to the memory
* usage of a memory pool when GC finishes.
*/
public Map<String, MemoryUsage> getMemoryUsageAfterGc() {
return Collections.unmodifiableMap(usageAfterGc);
}
/**
* Returns a <tt>GcInfo</tt> object represented by the
* given <tt>CompositeData</tt>. The given
* <tt>CompositeData</tt> must contain
* all the following attributes:
*
* <p>
* <blockquote>
* <table border>
* <tr>
* <th align=left>Attribute Name</th>
* <th align=left>Type</th>
* </tr>
* <tr>
* <td>index</td>
* <td><tt>java.lang.Long</tt></td>
* </tr>
* <tr>
* <td>startTime</td>
* <td><tt>java.lang.Long</tt></td>
* </tr>
* <tr>
* <td>endTime</td>
* <td><tt>java.lang.Long</tt></td>
* </tr>
* <tr>
* <td>memoryUsageBeforeGc</td>
* <td><tt>javax.management.openmbean.TabularData</tt></td>
* </tr>
* <tr>
* <td>memoryUsageAfterGc</td>
* <td><tt>javax.management.openmbean.TabularData</tt></td>
* </tr>
* </table>
* </blockquote>
*
* @throws IllegalArgumentException if <tt>cd</tt> does not
* represent a <tt>GcInfo</tt> object with the attributes
* described above.
*
* @return a <tt>GcInfo</tt> object represented by <tt>cd</tt>
* if <tt>cd</tt> is not <tt>null</tt>; <tt>null</tt> otherwise.
*/
public static GcInfo from(CompositeData cd) {
if (cd == null) {
return null;
}
if (cd instanceof GcInfoCompositeData) {
return ((GcInfoCompositeData) cd).getGcInfo();
} else {
return new GcInfo(cd);
}
}
// Implementation of the CompositeData interface
public boolean containsKey(String key) {
return cdata.containsKey(key);
}
public boolean containsValue(Object value) {
return cdata.containsValue(value);
}
public boolean equals(Object obj) {
return cdata.equals(obj);
}
public Object get(String key) {
return cdata.get(key);
}
public Object[] getAll(String[] keys) {
return cdata.getAll(keys);
}
public CompositeType getCompositeType() {
return cdata.getCompositeType();
}
public int hashCode() {
return cdata.hashCode();
}
public String toString() {
return cdata.toString();
}
public Collection values() {
return cdata.values();
}
/**
* <p>Return the {@code CompositeData} representation of this
* {@code GcInfo}, including any GC-specific attributes. The
* returned value will have at least all the attributes described
* in the {@link #from(CompositeData) from} method, plus optionally
* other attributes.
*
* @param ct the {@code CompositeType} that the caller expects.
* This parameter is ignored and can be null.
*
* @return the {@code CompositeData} representation.
*/
public CompositeData toCompositeData(CompositeType ct) {
return cdata;
}
}

View File

@@ -0,0 +1,120 @@
/*
* Copyright (c) 2005, 2017, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.management;
import java.lang.management.PlatformManagedObject;
/**
* Diagnostic management interface for the HotSpot Virtual Machine.
*
* <p>The diagnostic MBean is registered to the platform MBeanServer
* as are other platform MBeans.
*
* <p>The <tt>ObjectName</tt> for uniquely identifying the diagnostic
* MXBean within an MBeanServer is:
* <blockquote>
* <tt>com.sun.management:type=HotSpotDiagnostic</tt>
* </blockquote>
.*
* It can be obtained by calling the
* {@link PlatformManagedObject#getObjectName} method.
*
* All methods throw a {@code NullPointerException} if any input argument is
* {@code null} unless it's stated otherwise.
*
* @see ManagementFactory#getPlatformMXBeans(Class)
*/
@jdk.Exported
public interface HotSpotDiagnosticMXBean extends PlatformManagedObject {
/**
* Dumps the heap to the <tt>outputFile</tt> file in the same
* format as the hprof heap dump.
* <p>
* If this method is called remotely from another process,
* the heap dump output is written to a file named <tt>outputFile</tt>
* on the machine where the target VM is running. If outputFile is
* a relative path, it is relative to the working directory where
* the target VM was started.
*
* @param outputFile the system-dependent filename
* @param live if <tt>true</tt> dump only <i>live</i> objects
* i.e. objects that are reachable from others
* @throws IOException if the <tt>outputFile</tt> already exists,
* cannot be created, opened, or written to.
* @throws UnsupportedOperationException if this operation is not supported.
* @throws IllegalArgumentException if <tt>outputFile</tt> does not end with ".hprof" suffix.
* @throws NullPointerException if <tt>outputFile</tt> is <tt>null</tt>.
* @throws SecurityException
* If a security manager exists and its {@link
* java.lang.SecurityManager#checkWrite(java.lang.String)}
* method denies write access to the named file
* or the caller does not have ManagmentPermission("control").
*/
public void dumpHeap(String outputFile, boolean live) throws java.io.IOException;
/**
* Returns a list of <tt>VMOption</tt> objects for all diagnostic options.
* A diagnostic option is a {@link VMOption#isWriteable writeable}
* VM option that can be set dynamically mainly for troubleshooting
* and diagnosis.
*
* @return a list of <tt>VMOption</tt> objects for all diagnostic options.
*/
public java.util.List<VMOption> getDiagnosticOptions();
/**
* Returns a <tt>VMOption</tt> object for a VM option of the given
* name.
*
* @return a <tt>VMOption</tt> object for a VM option of the given name.
* @throws NullPointerException if name is <tt>null</tt>.
* @throws IllegalArgumentException if a VM option of the given name
* does not exist.
*/
public VMOption getVMOption(String name);
/**
* Sets a VM option of the given name to the specified value.
* The new value will be reflected in a new <tt>VMOption</tt>
* object returned by the {@link #getVMOption} method or
* the {@link #getDiagnosticOptions} method. This method does
* not change the value of this <tt>VMOption</tt> object.
*
* @param name Name of a VM option
* @param value New value of the VM option to be set
*
* @throws IllegalArgumentException if the VM option of the given name
* does not exist.
* @throws IllegalArgumentException if the new value is invalid.
* @throws IllegalArgumentException if the VM option is not writable.
* @throws NullPointerException if name or value is <tt>null</tt>.
*
* @throws java.lang.SecurityException
* if a security manager exists and the caller does not have
* ManagementPermission("control").
*/
public void setVMOption(String name, String value);
}

View File

@@ -0,0 +1,137 @@
/*
* Copyright (c) 2003, 2019, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.management;
/**
* Platform-specific management interface for the operating system
* on which the Java virtual machine is running.
*
* <p>
* This interface provides information about the operating environment
* on which the Java virtual machine is running. That might be a native
* operating system, a virtualized operating system environment, or a
* container-managed environment.
*
* <p>
* The <tt>OperatingSystemMXBean</tt> object returned by
* {@link java.lang.management.ManagementFactory#getOperatingSystemMXBean()}
* is an instance of the implementation class of this interface
* or {@link UnixOperatingSystemMXBean} interface depending on
* its underlying operating system.
*
* @author Mandy Chung
* @since 1.5
*/
@jdk.Exported
public interface OperatingSystemMXBean extends
java.lang.management.OperatingSystemMXBean {
/**
* Returns the amount of virtual memory that is guaranteed to
* be available to the running process in bytes,
* or <tt>-1</tt> if this operation is not supported.
*
* @return the amount of virtual memory that is guaranteed to
* be available to the running process in bytes,
* or <tt>-1</tt> if this operation is not supported.
*/
public long getCommittedVirtualMemorySize();
/**
* Returns the total amount of swap space in bytes.
*
* @return the total amount of swap space in bytes.
*/
public long getTotalSwapSpaceSize();
/**
* Returns the amount of free swap space in bytes.
*
* @return the amount of free swap space in bytes.
*/
public long getFreeSwapSpaceSize();
/**
* Returns the CPU time used by the process on which the Java
* virtual machine is running in nanoseconds. The returned value
* is of nanoseconds precision but not necessarily nanoseconds
* accuracy. This method returns <tt>-1</tt> if the
* the platform does not support this operation.
*
* @return the CPU time used by the process in nanoseconds,
* or <tt>-1</tt> if this operation is not supported.
*/
public long getProcessCpuTime();
/**
* Returns the amount of free physical memory in bytes.
*
* @return the amount of free physical memory in bytes.
*/
public long getFreePhysicalMemorySize();
/**
* Returns the total amount of physical memory in bytes.
*
* @return the total amount of physical memory in bytes.
*/
public long getTotalPhysicalMemorySize();
/**
* Returns the "recent cpu usage" for the whole system. This value is a
* double in the [0.0,1.0] interval. A value of 0.0 means that all CPUs
* were idle during the recent period of time observed, while a value
* of 1.0 means that all CPUs were actively running 100% of the time
* during the recent period being observed. All values betweens 0.0 and
* 1.0 are possible depending of the activities going on in the system.
* If the system recent cpu usage is not available, the method returns a
* negative value.
*
* @return the "recent cpu usage" for the whole system; a negative
* value if not available.
* @since 1.7
*/
public double getSystemCpuLoad();
/**
* Returns the "recent cpu usage" for the Java Virtual Machine process.
* This value is a double in the [0.0,1.0] interval. A value of 0.0 means
* that none of the CPUs were running threads from the JVM process during
* the recent period of time observed, while a value of 1.0 means that all
* CPUs were actively running threads from the JVM 100% of the time
* during the recent period being observed. Threads from the JVM include
* the application threads as well as the JVM internal threads. All values
* betweens 0.0 and 1.0 are possible depending of the activities going on
* in the JVM process and the whole system. If the Java Virtual Machine
* recent CPU usage is not available, the method returns a negative value.
*
* @return the "recent cpu usage" for the Java Virtual Machine process;
* a negative value if not available.
* @since 1.7
*/
public double getProcessCpuLoad();
}

View File

@@ -0,0 +1,437 @@
/*
* Copyright (c) 2011, 2019, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.management;
import java.lang.management.ThreadInfo;
import java.util.Map;
/**
* Platform-specific management interface for the thread system
* of the Java virtual machine.
* <p>
* This platform extension is only available to a thread
* implementation that supports this extension.
*
* @author Paul Hohensee
* @since 6u25
*/
@jdk.Exported
public interface ThreadMXBean extends java.lang.management.ThreadMXBean {
/**
* Returns the total CPU time for each thread whose ID is
* in the input array {@code ids} in nanoseconds.
* The returned values are of nanoseconds precision but
* not necessarily nanoseconds accuracy.
* <p>
* This method is equivalent to calling the
* {@link ThreadMXBean#getThreadCpuTime(long)}
* method for each thread ID in the input array {@code ids} and setting the
* returned value in the corresponding element of the returned array.
*
* @param ids an array of thread IDs.
* @return an array of long values, each of which is the amount of CPU
* time the thread whose ID is in the corresponding element of the input
* array of IDs has used,
* if the thread of a specified ID exists, the thread is alive,
* and CPU time measurement is enabled;
* {@code -1} otherwise.
*
* @throws NullPointerException if {@code ids} is {@code null}
* @throws IllegalArgumentException if any element in the input array
* {@code ids} is {@code <=} {@code 0}.
* @throws UnsupportedOperationException if the Java
* virtual machine implementation does not support CPU time
* measurement.
*
* @see ThreadMXBean#getThreadCpuTime(long)
* @see #getThreadUserTime
* @see ThreadMXBean#isThreadCpuTimeSupported
* @see ThreadMXBean#isThreadCpuTimeEnabled
* @see ThreadMXBean#setThreadCpuTimeEnabled
*/
public long[] getThreadCpuTime(long[] ids);
/**
* Returns the CPU time that each thread whose ID is in the input array
* {@code ids} has executed in user mode in nanoseconds.
* The returned values are of nanoseconds precision but
* not necessarily nanoseconds accuracy.
* <p>
* This method is equivalent to calling the
* {@link ThreadMXBean#getThreadUserTime(long)}
* method for each thread ID in the input array {@code ids} and setting the
* returned value in the corresponding element of the returned array.
*
* @param ids an array of thread IDs.
* @return an array of long values, each of which is the amount of user
* mode CPU time the thread whose ID is in the corresponding element of
* the input array of IDs has used,
* if the thread of a specified ID exists, the thread is alive,
* and CPU time measurement is enabled;
* {@code -1} otherwise.
*
* @throws NullPointerException if {@code ids} is {@code null}
* @throws IllegalArgumentException if any element in the input array
* {@code ids} is {@code <=} {@code 0}.
* @throws UnsupportedOperationException if the Java
* virtual machine implementation does not support CPU time
* measurement.
*
* @see ThreadMXBean#getThreadUserTime(long)
* @see #getThreadCpuTime
* @see ThreadMXBean#isThreadCpuTimeSupported
* @see ThreadMXBean#isThreadCpuTimeEnabled
* @see ThreadMXBean#setThreadCpuTimeEnabled
*/
public long[] getThreadUserTime(long[] ids);
/**
* Returns an approximation of the total amount of memory, in bytes, allocated
* in heap memory by all threads since the Java virtual machine started.
* The returned value is an approximation because some Java virtual machine
* implementations may use object allocation mechanisms that result in a
* delay between the time an object is allocated and the time its size is
* recorded.
*
* @implSpec The default implementation throws {@code UnsupportedOperationException}
* if the Java virtual machine implementation does not support thread
* memory allocation measurement, and otherwise acts as though thread
* memory allocation measurement is disabled.
*
* @return an approximation of the total memory allocated, in bytes, in
* heap memory since the Java virtual machine was started,
* if thread memory allocation measurement is enabled;
* {@code -1} otherwise.
*
* @throws UnsupportedOperationException if the Java virtual
* machine implementation does not support thread memory allocation
* measurement.
*
* @see #isThreadAllocatedMemorySupported
* @see #isThreadAllocatedMemoryEnabled
* @see #setThreadAllocatedMemoryEnabled
*
* @since 8u412
*/
public default long getTotalThreadAllocatedBytes() {
if (!isThreadAllocatedMemorySupported()) {
throw new UnsupportedOperationException(
"Thread allocated memory measurement is not supported.");
}
return -1;
}
/**
* Returns an approximation of the total amount of memory, in bytes,
* allocated in heap memory for the current thread.
* The returned value is an approximation because some Java virtual machine
* implementations may use object allocation mechanisms that result in a
* delay between the time an object is allocated and the time its size is
* recorded.
*
* <p>
* This is a convenience method for local management use and is
* equivalent to calling:
* <blockquote><pre>
* {@link #getThreadAllocatedBytes getThreadAllocatedBytes}(Thread.currentThread().getId());
* </pre></blockquote>
*
* @return an approximation of the total memory allocated, in bytes, in
* heap memory for the current thread
* if thread memory allocation measurement is enabled;
* {@code -1} otherwise.
*
* @throws UnsupportedOperationException if the Java virtual
* machine implementation does not support thread memory allocation
* measurement.
*
* @see #isThreadAllocatedMemorySupported
* @see #isThreadAllocatedMemoryEnabled
* @see #setThreadAllocatedMemoryEnabled
*
* @since 8u282
*/
public default long getCurrentThreadAllocatedBytes() {
return getThreadAllocatedBytes(Thread.currentThread().getId());
}
/**
* Returns an approximation of the total amount of memory, in bytes,
* allocated in heap memory for the thread with the specified ID.
* The returned value is an approximation because some Java virtual machine
* implementations may use object allocation mechanisms that result in a
* delay between the time an object is allocated and the time its size is
* recorded.
* <p>
* If the thread with the specified ID is not alive or does not exist,
* this method returns {@code -1}. If thread memory allocation measurement
* is disabled, this method returns {@code -1}.
* A thread is alive if it has been started and has not yet died.
* <p>
* If thread memory allocation measurement is enabled after the thread has
* started, the Java virtual machine implementation may choose any time up
* to and including the time that the capability is enabled as the point
* where thread memory allocation measurement starts.
*
* @param id the thread ID of a thread
* @return an approximation of the total memory allocated, in bytes, in
* heap memory for the thread with the specified ID
* if the thread with the specified ID exists, the thread is alive,
* and thread memory allocation measurement is enabled;
* {@code -1} otherwise.
*
* @throws IllegalArgumentException if {@code id} {@code <=} {@code 0}.
* @throws UnsupportedOperationException if the Java virtual
* machine implementation does not support thread memory allocation
* measurement.
*
* @see #isThreadAllocatedMemorySupported
* @see #isThreadAllocatedMemoryEnabled
* @see #setThreadAllocatedMemoryEnabled
*/
public long getThreadAllocatedBytes(long id);
/**
* Returns an approximation of the total amount of memory, in bytes,
* allocated in heap memory for each thread whose ID is in the input
* array {@code ids}.
* The returned values are approximations because some Java virtual machine
* implementations may use object allocation mechanisms that result in a
* delay between the time an object is allocated and the time its size is
* recorded.
* <p>
* This method is equivalent to calling the
* {@link #getThreadAllocatedBytes(long)}
* method for each thread ID in the input array {@code ids} and setting the
* returned value in the corresponding element of the returned array.
*
* @param ids an array of thread IDs.
* @return an array of long values, each of which is an approximation of
* the total memory allocated, in bytes, in heap memory for the thread
* whose ID is in the corresponding element of the input array of IDs.
*
* @throws NullPointerException if {@code ids} is {@code null}
* @throws IllegalArgumentException if any element in the input array
* {@code ids} is {@code <=} {@code 0}.
* @throws UnsupportedOperationException if the Java virtual
* machine implementation does not support thread memory allocation
* measurement.
*
* @see #getThreadAllocatedBytes(long)
* @see #isThreadAllocatedMemorySupported
* @see #isThreadAllocatedMemoryEnabled
* @see #setThreadAllocatedMemoryEnabled
*/
public long[] getThreadAllocatedBytes(long[] ids);
/**
* Tests if the Java virtual machine implementation supports thread memory
* allocation measurement.
*
* @return
* {@code true}
* if the Java virtual machine implementation supports thread memory
* allocation measurement;
* {@code false} otherwise.
*/
public boolean isThreadAllocatedMemorySupported();
/**
* Tests if thread memory allocation measurement is enabled.
*
* @return {@code true} if thread memory allocation measurement is enabled;
* {@code false} otherwise.
*
* @throws UnsupportedOperationException if the Java virtual
* machine does not support thread memory allocation measurement.
*
* @see #isThreadAllocatedMemorySupported
*/
public boolean isThreadAllocatedMemoryEnabled();
/**
* Enables or disables thread memory allocation measurement. The default
* is platform dependent.
*
* @param enable {@code true} to enable;
* {@code false} to disable.
*
* @throws UnsupportedOperationException if the Java virtual
* machine does not support thread memory allocation measurement.
*
* @throws SecurityException if a security manager
* exists and the caller does not have
* ManagementPermission("control").
*
* @see #isThreadAllocatedMemorySupported
*/
public void setThreadAllocatedMemoryEnabled(boolean enable);
/**
* Returns the thread info for each thread whose ID
* is in the input array <tt>ids</tt>,
* with stack trace of the specified maximum number of elements
* and synchronization information.
* If <tt>maxDepth == 0</tt>, no stack trace of the thread
* will be dumped.
*
* <p>
* This method obtains a snapshot of the thread information
* for each thread including:
* <ul>
* <li>stack trace of the specified maximum number of elements,</li>
* <li>the object monitors currently locked by the thread
* if <tt>lockedMonitors</tt> is <tt>true</tt>, and</li>
* <li>the <a href="{@docRoot}/../api/java/lang/management/LockInfo.html#OwnableSynchronizer">
* ownable synchronizers</a> currently locked by the thread
* if <tt>lockedSynchronizers</tt> is <tt>true</tt>.</li>
* </ul>
* <p>
* This method returns an array of the <tt>ThreadInfo</tt> objects,
* each is the thread information about the thread with the same index
* as in the <tt>ids</tt> array.
* If a thread of the given ID is not alive or does not exist,
* <tt>null</tt> will be set in the corresponding element
* in the returned array. A thread is alive if
* it has been started and has not yet died.
* <p>
* If a thread does not lock any object monitor or <tt>lockedMonitors</tt>
* is <tt>false</tt>, the returned <tt>ThreadInfo</tt> object will have an
* empty <tt>MonitorInfo</tt> array. Similarly, if a thread does not
* lock any synchronizer or <tt>lockedSynchronizers</tt> is <tt>false</tt>,
* the returned <tt>ThreadInfo</tt> object
* will have an empty <tt>LockInfo</tt> array.
*
* <p>
* When both <tt>lockedMonitors</tt> and <tt>lockedSynchronizers</tt>
* parameters are <tt>false</tt>, it is equivalent to calling:
* <blockquote><pre>
* {@link #getThreadInfo(long[], int) getThreadInfo(ids, maxDepth)}
* </pre></blockquote>
*
* <p>
* This method is designed for troubleshooting use, but not for
* synchronization control. It might be an expensive operation.
*
* <p>
* <b>MBeanServer access</b>:<br>
* The mapped type of <tt>ThreadInfo</tt> is
* <tt>CompositeData</tt> with attributes as specified in the
* {@link ThreadInfo#from ThreadInfo.from} method.
*
* @implSpec The default implementation throws
* <tt>UnsupportedOperationException</tt>.
*
* @param ids an array of thread IDs.
* @param lockedMonitors if <tt>true</tt>, retrieves all locked monitors.
* @param lockedSynchronizers if <tt>true</tt>, retrieves all locked
* ownable synchronizers.
* @param maxDepth indicates the maximum number of
* {@link StackTraceElement} to be retrieved from the stack trace.
*
* @return an array of the {@link ThreadInfo} objects, each containing
* information about a thread whose ID is in the corresponding
* element of the input array of IDs.
*
* @throws IllegalArgumentException if <tt>maxDepth</tt> is negative.
* @throws java.lang.SecurityException if a security manager
* exists and the caller does not have
* ManagementPermission("monitor").
* @throws java.lang.UnsupportedOperationException
* <ul>
* <li>if <tt>lockedMonitors</tt> is <tt>true</tt> but
* the Java virtual machine does not support monitoring
* of {@linkplain #isObjectMonitorUsageSupported
* object monitor usage}; or</li>
* <li>if <tt>lockedSynchronizers</tt> is <tt>true</tt> but
* the Java virtual machine does not support monitoring
* of {@linkplain #isSynchronizerUsageSupported
* ownable synchronizer usage}.</li>
* </ul>
*
* @see #isObjectMonitorUsageSupported
* @see #isSynchronizerUsageSupported
*
* @since 8u282
*/
public default ThreadInfo[] getThreadInfo(long[] ids, boolean lockedMonitors,
boolean lockedSynchronizers, int maxDepth) {
throw new UnsupportedOperationException();
}
/**
* Returns the thread info for all live threads
* with stack trace of the specified maximum number of elements
* and synchronization information.
* if <tt>maxDepth == 0</tt>, no stack trace of the thread
* will be dumped.
* Some threads included in the returned array
* may have been terminated when this method returns.
*
* <p>
* This method returns an array of {@link ThreadInfo} objects
* as specified in the {@link #getThreadInfo(long[], boolean, boolean, int)}
* method.
*
* @implSpec The default implementation throws
* <tt>UnsupportedOperationException</tt>.
*
* @param lockedMonitors if <tt>true</tt>, dump all locked monitors.
* @param lockedSynchronizers if <tt>true</tt>, dump all locked
* ownable synchronizers.
* @param maxDepth indicates the maximum number of
* {@link StackTraceElement} to be retrieved from the stack trace.
*
* @return an array of {@link ThreadInfo} for all live threads.
*
* @throws IllegalArgumentException if <tt>maxDepth</tt> is negative.
* @throws java.lang.SecurityException if a security manager
* exists and the caller does not have
* ManagementPermission("monitor").
* @throws java.lang.UnsupportedOperationException
* <ul>
* <li>if <tt>lockedMonitors</tt> is <tt>true</tt> but
* the Java virtual machine does not support monitoring
* of {@linkplain #isObjectMonitorUsageSupported
* object monitor usage}; or</li>
* <li>if <tt>lockedSynchronizers</tt> is <tt>true</tt> but
* the Java virtual machine does not support monitoring
* of {@linkplain #isSynchronizerUsageSupported
* ownable synchronizer usage}.</li>
* </ul>
*
* @see #isObjectMonitorUsageSupported
* @see #isSynchronizerUsageSupported
*
* @since 8u282
*/
public default ThreadInfo[] dumpAllThreads(boolean lockedMonitors,
boolean lockedSynchronizers, int maxDepth) {
throw new UnsupportedOperationException();
}
}

View File

@@ -0,0 +1,52 @@
/*
* Copyright (c) 2003, 2013, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.management;
/**
* Platform-specific management interface for the Unix
* operating system on which the Java virtual machine is running.
*
* @author Mandy Chung
* @since 1.5
*/
@jdk.Exported
public interface UnixOperatingSystemMXBean extends
com.sun.management.OperatingSystemMXBean {
/**
* Returns the number of open file descriptors.
*
* @return the number of open file descriptors.
*/
public long getOpenFileDescriptorCount();
/**
* Returns the maximum number of file descriptors.
*
* @return the maximum number of file descriptors.
*/
public long getMaxFileDescriptorCount();
}

View File

@@ -0,0 +1,240 @@
/*
* Copyright (c) 2005, 2013, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.management;
import sun.management.VMOptionCompositeData;
import javax.management.openmbean.CompositeData;
/**
* Information about a VM option including its value and
* where the value came from which is referred as its
* {@link VMOption.Origin <i>origin</i>}.
* <p>
* Each VM option has a default value. A VM option can
* be set at VM creation time typically as a command line
* argument to the launcher or an argument passed to the
* VM created using the JNI invocation interface.
* In addition, a VM option may be set via an environment
* variable or a configuration file. A VM option can also
* be set dynamically via a management interface after
* the VM was started.
*
* A <tt>VMOption</tt> contains the value of a VM option
* and the origin of that value at the time this <tt>VMOption</tt>
* object was constructed. The value of the VM option
* may be changed after the <tt>VMOption</tt> object was constructed,
*
* @see <a href="{@docRoot}/../../../../technotes/guides/vm/index.html">
* Java Virtual Machine</a>
* @author Mandy Chung
* @since 1.6
*/
@jdk.Exported
public class VMOption {
private String name;
private String value;
private boolean writeable;
private Origin origin;
/**
* Origin of the value of a VM option. It tells where the
* value of a VM option came from.
*
* @since 1.6
*/
@jdk.Exported
public enum Origin {
/**
* The VM option has not been set and its value
* is the default value.
*/
DEFAULT,
/**
* The VM option was set at VM creation time typically
* as a command line argument to the launcher or
* an argument passed to the VM created using the
* JNI invocation interface.
*/
VM_CREATION,
/**
* The VM option was set via an environment variable.
*/
ENVIRON_VAR,
/**
* The VM option was set via a configuration file.
*/
CONFIG_FILE,
/**
* The VM option was set via the management interface after the VM
* was started.
*/
MANAGEMENT,
/**
* The VM option was set via the VM ergonomic support.
*/
ERGONOMIC,
/**
* The VM option was set via some other mechanism.
*/
OTHER
}
/**
* Constructs a <tt>VMOption</tt>.
*
* @param name Name of a VM option.
* @param value Value of a VM option.
* @param writeable <tt>true</tt> if a VM option can be set dynamically,
* or <tt>false</tt> otherwise.
* @param origin where the value of a VM option came from.
*
* @throws NullPointerException if the name or value is <tt>null</tt>
*/
public VMOption(String name, String value, boolean writeable, Origin origin) {
this.name = name;
this.value = value;
this.writeable = writeable;
this.origin = origin;
}
/**
* Constructs a <tt>VMOption</tt> object from a
* {@link CompositeData CompositeData}.
*/
private VMOption(CompositeData cd) {
// validate the input composite data
VMOptionCompositeData.validateCompositeData(cd);
this.name = VMOptionCompositeData.getName(cd);
this.value = VMOptionCompositeData.getValue(cd);
this.writeable = VMOptionCompositeData.isWriteable(cd);
this.origin = VMOptionCompositeData.getOrigin(cd);
}
/**
* Returns the name of this VM option.
*
* @return the name of this VM option.
*/
public String getName() {
return name;
}
/**
* Returns the value of this VM option at the time when
* this <tt>VMOption</tt> was created. The value could have been changed.
*
* @return the value of the VM option at the time when
* this <tt>VMOption</tt> was created.
*/
public String getValue() {
return value;
}
/**
* Returns the origin of the value of this VM option. That is,
* where the value of this VM option came from.
*
* @return where the value of this VM option came from.
*/
public Origin getOrigin() {
return origin;
}
/**
* Tests if this VM option is writeable. If this VM option is writeable,
* it can be set by the {@link HotSpotDiagnosticMXBean#setVMOption
* HotSpotDiagnosticMXBean.setVMOption} method.
*
* @return <tt>true</tt> if this VM option is writeable; <tt>false</tt>
* otherwise.
*/
public boolean isWriteable() {
return writeable;
}
public String toString() {
return "VM option: " + getName() +
" value: " + value + " " +
" origin: " + origin + " " +
(writeable ? "(read-write)" : "(read-only)");
}
/**
* Returns a <tt>VMOption</tt> object represented by the
* given <tt>CompositeData</tt>. The given <tt>CompositeData</tt>
* must contain the following attributes:
* <p>
* <blockquote>
* <table border>
* <tr>
* <th align=left>Attribute Name</th>
* <th align=left>Type</th>
* </tr>
* <tr>
* <td>name</td>
* <td><tt>java.lang.String</tt></td>
* </tr>
* <tr>
* <td>value</td>
* <td><tt>java.lang.String</tt></td>
* </tr>
* <tr>
* <td>origin</td>
* <td><tt>java.lang.String</tt></td>
* </tr>
* <tr>
* <td>writeable</td>
* <td><tt>java.lang.Boolean</tt></td>
* </tr>
* </table>
* </blockquote>
*
* @param cd <tt>CompositeData</tt> representing a <tt>VMOption</tt>
*
* @throws IllegalArgumentException if <tt>cd</tt> does not
* represent a <tt>VMOption</tt> with the attributes described
* above.
*
* @return a <tt>VMOption</tt> object represented by <tt>cd</tt>
* if <tt>cd</tt> is not <tt>null</tt>;
* <tt>null</tt> otherwise.
*/
public static VMOption from(CompositeData cd) {
if (cd == null) {
return null;
}
if (cd instanceof VMOptionCompositeData) {
return ((VMOptionCompositeData) cd).getVMOption();
} else {
return new VMOption(cd);
}
}
}

View File

@@ -0,0 +1,44 @@
/*
* Copyright (c) 2004, 2013, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* This package contains Oracle Corporation's platform extension to
* the implementation of the
* <a href="{@docRoot}/../../../../api/java/lang/management/package-summary.html">
* java.lang.management</a> API and also defines the management
* interface for some other components for the platform.
*
* <p>
* All platform MBeans are registered in the <em>platform MBeanServer</em>
* which can be obtained via the
* <a href="{@docRoot}/../../../../api/java/lang/management/ManagementFactory.html#getPlatformMBeanServer()">
* java.lang.management.ManagementFactory.getPlatformMBeanServer</a>
*
* @author Mandy Chung
* @since 1.5
*/
@jdk.Exported
package com.sun.management;