# HG changeset patch
# User sjiang
# Date 1429256402 -7200
# Node ID e37c7eba132fb18518fd779d6b09c30c7c9205a2
# Parent ca83b4cae3636571af16833cf0d16f1bd08f33cf
8042901: Allow com.sun.management to be in a different module to java.lang.management
Reviewed-by: mchung, dfuchs, erikj, jbachorik
diff -r ca83b4cae363 -r e37c7eba132f jdk/make/lib/Lib-java.management.gmk
--- a/jdk/make/lib/Lib-java.management.gmk Wed Apr 15 13:27:39 2015 +0200
+++ b/jdk/make/lib/Lib-java.management.gmk Fri Apr 17 09:40:02 2015 +0200
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2011, 2015, 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
@@ -30,28 +30,14 @@
################################################################################
-BUILD_LIBMANAGEMENT_SRC += $(JDK_TOPDIR)/src/java.management/share/native/libmanagement \
+LIBMANAGEMENT_SRC += $(JDK_TOPDIR)/src/java.management/share/native/libmanagement \
$(JDK_TOPDIR)/src/java.management/$(OPENJDK_TARGET_OS_TYPE)/native/libmanagement
-BUILD_LIBMANAGEMENT_CFLAGS := -I$(JDK_TOPDIR)/src/java.management/share/native/include \
- $(addprefix -I,$(BUILD_LIBMANAGEMENT_SRC)) \
+LIBMANAGEMENT_CFLAGS := -I$(JDK_TOPDIR)/src/java.management/share/native/include \
+ $(addprefix -I,$(LIBMANAGEMENT_SRC)) \
-I$(SUPPORT_OUTPUTDIR)/headers/java.management \
$(LIBJAVA_HEADER_FLAGS) \
#
-BUILD_LIBMANAGEMENT_EXCLUDES :=
-
-ifneq ($(OPENJDK_TARGET_OS), solaris)
- BUILD_LIBMANAGEMENT_EXCLUDES += SolarisOperatingSystem.c
-endif
-
-ifneq ($(OPENJDK_TARGET_OS), linux)
- BUILD_LIBMANAGEMENT_EXCLUDES += LinuxOperatingSystem.c
-endif
-
-ifneq ($(OPENJDK_TARGET_OS), macosx)
- BUILD_LIBMANAGEMENT_EXCLUDES += MacosxOperatingSystem.c
-endif
-
LIBMANAGEMENT_OPTIMIZATION := HIGH
ifneq ($(findstring $(OPENJDK_TARGET_OS), solaris linux), )
ifeq ($(ENABLE_DEBUG_SYMBOLS), true)
@@ -59,18 +45,14 @@
endif
endif
-# Make it possible to override this variable
-LIBMANAGEMENT_MAPFILE ?= $(JDK_TOPDIR)/make/mapfiles/libmanagement/mapfile-vers
-
$(eval $(call SetupNativeCompilation,BUILD_LIBMANAGEMENT, \
LIBRARY := management, \
OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
- SRC := $(BUILD_LIBMANAGEMENT_SRC), \
- EXCLUDE_FILES := $(BUILD_LIBMANAGEMENT_EXCLUDES), \
+ SRC := $(LIBMANAGEMENT_SRC), \
LANG := C, \
OPTIMIZATION := $(LIBMANAGEMENT_OPTIMIZATION), \
- CFLAGS := $(CFLAGS_JDKLIB) $(CFLAGS_WARNINGS_ARE_ERRORS) $(BUILD_LIBMANAGEMENT_CFLAGS), \
- MAPFILE := $(LIBMANAGEMENT_MAPFILE), \
+ CFLAGS := $(CFLAGS_JDKLIB) $(CFLAGS_WARNINGS_ARE_ERRORS) $(LIBMANAGEMENT_CFLAGS), \
+ MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libmanagement/mapfile-vers, \
LDFLAGS := $(LDFLAGS_JDKLIB) \
$(call SET_SHARED_LIBRARY_ORIGIN), \
LDFLAGS_solaris := -lkstat, \
diff -r ca83b4cae363 -r e37c7eba132f jdk/make/lib/Lib-jdk.management.gmk
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/make/lib/Lib-jdk.management.gmk Fri Apr 17 09:40:02 2015 +0200
@@ -0,0 +1,75 @@
+#
+# Copyright (c) 2015, 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.
+#
+
+include LibCommon.gmk
+
+# Hook to include the corresponding custom file, if present.
+$(eval $(call IncludeCustomExtension, jdk, lib/Lib-jdk.management.gmk))
+
+################################################################################
+
+LIBMANAGEMENT_EXT_SRC += $(JDK_TOPDIR)/src/jdk.management/share/native/libmanagement_ext \
+ $(JDK_TOPDIR)/src/jdk.management/$(OPENJDK_TARGET_OS_TYPE)/native/libmanagement_ext \
+ $(JDK_TOPDIR)/src/jdk.management/$(OPENJDK_TARGET_OS)/native/libmanagement_ext
+LIBMANAGEMENT_EXT_CFLAGS := -I$(JDK_TOPDIR)/src/java.management/share/native/include \
+ $(addprefix -I,$(LIBMANAGEMENT_EXT_SRC)) \
+ -I$(SUPPORT_OUTPUTDIR)/headers/jdk.management \
+ $(LIBJAVA_HEADER_FLAGS) \
+ #
+
+LIBMANAGEMENT_EXT_OPTIMIZATION := HIGH
+ifneq ($(findstring $(OPENJDK_TARGET_OS), solaris linux), )
+ ifeq ($(ENABLE_DEBUG_SYMBOLS), true)
+ LIBMANAGEMENT_EXT_OPTIMIZATION := LOW
+ endif
+endif
+
+$(eval $(call SetupNativeCompilation,BUILD_LIBMANAGEMENT_EXT, \
+ LIBRARY := management_ext, \
+ OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
+ SRC := $(LIBMANAGEMENT_EXT_SRC), \
+ LANG := C, \
+ OPTIMIZATION := $(LIBMANAGEMENT_EXT_OPTIMIZATION), \
+ CFLAGS := $(CFLAGS_JDKLIB) $(CFLAGS_WARNINGS_ARE_ERRORS) $(LIBMANAGEMENT_EXT_CFLAGS), \
+ MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libmanagement_ext/mapfile-vers, \
+ LDFLAGS := $(LDFLAGS_JDKLIB) \
+ $(call SET_SHARED_LIBRARY_ORIGIN), \
+ LDFLAGS_solaris := -lkstat, \
+ LDFLAGS_SUFFIX := $(LDFLAGS_JDKLIB_SUFFIX), \
+ LDFLAGS_SUFFIX_windows := jvm.lib psapi.lib $(WIN_JAVA_LIB) advapi32.lib, \
+ LDFLAGS_SUFFIX_aix := -lperfstat,\
+ VERSIONINFO_RESOURCE := $(GLOBAL_VERSION_INFO_RESOURCE), \
+ RC_FLAGS := $(RC_FLAGS) \
+ -D "JDK_FNAME=management_ext.dll" \
+ -D "JDK_INTERNAL_NAME=management_ext" \
+ -D "JDK_FTYPE=0x2L", \
+ OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libmanagement_ext, \
+ DEBUG_SYMBOLS := true))
+
+$(BUILD_LIBMANAGEMENT_EXT): $(call FindLib, java.base, java)
+
+TARGETS += $(BUILD_LIBMANAGEMENT_EXT)
+
+################################################################################
diff -r ca83b4cae363 -r e37c7eba132f jdk/make/mapfiles/libmanagement/mapfile-vers
--- a/jdk/make/mapfiles/libmanagement/mapfile-vers Wed Apr 15 13:27:39 2015 +0200
+++ b/jdk/make/mapfiles/libmanagement/mapfile-vers Fri Apr 17 09:40:02 2015 +0200
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2005, 2015, 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
@@ -27,37 +27,10 @@
SUNWprivate_1.1 {
global:
- Java_sun_management_OperatingSystemImpl_getCommittedVirtualMemorySize0;
- Java_sun_management_OperatingSystemImpl_getFreePhysicalMemorySize0;
- Java_sun_management_OperatingSystemImpl_getFreeSwapSpaceSize0;
- Java_sun_management_OperatingSystemImpl_getMaxFileDescriptorCount0;
- Java_sun_management_OperatingSystemImpl_getOpenFileDescriptorCount0;
- Java_sun_management_OperatingSystemImpl_getProcessCpuLoad0;
- Java_sun_management_OperatingSystemImpl_getProcessCpuTime0;
- Java_sun_management_OperatingSystemImpl_getSystemCpuLoad0;
- Java_sun_management_OperatingSystemImpl_getTotalPhysicalMemorySize0;
- Java_sun_management_OperatingSystemImpl_getTotalSwapSpaceSize0;
- Java_sun_management_OperatingSystemImpl_initialize0;
Java_sun_management_ClassLoadingImpl_setVerboseClass;
- Java_sun_management_DiagnosticCommandImpl_executeDiagnosticCommand;
- Java_sun_management_DiagnosticCommandImpl_getDiagnosticCommands;
- Java_sun_management_DiagnosticCommandImpl_getDiagnosticCommandInfo;
- Java_sun_management_DiagnosticCommandImpl_setNotificationEnabled;
- Java_sun_management_FileSystemImpl_isAccessUserOnly0;
- Java_sun_management_Flag_getAllFlagNames;
- Java_sun_management_Flag_getFlags;
- Java_sun_management_Flag_getInternalFlagCount;
- Java_sun_management_Flag_initialize;
- Java_sun_management_Flag_setLongValue;
- Java_sun_management_Flag_setBooleanValue;
- Java_sun_management_Flag_setStringValue;
- Java_sun_management_GarbageCollectorImpl_getCollectionCount;
+ Java_sun_management_FileSystemImpl_isAccessUserOnly0;
+ Java_sun_management_GarbageCollectorImpl_getCollectionCount;
Java_sun_management_GarbageCollectorImpl_getCollectionTime;
- Java_sun_management_GarbageCollectorImpl_setNotificationEnabled;
- Java_sun_management_GcInfoBuilder_fillGcAttributeInfo;
- Java_sun_management_GcInfoBuilder_getLastGcInfo0;
- Java_sun_management_GcInfoBuilder_getNumGcExtAttributes;
- Java_sun_management_HotSpotDiagnostic_dumpHeap0;
Java_sun_management_HotspotThread_getInternalThreadCount;
Java_sun_management_HotspotThread_getInternalThreadTimes0;
Java_sun_management_MemoryImpl_getMemoryManagers0;
diff -r ca83b4cae363 -r e37c7eba132f jdk/make/mapfiles/libmanagement_ext/mapfile-vers
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/make/mapfiles/libmanagement_ext/mapfile-vers Fri Apr 17 09:40:02 2015 +0200
@@ -0,0 +1,60 @@
+#
+# Copyright (c) 2015, 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.
+#
+
+# Define library interface.
+
+SUNWprivate_1.1 {
+ global:
+ Java_com_sun_management_internal_OperatingSystemImpl_getCommittedVirtualMemorySize0;
+ Java_com_sun_management_internal_OperatingSystemImpl_getFreePhysicalMemorySize0;
+ Java_com_sun_management_internal_OperatingSystemImpl_getFreeSwapSpaceSize0;
+ Java_com_sun_management_internal_OperatingSystemImpl_getMaxFileDescriptorCount0;
+ Java_com_sun_management_internal_OperatingSystemImpl_getOpenFileDescriptorCount0;
+ Java_com_sun_management_internal_OperatingSystemImpl_getProcessCpuLoad0;
+ Java_com_sun_management_internal_OperatingSystemImpl_getProcessCpuTime0;
+ Java_com_sun_management_internal_OperatingSystemImpl_getSystemCpuLoad0;
+ Java_com_sun_management_internal_OperatingSystemImpl_getTotalPhysicalMemorySize0;
+ Java_com_sun_management_internal_OperatingSystemImpl_getTotalSwapSpaceSize0;
+ Java_com_sun_management_internal_OperatingSystemImpl_initialize0;
+ Java_com_sun_management_internal_DiagnosticCommandImpl_executeDiagnosticCommand;
+ Java_com_sun_management_internal_DiagnosticCommandImpl_getDiagnosticCommands;
+ Java_com_sun_management_internal_DiagnosticCommandImpl_getDiagnosticCommandInfo;
+ Java_com_sun_management_internal_DiagnosticCommandImpl_setNotificationEnabled;
+ Java_com_sun_management_internal_Flag_getAllFlagNames;
+ Java_com_sun_management_internal_Flag_getFlags;
+ Java_com_sun_management_internal_Flag_getInternalFlagCount;
+ Java_com_sun_management_internal_Flag_initialize;
+ Java_com_sun_management_internal_Flag_setLongValue;
+ Java_com_sun_management_internal_Flag_setBooleanValue;
+ Java_com_sun_management_internal_Flag_setStringValue;
+ Java_com_sun_management_internal_GarbageCollectorExtImpl_setNotificationEnabled;
+ Java_com_sun_management_internal_GcInfoBuilder_fillGcAttributeInfo;
+ Java_com_sun_management_internal_GcInfoBuilder_getLastGcInfo0;
+ Java_com_sun_management_internal_GcInfoBuilder_getNumGcExtAttributes;
+ Java_com_sun_management_internal_HotSpotDiagnostic_dumpHeap0;
+ JNI_OnLoad;
+ local:
+ *;
+};
diff -r ca83b4cae363 -r e37c7eba132f jdk/make/src/classes/build/tools/module/boot.modules
--- a/jdk/make/src/classes/build/tools/module/boot.modules Wed Apr 15 13:27:39 2015 +0200
+++ b/jdk/make/src/classes/build/tools/module/boot.modules Fri Apr 17 09:40:02 2015 +0200
@@ -22,6 +22,7 @@
jdk.hprof.agent
jdk.httpserver
jdk.jfr
+jdk.management
jdk.management.cmm
jdk.naming.rmi
jdk.sctp
diff -r ca83b4cae363 -r e37c7eba132f jdk/src/java.management/share/classes/META-INF/services/sun.management.spi.PlatformMBeanProvider
--- a/jdk/src/java.management/share/classes/META-INF/services/sun.management.spi.PlatformMBeanProvider Wed Apr 15 13:27:39 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,25 +0,0 @@
-#
-# Copyright (c) 2015, 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.
-#
-com.sun.management.internal.PlatformMBeanProviderImpl
diff -r ca83b4cae363 -r e37c7eba132f jdk/src/java.management/share/classes/com/sun/management/DiagnosticCommandMBean.java
--- a/jdk/src/java.management/share/classes/com/sun/management/DiagnosticCommandMBean.java Wed Apr 15 13:27:39 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,220 +0,0 @@
-/*
- * 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.
- *
- *
The {@code DiagnosticCommandMBean} is registered to the
- * {@linkplain java.lang.management.ManagementFactory#getPlatformMBeanServer
- * platform MBeanServer} as are other platform MBeans.
- *
- *
The {@link javax.management.ObjectName ObjectName} for uniquely identifying
- * the diagnostic MBean within an MBeanServer is:
- *
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 diagnostic command is represented as an operation of
- * the {@code DiagnosticCommandMBean} interface. Each diagnostic command has:
- *
- *
the diagnostic command name which is the name being referenced in
- * the HotSpot Virtual Machine
- *
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
- *
- *
- * The recommended way to transform a diagnostic command name into a MBean
- * operation name is as follows:
- *
- *
All characters from the first one to the first dot are set to be
- * lower-case characters
- *
Every dot or underline character is removed and the following
- * character is set to be an upper-case character
- *
All other characters are copied without modification
- *
- *
- *
The diagnostic command name is always provided with the meta-data on the
- * operation in a field named {@code dcmd.name} (see below).
- *
- *
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.
- *
- *
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.
- *
- *
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:
- *
- *
{@link javax.management.MBeanOperationInfo#getName() getName()}
- * returns the operation name generated from the diagnostic command name
- *
{@link javax.management.MBeanOperationInfo#getDescription() getDescription()}
- * returns the diagnostic command description
- * (the same as the one return in the 'help' command)
{@link javax.management.MBeanOperationInfo#getDescriptor() getDescriptor()}
- * returns a Descriptor instance (see below)
- *
- *
- *
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:
- *
- *
- *
- *
- *
Name
Type
Description
- *
- *
- *
dcmd.name
String
- *
The original diagnostic command name (not the operation name)
- *
- *
- *
dcmd.description
String
- *
The diagnostic command description
- *
- *
- *
dcmd.help
String
- *
The full help message for this diagnostic command (same output as
- * the one produced by the 'help' command)
- *
- *
- *
dcmd.vmImpact
String
- *
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
- *
- *
- *
dcmd.enabled
boolean
- *
True if the diagnostic command is enabled, false otherwise
- *
- *
- *
dcmd.permissionClass
String
- *
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
- *
- *
- *
- *
dcmd.permissionName
String
- *
The fist argument of the permission required to execute this
- * diagnostic command or null if no permission is required
- *
- *
- *
dcmd.permissionAction
String
- *
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
- *
- *
- *
dcmd.arguments
Descriptor
- *
A Descriptor instance containing the descriptions of options and
- * arguments supported by the diagnostic command (see below)
- *
- *
- *
- *
- *
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:
- *
- *
- *
- *
Name
Type
Description
- *
- *
- *
dcmd.arg.name
String
- *
The name of the parameter
- *
- *
- *
dcmd.arg.type
String
- *
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.
- *
- *
- *
- *
dcmd.arg.description
String
- *
The parameter description
- *
- *
- *
dcmd.arg.isMandatory
boolean
- *
True if the parameter is mandatory, false otherwise
- *
- *
- *
dcmd.arg.isOption
boolean
- *
True if the parameter is an option, false if it is an argument
- *
- *
- *
dcmd.arg.isMultiple
boolean
- *
True if the parameter can be specified several times, false
- * otherwise
- *
- *
- *
- *
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
- *
- * {@code "jmx.mbean.info.changed"} and a
- * {@linkplain javax.management.Notification#getUserData() userData} that
- * is the new {@code MBeanInfo}.
- *
- * @since 1.8
- */
-public interface DiagnosticCommandMBean extends DynamicMBean
-{
-
-}
diff -r ca83b4cae363 -r e37c7eba132f jdk/src/java.management/share/classes/com/sun/management/GarbageCollectionNotificationInfo.java
--- a/jdk/src/java.management/share/classes/com/sun/management/GarbageCollectionNotificationInfo.java Wed Apr 15 13:27:39 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,238 +0,0 @@
-/*
- * 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
- *
- *
- * 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:
- *
- *
The name of the garbage collector used to perform the collection.
- *
The action performed by the garbage collector.
- *
The cause of the garbage collection action.
- *
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.
- *
- *
- *
- * 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:
- *
- *
- * 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);
- * ....
- * }
- *
- *
- *
- * The type of the notification emitted by a {@code GarbageCollectorMXBean} is:
- *
- *
A {@linkplain #GARBAGE_COLLECTION_NOTIFICATION garbage collection notification}.
- * Used by every notification emitted by the garbage collector, the details about
- * the notification are provided in the {@linkplain #getGcAction action} String
- *
- *
- **/
-
-@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 of 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 performed by the garbage collector
- *
- * @return the action performed by the garbage collector
- */
- public String getGcAction() {
- return gcAction;
- }
-
- /**
- * Returns the cause of the garbage collection
- *
- * @return the cause of 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:
- *
- *
- *
- *
Attribute Name
- *
Type
- *
- *
- *
gcName
- *
{@code java.lang.String}
- *
- *
- *
gcAction
- *
{@code java.lang.String}
- *
- *
- *
gcCause
- *
{@code java.lang.String}
- *
- *
- *
gcInfo
- *
{@code javax.management.openmbean.CompositeData}
- *
- *
- *
- *
- * @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;
- }
-
-}
diff -r ca83b4cae363 -r e37c7eba132f jdk/src/java.management/share/classes/com/sun/management/GarbageCollectorMXBean.java
--- a/jdk/src/java.management/share/classes/com/sun/management/GarbageCollectorMXBean.java Wed Apr 15 13:27:39 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,60 +0,0 @@
-/*
- * 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.
- *
- *
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, null is returned.
- * The collector-specific attributes, if any, can be obtained
- * via the {@link CompositeData CompositeData} interface.
- *
- * MBeanServer access:
- * The mapped type of GcInfo is CompositeData
- * with attributes specified in {@link GcInfo#from GcInfo}.
- *
- * @return a GcInfo object representing
- * the most GC information; or null if no GC
- * information available.
- */
- public GcInfo getLastGcInfo();
-}
diff -r ca83b4cae363 -r e37c7eba132f jdk/src/java.management/share/classes/com/sun/management/GcInfo.java
--- a/jdk/src/java.management/share/classes/com/sun/management/GcInfo.java Wed Apr 15 13:27:39 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,289 +0,0 @@
-/*
- * Copyright (c) 2003, 2014, 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:
- *
- *
- *
Start time
- *
End time
- *
Duration
- *
Memory usage before the collection starts
- *
Memory usage after the collection ends
- *
- *
- *
- *
- * GcInfo 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.
- *
- *
MXBean Mapping
- * GcInfo 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 usageBeforeGc;
- private final Map 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(poolNames.length);
- this.usageAfterGc = new HashMap(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 Map of the name of a memory pool
- * to the memory usage of the corresponding
- * memory pool before GC starts.
- *
- * @return a Map of memory pool names to the memory
- * usage of a memory pool before GC starts.
- */
- public Map getMemoryUsageBeforeGc() {
- return Collections.unmodifiableMap(usageBeforeGc);
- }
-
- /**
- * Returns the memory usage of all memory pools
- * at the end of this GC.
- * This method returns
- * a Map of the name of a memory pool
- * to the memory usage of the corresponding
- * memory pool when GC finishes.
- *
- * @return a Map of memory pool names to the memory
- * usage of a memory pool when GC finishes.
- */
- public Map getMemoryUsageAfterGc() {
- return Collections.unmodifiableMap(usageAfterGc);
- }
-
- /**
- * Returns a GcInfo object represented by the
- * given CompositeData. The given
- * CompositeData must contain
- * all the following attributes:
- *
- *
- *
- *
- *
- *
Attribute Name
- *
Type
- *
- *
- *
index
- *
java.lang.Long
- *
- *
- *
startTime
- *
java.lang.Long
- *
- *
- *
endTime
- *
java.lang.Long
- *
- *
- *
memoryUsageBeforeGc
- *
javax.management.openmbean.TabularData
- *
- *
- *
memoryUsageAfterGc
- *
javax.management.openmbean.TabularData
- *
- *
- *
- *
- * @throws IllegalArgumentException if cd does not
- * represent a GcInfo object with the attributes
- * described above.
- *
- * @return a GcInfo object represented by cd
- * if cd is not null; null 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();
- }
-
- /**
- *
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;
- }
-}
diff -r ca83b4cae363 -r e37c7eba132f jdk/src/java.management/share/classes/com/sun/management/HotSpotDiagnosticMXBean.java
--- a/jdk/src/java.management/share/classes/com/sun/management/HotSpotDiagnosticMXBean.java Wed Apr 15 13:27:39 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,119 +0,0 @@
-/*
- * Copyright (c) 2005, 2014, 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.
- *
- *
The diagnostic MBean is registered to the platform MBeanServer
- * as are other platform MBeans.
- *
- *
The ObjectName for uniquely identifying the diagnostic
- * MXBean within an MBeanServer is:
- *
- * com.sun.management:type=HotSpotDiagnostic
- *
-.*
- * 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 java.lang.management.ManagementFactory#getPlatformMXBeans(Class)
- */
-@jdk.Exported
-public interface HotSpotDiagnosticMXBean extends PlatformManagedObject {
- /**
- * Dumps the heap to the outputFile file in the same
- * format as the hprof heap dump.
- *
- * If this method is called remotely from another process,
- * the heap dump output is written to a file named outputFile
- * 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 true dump only live objects
- * i.e. objects that are reachable from others
- * @throws IOException if the outputFile
- * cannot be created, opened, or written to.
- * @throws UnsupportedOperationException if this operation is not supported.
- * @throws NullPointerException if outputFile is null.
- * @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 VMOption 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 VMOption objects for all diagnostic options.
- */
- public java.util.List getDiagnosticOptions();
-
- /**
- * Returns a VMOption object for a VM option of the given
- * name.
- *
- * @return a VMOption object for a VM option of the given name.
- * @throws NullPointerException if name is null.
- * @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 VMOption
- * object returned by the {@link #getVMOption} method or
- * the {@link #getDiagnosticOptions} method. This method does
- * not change the value of this VMOption 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 null.
- *
- * @throws java.lang.SecurityException
- * if a security manager exists and the caller does not have
- * ManagementPermission("control").
- */
- public void setVMOption(String name, String value);
-}
diff -r ca83b4cae363 -r e37c7eba132f jdk/src/java.management/share/classes/com/sun/management/OperatingSystemMXBean.java
--- a/jdk/src/java.management/share/classes/com/sun/management/OperatingSystemMXBean.java Wed Apr 15 13:27:39 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,131 +0,0 @@
-/*
- * 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 operating system
- * on which the Java virtual machine is running.
- *
- *
- * The OperatingSystemMXBean 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 -1 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 -1 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 -1 if the
- * the platform does not support this operation.
- *
- * @return the CPU time used by the process in nanoseconds,
- * or -1 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();
-
-}
diff -r ca83b4cae363 -r e37c7eba132f jdk/src/java.management/share/classes/com/sun/management/ThreadMXBean.java
--- a/jdk/src/java.management/share/classes/com/sun/management/ThreadMXBean.java Wed Apr 15 13:27:39 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,222 +0,0 @@
-/*
- * 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 java.util.Map;
-
-/**
- * Platform-specific management interface for the thread system
- * of the Java virtual machine.
- *
- * 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.
- *
- * 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 java.lang.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.
- *
- * 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 java.lang.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 for the thread of 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.
- *
- * If the thread of 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.
- *
- * 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 a thread of the specified ID
- * if the thread of 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 java.lang.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.
- *
- * 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 java.lang.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 java.lang.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 java.lang.UnsupportedOperationException if the Java virtual
- * machine does not support thread memory allocation measurement.
- *
- * @throws java.lang.SecurityException if a security manager
- * exists and the caller does not have
- * ManagementPermission("control").
- *
- * @see #isThreadAllocatedMemorySupported
- */
- public void setThreadAllocatedMemoryEnabled(boolean enable);
-}
diff -r ca83b4cae363 -r e37c7eba132f jdk/src/java.management/share/classes/com/sun/management/UnixOperatingSystemMXBean.java
--- a/jdk/src/java.management/share/classes/com/sun/management/UnixOperatingSystemMXBean.java Wed Apr 15 13:27:39 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,52 +0,0 @@
-/*
- * 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();
-}
diff -r ca83b4cae363 -r e37c7eba132f jdk/src/java.management/share/classes/com/sun/management/VMOption.java
--- a/jdk/src/java.management/share/classes/com/sun/management/VMOption.java Wed Apr 15 13:27:39 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,245 +0,0 @@
-/*
- * 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 origin}.
- *
- * 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 VMOption contains the value of a VM option
- * and the origin of that value at the time this VMOption
- * object was constructed. The value of the VM option
- * may be changed after the VMOption object was constructed,
- *
- * @see
- * Java Virtual Machine
- * @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 using the attach framework.
- * @since 1.9
- */
- ATTACH_ON_DEMAND,
- /**
- * The VM option was set via some other mechanism.
- */
- OTHER
- }
-
- /**
- * Constructs a VMOption.
- *
- * @param name Name of a VM option.
- * @param value Value of a VM option.
- * @param writeable true if a VM option can be set dynamically,
- * or false otherwise.
- * @param origin where the value of a VM option came from.
- *
- * @throws NullPointerException if the name or value is null
- */
- public VMOption(String name, String value, boolean writeable, Origin origin) {
- this.name = name;
- this.value = value;
- this.writeable = writeable;
- this.origin = origin;
- }
-
- /**
- * Constructs a VMOption 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 VMOption was created. The value could have been changed.
- *
- * @return the value of the VM option at the time when
- * this VMOption 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 true if this VM option is writeable; false
- * otherwise.
- */
- public boolean isWriteable() {
- return writeable;
- }
-
- public String toString() {
- return "VM option: " + getName() +
- " value: " + value + " " +
- " origin: " + origin + " " +
- (writeable ? "(read-write)" : "(read-only)");
- }
-
- /**
- * Returns a VMOption object represented by the
- * given CompositeData. The given CompositeData
- * must contain the following attributes:
- *
- *
- *
- *
- *
Attribute Name
- *
Type
- *
- *
- *
name
- *
java.lang.String
- *
- *
- *
value
- *
java.lang.String
- *
- *
- *
origin
- *
java.lang.String
- *
- *
- *
writeable
- *
java.lang.Boolean
- *
- *
- *
- *
- * @param cd CompositeData representing a VMOption
- *
- * @throws IllegalArgumentException if cd does not
- * represent a VMOption with the attributes described
- * above.
- *
- * @return a VMOption object represented by cd
- * if cd is not null;
- * null 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);
- }
-
- }
-
-
-}
diff -r ca83b4cae363 -r e37c7eba132f jdk/src/java.management/share/classes/com/sun/management/internal/PlatformMBeanProviderImpl.java
--- a/jdk/src/java.management/share/classes/com/sun/management/internal/PlatformMBeanProviderImpl.java Wed Apr 15 13:27:39 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,209 +0,0 @@
-/*
- * Copyright (c) 2015, 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.internal;
-
-import java.lang.management.ManagementFactory;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-import javax.management.DynamicMBean;
-import javax.management.ObjectName;
-import sun.management.ManagementFactoryHelper;
-import sun.management.spi.PlatformMBeanProvider;
-
-public final class PlatformMBeanProviderImpl extends PlatformMBeanProvider {
- private final List> mxbeanList;
-
- public PlatformMBeanProviderImpl() {
- mxbeanList = Collections.unmodifiableList(init());
- }
-
- @Override
- public List> getPlatformComponentList() {
- return mxbeanList;
- }
-
- private List> init() {
- ArrayList> initMBeanList = new ArrayList<>();
- /**
- * Garbage Collector in the Java virtual machine.
- */
- initMBeanList.add(new PlatformComponent() {
- private final Set garbageCollectorMXBeanInterfaceNames
- = Collections.unmodifiableSet(
- Stream.of("java.lang.management.MemoryManagerMXBean",
- "java.lang.management.GarbageCollectorMXBean",
- "com.sun.management.GarbageCollectorMXBean")
- .collect(Collectors.toSet()));
-
- @Override
- public Set> mbeanInterfaces() {
- return Stream.of(java.lang.management.MemoryManagerMXBean.class,
- java.lang.management.GarbageCollectorMXBean.class,
- com.sun.management.GarbageCollectorMXBean.class)
- .collect(Collectors.toSet());
- }
-
- @Override
- public Set mbeanInterfaceNames() {
- return garbageCollectorMXBeanInterfaceNames;
- }
-
- @Override
- public String getObjectNamePattern() {
- return ManagementFactory.GARBAGE_COLLECTOR_MXBEAN_DOMAIN_TYPE + ",name=*";
- }
-
- @Override
- public boolean isSingleton() {
- return false; // zero or more instances
- }
-
- @Override
- public Map nameToMBeanMap() {
- List list
- = ManagementFactoryHelper.getGarbageCollectorMXBeans();;
- Map map;
- if (list.isEmpty()) {
- map = Collections.emptyMap();
- } else {
- map = new HashMap<>(list.size());
- for (java.lang.management.MemoryManagerMXBean gcm : list) {
- map.put(gcm.getObjectName().getCanonicalName(),
- gcm);
- }
- }
- return map;
- }
- });
-
- /**
- * OperatingSystemMXBean
- */
- initMBeanList.add(new PlatformComponent() {
- private final Set operatingSystemMXBeanInterfaceNames
- = Collections.unmodifiableSet(
- Stream.of("java.lang.management.OperatingSystemMXBean",
- "com.sun.management.OperatingSystemMXBean",
- "com.sun.management.UnixOperatingSystemMXBean")
- .collect(Collectors.toSet()));
-
- @Override
- public Set> mbeanInterfaces() {
- return Stream.of(java.lang.management.OperatingSystemMXBean.class,
- com.sun.management.OperatingSystemMXBean.class,
- com.sun.management.UnixOperatingSystemMXBean.class)
- .collect(Collectors.toSet());
- }
-
- @Override
- public Set mbeanInterfaceNames() {
- return operatingSystemMXBeanInterfaceNames;
- }
-
- @Override
- public String getObjectNamePattern() {
- return ManagementFactory.OPERATING_SYSTEM_MXBEAN_NAME;
- }
-
- @Override
- public Map nameToMBeanMap() {
- return Collections.singletonMap(
- ManagementFactory.OPERATING_SYSTEM_MXBEAN_NAME,
- ManagementFactoryHelper.getOperatingSystemMXBean());
- }
- });
-
- /**
- * Diagnostic support for the HotSpot Virtual Machine.
- */
- initMBeanList.add(new PlatformComponent() {
- private final Set hotSpotDiagnosticMXBeanInterfaceNames =
- Collections.unmodifiableSet(Collections.singleton("com.sun.management.HotSpotDiagnosticMXBean"));
-
- @Override
- public Set> mbeanInterfaces() {
- return Collections.singleton(com.sun.management.HotSpotDiagnosticMXBean.class);
- }
-
- @Override
- public Set mbeanInterfaceNames() {
- return hotSpotDiagnosticMXBeanInterfaceNames;
- }
-
- @Override
- public String getObjectNamePattern() {
- return "com.sun.management:type=HotSpotDiagnostic";
- }
-
- @Override
- public Map nameToMBeanMap() {
- return Collections.singletonMap(
- "com.sun.management:type=HotSpotDiagnostic",
- ManagementFactoryHelper.getDiagnosticMXBean());
- }
- });
-
- /**
- * DynamicMBean
- */
- HashMap dynmbeans
- = ManagementFactoryHelper.getPlatformDynamicMBeans();
- final Set dynamicMBeanInterfaceNames =
- Collections.unmodifiableSet(Collections.singleton("javax.management.DynamicMBean"));
- for (Map.Entry e : dynmbeans.entrySet()) {
- initMBeanList.add(new PlatformComponent() {
- @Override
- public Set mbeanInterfaceNames() {
- return dynamicMBeanInterfaceNames;
- }
-
- @Override
- public Set> mbeanInterfaces() {
- return Collections.emptySet(); // DynamicMBean cannot be used to find an MBean by ManagementFactory
- }
-
- @Override
- public String getObjectNamePattern() {
- return e.getKey().getCanonicalName();
- }
-
- @Override
- public Map nameToMBeanMap() {
- return Collections.singletonMap(
- e.getKey().getCanonicalName(),
- e.getValue());
- }
- });
- }
- initMBeanList.trimToSize();
- return initMBeanList;
- }
-}
diff -r ca83b4cae363 -r e37c7eba132f jdk/src/java.management/share/classes/com/sun/management/package-info.java
--- a/jdk/src/java.management/share/classes/com/sun/management/package-info.java Wed Apr 15 13:27:39 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,44 +0,0 @@
-/*
- * 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
- *
- * java.lang.management API and also defines the management
- * interface for some other components for the platform.
- *
- *
- * All platform MBeans are registered in the platform MBeanServer
- * which can be obtained via the
- *
- * java.lang.management.ManagementFactory.getPlatformMBeanServer
- *
- * @author Mandy Chung
- * @since 1.5
- */
-
-@jdk.Exported
-package com.sun.management;
diff -r ca83b4cae363 -r e37c7eba132f jdk/src/java.management/share/classes/java/lang/management/DefaultPlatformMBeanProvider.java
--- a/jdk/src/java.management/share/classes/java/lang/management/DefaultPlatformMBeanProvider.java Wed Apr 15 13:27:39 2015 +0200
+++ b/jdk/src/java.management/share/classes/java/lang/management/DefaultPlatformMBeanProvider.java Fri Apr 17 09:40:02 2015 +0200
@@ -33,7 +33,6 @@
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
-import javax.management.DynamicMBean;
import javax.management.ObjectName;
import sun.management.ManagementFactoryHelper;
import sun.management.spi.PlatformMBeanProvider;
@@ -162,8 +161,7 @@
@Override
public Set> mbeanInterfaces() {
return Stream.of(MemoryManagerMXBean.class,
- GarbageCollectorMXBean.class,
- com.sun.management.GarbageCollectorMXBean.class).collect(Collectors.toSet());
+ GarbageCollectorMXBean.class).collect(Collectors.toSet());
}
@Override
@@ -464,39 +462,6 @@
});
- /**
- * DynamicMBean
- */
- HashMap dynmbeans
- = ManagementFactoryHelper.getPlatformDynamicMBeans();
- final Set dynamicMBeanInterfaceNames =
- Collections.unmodifiableSet(Collections.singleton("javax.management.DynamicMBean"));
- for (Map.Entry e : dynmbeans.entrySet()) {
- initMBeanList.add(new PlatformComponent() {
- @Override
- public Set> mbeanInterfaces() {
- return Collections.emptySet();
- }
-
- @Override
- public Set mbeanInterfaceNames() {
- return dynamicMBeanInterfaceNames;
- }
-
- @Override
- public String getObjectNamePattern() {
- return e.getKey().getCanonicalName();
- }
-
- @Override
- public Map nameToMBeanMap() {
- return Collections.singletonMap(
- e.getKey().getCanonicalName(),
- e.getValue());
- }
- });
- }
-
initMBeanList.trimToSize();
return initMBeanList;
}
diff -r ca83b4cae363 -r e37c7eba132f jdk/src/java.management/share/classes/java/lang/management/ManagementFactory.java
--- a/jdk/src/java.management/share/classes/java/lang/management/ManagementFactory.java Wed Apr 15 13:27:39 2015 +0200
+++ b/jdk/src/java.management/share/classes/java/lang/management/ManagementFactory.java Fri Apr 17 09:40:02 2015 +0200
@@ -582,7 +582,7 @@
final Class> cls = mxbeanInterface;
ClassLoader loader =
AccessController.doPrivileged(
- (PrivilegedAction) () -> cls.getClassLoader());
+ (PrivilegedAction) () -> cls.getClassLoader());
if (!sun.misc.VM.isSystemDomainLoader(loader)) {
throw new IllegalArgumentException(mxbeanName +
" is not a platform MXBean");
@@ -883,7 +883,7 @@
all.add(new DefaultPlatformMBeanProvider());
return all;
}, null, new FilePermission("<>", "read"),
- new RuntimePermission("sun.management.spi.PlatformMBeanProvider"));
+ new RuntimePermission("sun.management.spi.PlatformMBeanProvider.subclass"));
// load all platform components into a map
componentMap = providers.stream()
@@ -970,4 +970,11 @@
return singleton;
}
}
+
+ static {
+ AccessController.doPrivileged((PrivilegedAction) () -> {
+ System.loadLibrary("management");
+ return null;
+ });
+ }
}
diff -r ca83b4cae363 -r e37c7eba132f jdk/src/java.management/share/classes/sun/management/DiagnosticCommandArgumentInfo.java
--- a/jdk/src/java.management/share/classes/sun/management/DiagnosticCommandArgumentInfo.java Wed Apr 15 13:27:39 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,159 +0,0 @@
-/*
- * 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 sun.management;
-
-/**
- * Diagnostic Command Argument information. It contains the description
- * of one parameter of the diagnostic command. A parameter can either be an
- * option or an argument. Options are identified by the option name while
- * arguments are identified by their position in the command line. The generic
- * syntax of a diagnostic command is:
- *
- * In this command line, the diagnostic command receives five parameters, two
- * options named {@code option1} and {@code option2}, and three arguments.
- * argumentA's position is 0, argumentB's position is 1 and argumentC's
- * position is 2.
- *
- * @since 1.8
- */
-
-class DiagnosticCommandArgumentInfo {
- private final String name;
- private final String description;
- private final String type;
- private final String defaultValue;
- private final boolean mandatory;
- private final boolean option;
- private final boolean multiple;
- private final int position;
-
- /**
- * Returns the argument name.
- *
- * @return the argument name
- */
- String getName() {
- return name;
- }
-
- /**
- * Returns the argument description.
- *
- * @return the argument description
- */
- String getDescription() {
- return description;
- }
-
- /**
- * Returns the argument type.
- *
- * @return the argument type
- */
- String getType() {
- return type;
- }
-
- /**
- * Returns the default value as a String if a default value
- * is defined, null otherwise.
- *
- * @return the default value as a String if a default value
- * is defined, null otherwise.
- */
- String getDefault() {
- return defaultValue;
- }
-
- /**
- * Returns {@code true} if the argument is mandatory,
- * {@code false} otherwise.
- *
- * @return {@code true} if the argument is mandatory,
- * {@code false} otherwise
- */
- boolean isMandatory() {
- return mandatory;
- }
-
- /**
- * Returns {@code true} if the argument is an option,
- * {@code false} otherwise. Options have to be specified using the
- * <key>=<value> syntax on the command line, while other
- * arguments are specified with a single <value> field and are
- * identified by their position on command line.
- *
- * @return {@code true} if the argument is an option,
- * {@code false} otherwise
- */
- boolean isOption() {
- return option;
- }
-
- /**
- * Returns {@code true} if the argument can be specified multiple times,
- * {@code false} otherwise.
- *
- * @return {@code true} if the argument can be specified multiple times,
- * {@code false} otherwise
- */
- boolean isMultiple() {
- return multiple;
- }
-
- /**
- * Returns the expected position of this argument if it is not an option,
- * -1 otherwise. Argument position if defined from left to right,
- * starting at zero and ignoring the diagnostic command name and
- * options.
- *
- * @return the expected position of this argument if it is not an option,
- * -1 otherwise.
- */
- int getPosition() {
- return position;
- }
-
- DiagnosticCommandArgumentInfo(String name, String description,
- String type, String defaultValue,
- boolean mandatory, boolean option,
- boolean multiple, int position) {
- this.name = name;
- this.description = description;
- this.type = type;
- this.defaultValue = defaultValue;
- this.mandatory = mandatory;
- this.option = option;
- this.multiple = multiple;
- this.position = position;
- }
-}
diff -r ca83b4cae363 -r e37c7eba132f jdk/src/java.management/share/classes/sun/management/DiagnosticCommandImpl.java
--- a/jdk/src/java.management/share/classes/sun/management/DiagnosticCommandImpl.java Wed Apr 15 13:27:39 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,380 +0,0 @@
-/*
- * Copyright (c) 2013, 2014, 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 sun.management;
-
-import com.sun.management.DiagnosticCommandMBean;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.security.Permission;
-import java.util.*;
-import javax.management.*;
-
-/**
- * Implementation class for the diagnostic commands subsystem.
- *
- * @since 1.8
- */
-class DiagnosticCommandImpl extends NotificationEmitterSupport
- implements DiagnosticCommandMBean {
-
- private final VMManagement jvm;
- private volatile Map wrappers = null;
- private static final String strClassName = "".getClass().getName();
- private static final String strArrayClassName = String[].class.getName();
- private final boolean isSupported;
-
- @Override
- public Object getAttribute(String attribute) throws AttributeNotFoundException,
- MBeanException, ReflectionException {
- throw new AttributeNotFoundException(attribute);
- }
-
- @Override
- public void setAttribute(Attribute attribute) throws AttributeNotFoundException,
- InvalidAttributeValueException, MBeanException, ReflectionException {
- throw new AttributeNotFoundException(attribute.getName());
- }
-
- @Override
- public AttributeList getAttributes(String[] attributes) {
- return new AttributeList();
- }
-
- @Override
- public AttributeList setAttributes(AttributeList attributes) {
- return new AttributeList();
- }
-
- private class Wrapper {
-
- String name;
- String cmd;
- DiagnosticCommandInfo info;
- Permission permission;
-
- Wrapper(String name, String cmd, DiagnosticCommandInfo info)
- throws InstantiationException {
- this.name = name;
- this.cmd = cmd;
- this.info = info;
- this.permission = null;
- Exception cause = null;
- if (info.getPermissionClass() != null) {
- try {
- Class> c = Class.forName(info.getPermissionClass());
- if (info.getPermissionAction() == null) {
- try {
- Constructor> constructor = c.getConstructor(String.class);
- permission = (Permission) constructor.newInstance(info.getPermissionName());
-
- } catch (InstantiationException | IllegalAccessException
- | IllegalArgumentException | InvocationTargetException
- | NoSuchMethodException | SecurityException ex) {
- cause = ex;
- }
- }
- if (permission == null) {
- try {
- Constructor> constructor = c.getConstructor(String.class, String.class);
- permission = (Permission) constructor.newInstance(
- info.getPermissionName(),
- info.getPermissionAction());
- } catch (InstantiationException | IllegalAccessException
- | IllegalArgumentException | InvocationTargetException
- | NoSuchMethodException | SecurityException ex) {
- cause = ex;
- }
- }
- } catch (ClassNotFoundException ex) { }
- if (permission == null) {
- InstantiationException iex =
- new InstantiationException("Unable to instantiate required permission");
- iex.initCause(cause);
- }
- }
- }
-
- public String execute(String[] args) {
- if (permission != null) {
- SecurityManager sm = System.getSecurityManager();
- if (sm != null) {
- sm.checkPermission(permission);
- }
- }
- if(args == null) {
- return executeDiagnosticCommand(cmd);
- } else {
- StringBuilder sb = new StringBuilder();
- sb.append(cmd);
- for(int i=0; i {
- @Override
- public int compare(MBeanOperationInfo o1, MBeanOperationInfo o2) {
- return o1.getName().compareTo(o2.getName());
- }
- }
-
- @Override
- public MBeanInfo getMBeanInfo() {
- SortedSet operations = new TreeSet<>(new OperationInfoComparator());
- Map wrappersmap;
- if (!isSupported) {
- wrappersmap = Collections.emptyMap();
- } else {
- try {
- String[] command = getDiagnosticCommands();
- DiagnosticCommandInfo[] info = getDiagnosticCommandInfo(command);
- MBeanParameterInfo stringArgInfo[] = new MBeanParameterInfo[]{
- new MBeanParameterInfo("arguments", strArrayClassName,
- "Array of Diagnostic Commands Arguments and Options")
- };
- wrappersmap = new HashMap<>();
- for (int i = 0; i < command.length; i++) {
- String name = transform(command[i]);
- try {
- Wrapper w = new Wrapper(name, command[i], info[i]);
- wrappersmap.put(name, w);
- operations.add(new MBeanOperationInfo(
- w.name,
- w.info.getDescription(),
- (w.info.getArgumentsInfo() == null
- || w.info.getArgumentsInfo().isEmpty())
- ? null : stringArgInfo,
- strClassName,
- MBeanOperationInfo.ACTION_INFO,
- commandDescriptor(w)));
- } catch (InstantiationException ex) {
- // If for some reasons the creation of a diagnostic command
- // wrappers fails, the diagnostic command is just ignored
- // and won't appear in the DynamicMBean
- }
- }
- } catch (IllegalArgumentException | UnsupportedOperationException e) {
- wrappersmap = Collections.emptyMap();
- }
- }
- wrappers = Collections.unmodifiableMap(wrappersmap);
- HashMap map = new HashMap<>();
- map.put("immutableInfo", "false");
- map.put("interfaceClassName","com.sun.management.DiagnosticCommandMBean");
- map.put("mxbean", "false");
- Descriptor desc = new ImmutableDescriptor(map);
- return new MBeanInfo(
- this.getClass().getName(),
- "Diagnostic Commands",
- null, // attributes
- null, // constructors
- operations.toArray(new MBeanOperationInfo[operations.size()]), // operations
- getNotificationInfo(), // notifications
- desc);
- }
-
- @Override
- public Object invoke(String actionName, Object[] params, String[] signature)
- throws MBeanException, ReflectionException {
- if (!isSupported) {
- throw new UnsupportedOperationException();
- }
- if (wrappers == null) {
- getMBeanInfo();
- }
- Wrapper w = wrappers.get(actionName);
- if (w != null) {
- if (w.info.getArgumentsInfo().isEmpty()
- && (params == null || params.length == 0)
- && (signature == null || signature.length == 0)) {
- return w.execute(null);
- } else if((params != null && params.length == 1)
- && (signature != null && signature.length == 1
- && signature[0] != null
- && signature[0].compareTo(strArrayClassName) == 0)) {
- return w.execute((String[]) params[0]);
- }
- }
- throw new ReflectionException(new NoSuchMethodException(actionName));
- }
-
- private static String transform(String name) {
- StringBuilder sb = new StringBuilder();
- boolean toLower = true;
- boolean toUpper = false;
- for (int i = 0; i < name.length(); i++) {
- char c = name.charAt(i);
- if (c == '.' || c == '_') {
- toLower = false;
- toUpper = true;
- } else {
- if (toUpper) {
- toUpper = false;
- sb.append(Character.toUpperCase(c));
- } else if(toLower) {
- sb.append(Character.toLowerCase(c));
- } else {
- sb.append(c);
- }
- }
- }
- return sb.toString();
- }
-
- private Descriptor commandDescriptor(Wrapper w) throws IllegalArgumentException {
- HashMap map = new HashMap<>();
- map.put("dcmd.name", w.info.getName());
- map.put("dcmd.description", w.info.getDescription());
- map.put("dcmd.vmImpact", w.info.getImpact());
- map.put("dcmd.permissionClass", w.info.getPermissionClass());
- map.put("dcmd.permissionName", w.info.getPermissionName());
- map.put("dcmd.permissionAction", w.info.getPermissionAction());
- map.put("dcmd.enabled", w.info.isEnabled());
- StringBuilder sb = new StringBuilder();
- sb.append("help ");
- sb.append(w.info.getName());
- map.put("dcmd.help", executeDiagnosticCommand(sb.toString()));
- if (w.info.getArgumentsInfo() != null && !w.info.getArgumentsInfo().isEmpty()) {
- HashMap allargmap = new HashMap<>();
- for (DiagnosticCommandArgumentInfo arginfo : w.info.getArgumentsInfo()) {
- HashMap argmap = new HashMap<>();
- argmap.put("dcmd.arg.name", arginfo.getName());
- argmap.put("dcmd.arg.type", arginfo.getType());
- argmap.put("dcmd.arg.description", arginfo.getDescription());
- argmap.put("dcmd.arg.isMandatory", arginfo.isMandatory());
- argmap.put("dcmd.arg.isMultiple", arginfo.isMultiple());
- boolean isOption = arginfo.isOption();
- argmap.put("dcmd.arg.isOption", isOption);
- if(!isOption) {
- argmap.put("dcmd.arg.position", arginfo.getPosition());
- } else {
- argmap.put("dcmd.arg.position", -1);
- }
- allargmap.put(arginfo.getName(), new ImmutableDescriptor(argmap));
- }
- map.put("dcmd.arguments", new ImmutableDescriptor(allargmap));
- }
- return new ImmutableDescriptor(map);
- }
-
- private final static String notifName =
- "javax.management.Notification";
-
- private final static String[] diagFramNotifTypes = {
- "jmx.mbean.info.changed"
- };
-
- private MBeanNotificationInfo[] notifInfo = null;
-
- @Override
- public MBeanNotificationInfo[] getNotificationInfo() {
- synchronized (this) {
- if (notifInfo == null) {
- notifInfo = new MBeanNotificationInfo[1];
- notifInfo[0] =
- new MBeanNotificationInfo(diagFramNotifTypes,
- notifName,
- "Diagnostic Framework Notification");
- }
- }
- return notifInfo;
- }
-
- private static long seqNumber = 0;
- private static long getNextSeqNumber() {
- return ++seqNumber;
- }
-
- private void createDiagnosticFrameworkNotification() {
-
- if (!hasListeners()) {
- return;
- }
- ObjectName on = null;
- try {
- on = ObjectName.getInstance(ManagementFactoryHelper.HOTSPOT_DIAGNOSTIC_COMMAND_MBEAN_NAME);
- } catch (MalformedObjectNameException e) { }
- Notification notif = new Notification("jmx.mbean.info.changed",
- on,
- getNextSeqNumber());
- notif.setUserData(getMBeanInfo());
- sendNotification(notif);
- }
-
- @Override
- public synchronized void addNotificationListener(NotificationListener listener,
- NotificationFilter filter,
- Object handback) {
- boolean before = hasListeners();
- super.addNotificationListener(listener, filter, handback);
- boolean after = hasListeners();
- if (!before && after) {
- setNotificationEnabled(true);
- }
- }
-
- @Override
- public synchronized void removeNotificationListener(NotificationListener listener)
- throws ListenerNotFoundException {
- boolean before = hasListeners();
- super.removeNotificationListener(listener);
- boolean after = hasListeners();
- if (before && !after) {
- setNotificationEnabled(false);
- }
- }
-
- @Override
- public synchronized void removeNotificationListener(NotificationListener listener,
- NotificationFilter filter,
- Object handback)
- throws ListenerNotFoundException {
- boolean before = hasListeners();
- super.removeNotificationListener(listener, filter, handback);
- boolean after = hasListeners();
- if (before && !after) {
- setNotificationEnabled(false);
- }
- }
-
- private native void setNotificationEnabled(boolean enabled);
- private native String[] getDiagnosticCommands();
- private native DiagnosticCommandInfo[] getDiagnosticCommandInfo(String[] commands);
- private native String executeDiagnosticCommand(String command);
-
-}
diff -r ca83b4cae363 -r e37c7eba132f jdk/src/java.management/share/classes/sun/management/DiagnosticCommandInfo.java
--- a/jdk/src/java.management/share/classes/sun/management/DiagnosticCommandInfo.java Wed Apr 15 13:27:39 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,151 +0,0 @@
-/*
- * 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 sun.management;
-
-import java.util.List;
-
-/**
- * Diagnostic command information. It contains the description of a
- * diagnostic command.
- *
- * @since 1.8
- */
-
-class DiagnosticCommandInfo {
- private final String name;
- private final String description;
- private final String impact;
- private final String permissionClass;
- private final String permissionName;
- private final String permissionAction;
- private final boolean enabled;
- private final List arguments;
-
- /**
- * Returns the diagnostic command name.
- *
- * @return the diagnostic command name
- */
- String getName() {
- return name;
- }
-
- /**
- * Returns the diagnostic command description.
- *
- * @return the diagnostic command description
- */
- String getDescription() {
- return description;
- }
-
- /**
- * Returns the potential impact of the diagnostic command execution
- * on the Java virtual machine behavior.
- *
- * @return the potential impact of the diagnostic command execution
- * on the Java virtual machine behavior
- */
- String getImpact() {
- return impact;
- }
-
- /**
- * Returns the name of the permission class required to be allowed
- * to invoke the diagnostic command, or null if no permission
- * is required.
- *
- * @return the name of the permission class name required to be allowed
- * to invoke the diagnostic command, or null if no permission
- * is required
- */
- String getPermissionClass() {
- return permissionClass;
- }
-
- /**
- * Returns the permission name required to be allowed to invoke the
- * diagnostic command, or null if no permission is required.
- *
- * @return the permission name required to be allowed to invoke the
- * diagnostic command, or null if no permission is required
- */
- String getPermissionName() {
- return permissionName;
- }
-
- /**
- * Returns the permission action required to be allowed to invoke the
- * diagnostic command, or null if no permission is required or
- * if the permission has no action specified.
- *
- * @return the permission action required to be allowed to invoke the
- * diagnostic command, or null if no permission is required or
- * if the permission has no action specified
- */
- String getPermissionAction() {
- return permissionAction;
- }
-
- /**
- * Returns {@code true} if the diagnostic command is enabled,
- * {@code false} otherwise. The enabled/disabled
- * status of a diagnostic command can evolve during
- * the lifetime of the Java virtual machine.
- *
- * @return {@code true} if the diagnostic command is enabled,
- * {@code false} otherwise
- */
- boolean isEnabled() {
- return enabled;
- }
-
- /**
- * Returns the list of the diagnostic command arguments description.
- * If the diagnostic command has no arguments, it returns an empty list.
- *
- * @return a list of the diagnostic command arguments description
- */
- List getArgumentsInfo() {
- return arguments;
- }
-
- DiagnosticCommandInfo(String name, String description,
- String impact, String permissionClass,
- String permissionName, String permissionAction,
- boolean enabled,
- List arguments)
- {
- this.name = name;
- this.description = description;
- this.impact = impact;
- this.permissionClass = permissionClass;
- this.permissionName = permissionName;
- this.permissionAction = permissionAction;
- this.enabled = enabled;
- this.arguments = arguments;
- }
-}
diff -r ca83b4cae363 -r e37c7eba132f jdk/src/java.management/share/classes/sun/management/Flag.java
--- a/jdk/src/java.management/share/classes/sun/management/Flag.java Wed Apr 15 13:27:39 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,129 +0,0 @@
-/*
- * Copyright (c) 2003, 2014, 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 sun.management;
-
-import java.util.*;
-import com.sun.management.VMOption;
-import com.sun.management.VMOption.Origin;
-import java.security.AccessController;
-
-/**
- * Flag class is a helper class for constructing a VMOption.
- * It has the static methods for getting the Flag objects, each
- * corresponds to one VMOption.
- *
- */
-class Flag {
- private String name;
- private Object value;
- private Origin origin;
- private boolean writeable;
- private boolean external;
-
- Flag(String name, Object value, boolean writeable,
- boolean external, Origin origin) {
- this.name = name;
- this.value = value == null ? "" : value ;
- this.origin = origin;
- this.writeable = writeable;
- this.external = external;
- }
-
- Object getValue() {
- return value;
- }
-
- boolean isWriteable() {
- return writeable;
- }
-
- boolean isExternal() {
- return external;
- }
-
- VMOption getVMOption() {
- return new VMOption(name, value.toString(), writeable, origin);
- }
-
- static Flag getFlag(String name) {
- String[] names = new String[1];
- names[0] = name;
-
- List flags = getFlags(names, 1);
- if (flags.isEmpty()) {
- return null;
- } else {
- // flags should have only one element
- return flags.get(0);
- }
- }
-
- static List getAllFlags() {
- int numFlags = getInternalFlagCount();
-
- // Get all internal flags with names = null
- return getFlags(null, numFlags);
- }
-
- private static List getFlags(String[] names, int numFlags) {
- Flag[] flags = new Flag[numFlags];
- int count = getFlags(names, flags, numFlags);
-
- List result = new ArrayList<>();
- for (Flag f : flags) {
- if (f != null) {
- result.add(f);
- }
- }
- return result;
- }
-
- private static native String[] getAllFlagNames();
- // getFlags sets each element in the given flags array
- // with a Flag object only if the name is valid and the
- // type is supported. The flags array may contain null elements.
- private static native int getFlags(String[] names, Flag[] flags, int count);
- private static native int getInternalFlagCount();
-
- // These set* methods are synchronized on the class object
- // to avoid multiple threads updating the same flag at the same time.
- static synchronized native void setLongValue(String name, long value);
- static synchronized native void setDoubleValue(String name, double value);
- static synchronized native void setBooleanValue(String name, boolean value);
- static synchronized native void setStringValue(String name, String value);
-
- static {
- AccessController.doPrivileged(
- new java.security.PrivilegedAction() {
- public Void run() {
- System.loadLibrary("management");
- return null;
- }
- });
- initialize();
- }
- private static native void initialize();
-}
diff -r ca83b4cae363 -r e37c7eba132f jdk/src/java.management/share/classes/sun/management/GarbageCollectionNotifInfoCompositeData.java
--- a/jdk/src/java.management/share/classes/sun/management/GarbageCollectionNotifInfoCompositeData.java Wed Apr 15 13:27:39 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,215 +0,0 @@
-/*
- * Copyright (c) 2011, 2014, 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 sun.management;
-
-import com.sun.management.GarbageCollectionNotificationInfo;
-import com.sun.management.GcInfo;
-import java.lang.reflect.Method;
-import javax.management.openmbean.CompositeData;
-import javax.management.openmbean.CompositeType;
-import javax.management.openmbean.CompositeDataSupport;
-import javax.management.openmbean.OpenDataException;
-import javax.management.openmbean.OpenType;
-import javax.management.openmbean.SimpleType;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.lang.reflect.Field;
-import java.util.HashMap;
-
-/**
- * A CompositeData for GarbageCollectionNotificationInfo for the local management support.
- * This class avoids the performance penalty paid to the
- * construction of a CompositeData use in the local case.
- */
-public class GarbageCollectionNotifInfoCompositeData extends LazyCompositeData {
- private final GarbageCollectionNotificationInfo gcNotifInfo;
-
- public GarbageCollectionNotifInfoCompositeData(GarbageCollectionNotificationInfo info) {
- this.gcNotifInfo = info;
- }
-
- public GarbageCollectionNotificationInfo getGarbageCollectionNotifInfo() {
- return gcNotifInfo;
- }
-
- public static CompositeData toCompositeData(GarbageCollectionNotificationInfo info) {
- GarbageCollectionNotifInfoCompositeData gcnicd =
- new GarbageCollectionNotifInfoCompositeData(info);
- return gcnicd.getCompositeData();
- }
-
- private CompositeType getCompositeTypeByBuilder() {
- final GcInfoBuilder builder = AccessController.doPrivileged (new PrivilegedAction() {
- public GcInfoBuilder run() {
- try {
- Class> cl = Class.forName("com.sun.management.GcInfo");
- Field f = cl.getDeclaredField("builder");
- f.setAccessible(true);
- return (GcInfoBuilder)f.get(gcNotifInfo.getGcInfo());
- } catch(ClassNotFoundException | NoSuchFieldException | IllegalAccessException e) {
- return null;
- }
- }
- });
- CompositeType gict = null;
- synchronized(compositeTypeByBuilder) {
- gict = compositeTypeByBuilder.get(builder);
- if(gict == null) {
- OpenType>[] gcNotifInfoItemTypes = new OpenType>[] {
- SimpleType.STRING,
- SimpleType.STRING,
- SimpleType.STRING,
- builder.getGcInfoCompositeType(),
- };
- try {
- final String typeName =
- "sun.management.GarbageCollectionNotifInfoCompositeType";
- gict = new CompositeType(typeName,
- "CompositeType for GC notification info",
- gcNotifInfoItemNames,
- gcNotifInfoItemNames,
- gcNotifInfoItemTypes);
- compositeTypeByBuilder.put(builder,gict);
- } catch (OpenDataException e) {
- // shouldn't reach here
- throw Util.newException(e);
- }
- }
- }
- return gict;
- }
-
- protected CompositeData getCompositeData() {
- // CONTENTS OF THIS ARRAY MUST BE SYNCHRONIZED WITH
- // gcNotifInfoItemNames!
- final Object[] gcNotifInfoItemValues;
- gcNotifInfoItemValues = new Object[] {
- gcNotifInfo.getGcName(),
- gcNotifInfo.getGcAction(),
- gcNotifInfo.getGcCause(),
- GcInfoCompositeData.toCompositeData(gcNotifInfo.getGcInfo())
- };
-
- CompositeType gict = getCompositeTypeByBuilder();
-
- try {
- return new CompositeDataSupport(gict,
- gcNotifInfoItemNames,
- gcNotifInfoItemValues);
- } catch (OpenDataException e) {
- // Should never reach here
- throw new AssertionError(e);
- }
- }
-
- // private static MappedMXBeanType gcInfoMapType;
- private static final String GC_NAME = "gcName";
- private static final String GC_ACTION = "gcAction";
- private static final String GC_CAUSE = "gcCause";
- private static final String GC_INFO = "gcInfo";
- private static final String[] gcNotifInfoItemNames = {
- GC_NAME,
- GC_ACTION,
- GC_CAUSE,
- GC_INFO
- };
- private static HashMap compositeTypeByBuilder =
- new HashMap<>();
-
- public static String getGcName(CompositeData cd) {
- String gcname = getString(cd, GC_NAME);
- if (gcname == null) {
- throw new IllegalArgumentException("Invalid composite data: " +
- "Attribute " + GC_NAME + " has null value");
- }
- return gcname;
- }
-
- public static String getGcAction(CompositeData cd) {
- String gcaction = getString(cd, GC_ACTION);
- if (gcaction == null) {
- throw new IllegalArgumentException("Invalid composite data: " +
- "Attribute " + GC_ACTION + " has null value");
- }
- return gcaction;
- }
-
- public static String getGcCause(CompositeData cd) {
- String gccause = getString(cd, GC_CAUSE);
- if (gccause == null) {
- throw new IllegalArgumentException("Invalid composite data: " +
- "Attribute " + GC_CAUSE + " has null value");
- }
- return gccause;
- }
-
- public static GcInfo getGcInfo(CompositeData cd) {
- CompositeData gcInfoData = (CompositeData) cd.get(GC_INFO);
- return GcInfo.from(gcInfoData);
- }
-
- /** Validate if the input CompositeData has the expected
- * CompositeType (i.e. contain all attributes with expected
- * names and types).
- */
- public static void validateCompositeData(CompositeData cd) {
- if (cd == null) {
- throw new NullPointerException("Null CompositeData");
- }
-
- if (!isTypeMatched( getBaseGcNotifInfoCompositeType(), cd.getCompositeType())) {
- throw new IllegalArgumentException(
- "Unexpected composite type for GarbageCollectionNotificationInfo");
- }
- }
-
- // This is only used for validation.
- private static CompositeType baseGcNotifInfoCompositeType = null;
- private static synchronized CompositeType getBaseGcNotifInfoCompositeType() {
- if (baseGcNotifInfoCompositeType == null) {
- try {
- OpenType>[] baseGcNotifInfoItemTypes = new OpenType>[] {
- SimpleType.STRING,
- SimpleType.STRING,
- SimpleType.STRING,
- GcInfoCompositeData.getBaseGcInfoCompositeType()
- };
- baseGcNotifInfoCompositeType =
- new CompositeType("sun.management.BaseGarbageCollectionNotifInfoCompositeType",
- "CompositeType for Base GarbageCollectionNotificationInfo",
- gcNotifInfoItemNames,
- gcNotifInfoItemNames,
- baseGcNotifInfoItemTypes);
- } catch (OpenDataException e) {
- // shouldn't reach here
- throw Util.newException(e);
- }
- }
- return baseGcNotifInfoCompositeType;
- }
-
- private static final long serialVersionUID = -1805123446483771292L;
-}
diff -r ca83b4cae363 -r e37c7eba132f jdk/src/java.management/share/classes/sun/management/GarbageCollectorImpl.java
--- a/jdk/src/java.management/share/classes/sun/management/GarbageCollectorImpl.java Wed Apr 15 13:27:39 2015 +0200
+++ b/jdk/src/java.management/share/classes/sun/management/GarbageCollectorImpl.java Fri Apr 17 09:40:02 2015 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2015, 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
@@ -25,168 +25,31 @@
package sun.management;
-import com.sun.management.GarbageCollectorMXBean;
-import com.sun.management.GarbageCollectionNotificationInfo;
+import java.lang.management.GarbageCollectorMXBean;
import java.lang.management.ManagementFactory;
-import java.lang.management.MemoryPoolMXBean;
-import java.lang.management.MemoryUsage;
-
-import com.sun.management.GcInfo;
-import javax.management.openmbean.CompositeData;
-import javax.management.MBeanInfo;
-import javax.management.MBeanAttributeInfo;
import javax.management.ObjectName;
-import javax.management.MBeanNotificationInfo;
-import javax.management.Notification;
-import javax.management.NotificationFilter;
-import javax.management.NotificationListener;
-import javax.management.ListenerNotFoundException;
-
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Map;
/**
* Implementation class for the garbage collector.
- * Standard and committed hotspot-specific metrics if any.
*
* ManagementFactory.getGarbageCollectorMXBeans() returns a list
* of instances of this class.
*/
-class GarbageCollectorImpl extends MemoryManagerImpl
+public class GarbageCollectorImpl extends MemoryManagerImpl
implements GarbageCollectorMXBean {
- GarbageCollectorImpl(String name) {
+ protected GarbageCollectorImpl(String name) {
super(name);
}
+ @Override
public native long getCollectionCount();
+
+ @Override
public native long getCollectionTime();
-
- // The memory pools are static and won't be changed.
- // TODO: If the hotspot implementation begins to have pools
- // dynamically created and removed, this needs to be modified.
- private String[] poolNames = null;
- synchronized String[] getAllPoolNames() {
- if (poolNames == null) {
- List pools = ManagementFactory.getMemoryPoolMXBeans();
- poolNames = new String[pools.size()];
- int i = 0;
- for (MemoryPoolMXBean m : pools) {
- poolNames[i++] = m.getName();
- }
- }
- return poolNames;
- }
-
- // Sun JDK extension
- private GcInfoBuilder gcInfoBuilder;
-
- private synchronized GcInfoBuilder getGcInfoBuilder() {
- if(gcInfoBuilder == null) {
- gcInfoBuilder = new GcInfoBuilder(this, getAllPoolNames());
- }
- return gcInfoBuilder;
- }
-
- public GcInfo getLastGcInfo() {
- GcInfo info = getGcInfoBuilder().getLastGcInfo();
- return info;
- }
-
- private final static String notifName =
- "javax.management.Notification";
-
- private final static String[] gcNotifTypes = {
- GarbageCollectionNotificationInfo.GARBAGE_COLLECTION_NOTIFICATION
- };
-
- private MBeanNotificationInfo[] notifInfo = null;
- public MBeanNotificationInfo[] getNotificationInfo() {
- synchronized (this) {
- if (notifInfo == null) {
- notifInfo = new MBeanNotificationInfo[1];
- notifInfo[0] = new MBeanNotificationInfo(gcNotifTypes,
- notifName,
- "GC Notification");
- }
- }
- return notifInfo;
- }
-
- private static long seqNumber = 0;
- private static long getNextSeqNumber() {
- return ++seqNumber;
- }
-
- void createGCNotification(long timestamp,
- String gcName,
- String gcAction,
- String gcCause,
- GcInfo gcInfo) {
-
- if (!hasListeners()) {
- return;
- }
-
- Notification notif = new Notification(GarbageCollectionNotificationInfo.GARBAGE_COLLECTION_NOTIFICATION,
- getObjectName(),
- getNextSeqNumber(),
- timestamp,
- gcName);
- GarbageCollectionNotificationInfo info =
- new GarbageCollectionNotificationInfo(gcName,
- gcAction,
- gcCause,
- gcInfo);
-
- CompositeData cd =
- GarbageCollectionNotifInfoCompositeData.toCompositeData(info);
- notif.setUserData(cd);
- sendNotification(notif);
- }
-
- public synchronized void addNotificationListener(NotificationListener listener,
- NotificationFilter filter,
- Object handback)
- {
- boolean before = hasListeners();
- super.addNotificationListener(listener, filter, handback);
- boolean after = hasListeners();
- if (!before && after) {
- setNotificationEnabled(this, true);
- }
- }
-
- public synchronized void removeNotificationListener(NotificationListener listener)
- throws ListenerNotFoundException {
- boolean before = hasListeners();
- super.removeNotificationListener(listener);
- boolean after = hasListeners();
- if (before && !after) {
- setNotificationEnabled(this,false);
- }
- }
-
- public synchronized void removeNotificationListener(NotificationListener listener,
- NotificationFilter filter,
- Object handback)
- throws ListenerNotFoundException
- {
- boolean before = hasListeners();
- super.removeNotificationListener(listener,filter,handback);
- boolean after = hasListeners();
- if (before && !after) {
- setNotificationEnabled(this,false);
- }
- }
-
+ @Override
public ObjectName getObjectName() {
return Util.newObjectName(ManagementFactory.GARBAGE_COLLECTOR_MXBEAN_DOMAIN_TYPE, getName());
}
-
- native void setNotificationEnabled(GarbageCollectorMXBean gc,
- boolean enabled);
-
}
diff -r ca83b4cae363 -r e37c7eba132f jdk/src/java.management/share/classes/sun/management/GcInfoBuilder.java
--- a/jdk/src/java.management/share/classes/sun/management/GcInfoBuilder.java Wed Apr 15 13:27:39 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,205 +0,0 @@
-/*
- * Copyright (c) 2003, 2014, 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 sun.management;
-
-import java.lang.management.GarbageCollectorMXBean;
-import java.lang.management.MemoryUsage;
-import javax.management.openmbean.OpenType;
-import javax.management.openmbean.SimpleType;
-import javax.management.openmbean.TabularType;
-import javax.management.openmbean.TabularData;
-import javax.management.openmbean.TabularDataSupport;
-import javax.management.openmbean.CompositeType;
-import javax.management.openmbean.CompositeData;
-import javax.management.openmbean.CompositeDataSupport;
-import javax.management.openmbean.OpenDataException;
-import com.sun.management.GcInfo;
-
-/**
- * Helper class to build composite data.
- */
-public class GcInfoBuilder {
- private final GarbageCollectorMXBean gc;
- private final String[] poolNames;
- private String[] allItemNames;
-
- // GC-specific composite type:
- // Each GarbageCollectorMXBean may have different GC-specific attributes
- // the CompositeType for the GcInfo could be different.
- private CompositeType gcInfoCompositeType;
-
- // GC-specific items
- private final int gcExtItemCount;
- private final String[] gcExtItemNames;
- private final String[] gcExtItemDescs;
- private final char[] gcExtItemTypes;
-
- GcInfoBuilder(GarbageCollectorMXBean gc, String[] poolNames) {
- this.gc = gc;
- this.poolNames = poolNames;
- this.gcExtItemCount = getNumGcExtAttributes(gc);
- this.gcExtItemNames = new String[gcExtItemCount];
- this.gcExtItemDescs = new String[gcExtItemCount];
- this.gcExtItemTypes = new char[gcExtItemCount];
-
- // Fill the information about extension attributes
- fillGcAttributeInfo(gc, gcExtItemCount, gcExtItemNames,
- gcExtItemTypes, gcExtItemDescs);
-
- // lazily build the CompositeType for the GcInfo
- // including the GC-specific extension attributes
- this.gcInfoCompositeType = null;
- }
-
- GcInfo getLastGcInfo() {
- MemoryUsage[] usageBeforeGC = new MemoryUsage[poolNames.length];
- MemoryUsage[] usageAfterGC = new MemoryUsage[poolNames.length];
- Object[] values = new Object[gcExtItemCount];
-
- return getLastGcInfo0(gc, gcExtItemCount, values, gcExtItemTypes,
- usageBeforeGC, usageAfterGC);
- }
-
- public String[] getPoolNames() {
- return poolNames;
- }
-
- int getGcExtItemCount() {
- return gcExtItemCount;
- }
-
- // Returns the CompositeType for the GcInfo including
- // the extension attributes
- synchronized CompositeType getGcInfoCompositeType() {
- if (gcInfoCompositeType != null)
- return gcInfoCompositeType;
-
- // First, fill with the attributes in the GcInfo
- String[] gcInfoItemNames = GcInfoCompositeData.getBaseGcInfoItemNames();
- OpenType>[] gcInfoItemTypes = GcInfoCompositeData.getBaseGcInfoItemTypes();
- int numGcInfoItems = gcInfoItemNames.length;
-
- int itemCount = numGcInfoItems + gcExtItemCount;
- allItemNames = new String[itemCount];
- String[] allItemDescs = new String[itemCount];
- OpenType>[] allItemTypes = new OpenType>[itemCount];
-
- System.arraycopy(gcInfoItemNames, 0, allItemNames, 0, numGcInfoItems);
- System.arraycopy(gcInfoItemNames, 0, allItemDescs, 0, numGcInfoItems);
- System.arraycopy(gcInfoItemTypes, 0, allItemTypes, 0, numGcInfoItems);
-
- // Then fill with the extension GC-specific attributes, if any.
- if (gcExtItemCount > 0) {
- fillGcAttributeInfo(gc, gcExtItemCount, gcExtItemNames,
- gcExtItemTypes, gcExtItemDescs);
- System.arraycopy(gcExtItemNames, 0, allItemNames,
- numGcInfoItems, gcExtItemCount);
- System.arraycopy(gcExtItemDescs, 0, allItemDescs,
- numGcInfoItems, gcExtItemCount);
- for (int i = numGcInfoItems, j = 0; j < gcExtItemCount; i++, j++) {
- switch (gcExtItemTypes[j]) {
- case 'Z':
- allItemTypes[i] = SimpleType.BOOLEAN;
- break;
- case 'B':
- allItemTypes[i] = SimpleType.BYTE;
- break;
- case 'C':
- allItemTypes[i] = SimpleType.CHARACTER;
- break;
- case 'S':
- allItemTypes[i] = SimpleType.SHORT;
- break;
- case 'I':
- allItemTypes[i] = SimpleType.INTEGER;
- break;
- case 'J':
- allItemTypes[i] = SimpleType.LONG;
- break;
- case 'F':
- allItemTypes[i] = SimpleType.FLOAT;
- break;
- case 'D':
- allItemTypes[i] = SimpleType.DOUBLE;
- break;
- default:
- throw new AssertionError(
- "Unsupported type [" + gcExtItemTypes[i] + "]");
- }
- }
- }
-
- CompositeType gict = null;
- try {
- final String typeName =
- "sun.management." + gc.getName() + ".GcInfoCompositeType";
-
- gict = new CompositeType(typeName,
- "CompositeType for GC info for " +
- gc.getName(),
- allItemNames,
- allItemDescs,
- allItemTypes);
- } catch (OpenDataException e) {
- // shouldn't reach here
- throw Util.newException(e);
- }
- gcInfoCompositeType = gict;
-
- return gcInfoCompositeType;
- }
-
- synchronized String[] getItemNames() {
- if (allItemNames == null) {
- // initialize when forming the composite type
- getGcInfoCompositeType();
- }
- return allItemNames;
- }
-
- // Retrieve information about extension attributes
- private native int getNumGcExtAttributes(GarbageCollectorMXBean gc);
- private native void fillGcAttributeInfo(GarbageCollectorMXBean gc,
- int numAttributes,
- String[] attributeNames,
- char[] types,
- String[] descriptions);
-
- /**
- * Returns the last GcInfo
- *
- * @param gc GarbageCollectorMXBean that the gc info is associated with.
- * @param numExtAtts number of extension attributes
- * @param extAttValues Values of extension attributes to be filled.
- * @param before Memory usage before GC to be filled.
- * @param after Memory usage after GC to be filled.
- */
- private native GcInfo getLastGcInfo0(GarbageCollectorMXBean gc,
- int numExtAtts,
- Object[] extAttValues,
- char[] extAttTypes,
- MemoryUsage[] before,
- MemoryUsage[] after);
-}
diff -r ca83b4cae363 -r e37c7eba132f jdk/src/java.management/share/classes/sun/management/GcInfoCompositeData.java
--- a/jdk/src/java.management/share/classes/sun/management/GcInfoCompositeData.java Wed Apr 15 13:27:39 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,276 +0,0 @@
-/*
- * Copyright (c) 2004, 2014, 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 sun.management;
-
-import java.lang.management.MemoryUsage;
-import java.lang.reflect.Method;
-import java.lang.reflect.Field;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Collections;
-import java.io.InvalidObjectException;
-import javax.management.openmbean.CompositeType;
-import javax.management.openmbean.CompositeData;
-import javax.management.openmbean.CompositeDataSupport;
-import javax.management.openmbean.TabularData;
-import javax.management.openmbean.SimpleType;
-import javax.management.openmbean.OpenType;
-import javax.management.openmbean.OpenDataException;
-import com.sun.management.GcInfo;
-import com.sun.management.GarbageCollectionNotificationInfo;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-
-/**
- * A CompositeData for GcInfo for the local management support.
- * This class avoids the performance penalty paid to the
- * construction of a CompositeData use in the local case.
- */
-public class GcInfoCompositeData extends LazyCompositeData {
- private final GcInfo info;
- private final GcInfoBuilder builder;
- private final Object[] gcExtItemValues;
-
- public GcInfoCompositeData(GcInfo info,
- GcInfoBuilder builder,
- Object[] gcExtItemValues) {
- this.info = info;
- this.builder = builder;
- this.gcExtItemValues = gcExtItemValues;
- }
-
- public GcInfo getGcInfo() {
- return info;
- }
-
- public static CompositeData toCompositeData(final GcInfo info) {
- final GcInfoBuilder builder = AccessController.doPrivileged (new PrivilegedAction() {
- public GcInfoBuilder run() {
- try {
- Class> cl = Class.forName("com.sun.management.GcInfo");
- Field f = cl.getDeclaredField("builder");
- f.setAccessible(true);
- return (GcInfoBuilder)f.get(info);
- } catch(ClassNotFoundException | NoSuchFieldException | IllegalAccessException e) {
- return null;
- }
- }
- });
- final Object[] extAttr = AccessController.doPrivileged (new PrivilegedAction