# HG changeset patch # User fparain # Date 1329331615 28800 # Node ID b6c37f4753fd1ba1dde3300d246dc53b876a9a82 # Parent b1e37377b2a3c9ba9f4e4fb0daf205c4b11ece94 7145925: Removing remote access to diagnostic commands in the HotSpotDiagnosticMBean Reviewed-by: acorn, mchung, phh diff -r b1e37377b2a3 -r b6c37f4753fd jdk/make/java/management/mapfile-vers --- a/jdk/make/java/management/mapfile-vers Wed Feb 15 09:29:05 2012 -0800 +++ b/jdk/make/java/management/mapfile-vers Wed Feb 15 10:46:55 2012 -0800 @@ -54,9 +54,6 @@ Java_sun_management_GcInfoBuilder_getLastGcInfo0; Java_sun_management_GcInfoBuilder_getNumGcExtAttributes; Java_sun_management_HotSpotDiagnostic_dumpHeap; - Java_sun_management_HotSpotDiagnostic_executeDiagnosticCommand0; - Java_sun_management_HotSpotDiagnostic_getDiagnosticCommandInfo0; - Java_sun_management_HotSpotDiagnostic_getDiagnosticCommands0; Java_sun_management_HotspotThread_getInternalThreadCount; Java_sun_management_HotspotThread_getInternalThreadTimes0; Java_sun_management_MemoryImpl_getMemoryManagers0; diff -r b1e37377b2a3 -r b6c37f4753fd jdk/src/share/classes/com/sun/management/DiagnosticCommandArgumentInfo.java --- a/jdk/src/share/classes/com/sun/management/DiagnosticCommandArgumentInfo.java Wed Feb 15 09:29:05 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,151 +0,0 @@ -/* - * Copyright (c) 2011, 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.beans.ConstructorProperties; - -/** - * 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: - *
- * <command name> [<option>=<value>] [<argument_value>] - *- * Example: - *
- * command_name option1=value1 option2=value argumentA argumentB argumentC - *- * 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. - * - * @author Frederic Parain - * @since 7u4 - */ - -public 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 int position; - - /** - * Returns the argument name - * - * @return the argument name - */ - public String getName() { - return name; - } - - /** - * Returns the argument description - * - * @return the argument description - */ - public String getDescription() { - return description; - } - - /** - * Returns the argument type - * - * @return the argument type - */ - public 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. - */ - public 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 - */ - public 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 - */ - public boolean isOption() { - return option; - } - - /** - * 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. - */ - public int getPosition() { - return position; - } - - @ConstructorProperties({"name","description","type","default", - "mandatory","option","position"}) - public DiagnosticCommandArgumentInfo(String name, String description, - String type, String defaultValue, - boolean mandatory, boolean option, - int position) { - this.name = name; - this.description = description; - this.type = type; - this.defaultValue = defaultValue; - this.mandatory = mandatory; - this.option = option; - this.position = position; - } -} diff -r b1e37377b2a3 -r b6c37f4753fd jdk/src/share/classes/com/sun/management/DiagnosticCommandInfo.java --- a/jdk/src/share/classes/com/sun/management/DiagnosticCommandInfo.java Wed Feb 15 09:29:05 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,110 +0,0 @@ -/* - * Copyright (c) 2011, 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.beans.ConstructorProperties; -import java.util.List; - -/** - * Diagnostic command information. It contains the description of a - * diagnostic command. - * - * @author Frederic Parain - * @since 7u4 - */ - -public class DiagnosticCommandInfo { - private final String name; - private final String description; - private final String impact; - private final boolean enabled; - private final List
{@linkplain #getDiagnosticCommands Diagnostic commands} - * are actions that can be invoked dynamically and - * executed in a target Java virtual machine, mainly for troubleshooting - * and diagnosis. - * *
The diagnostic MBean is registered to the platform MBeanServer
* as are other platform MBeans.
*
@@ -116,108 +111,4 @@
* ManagementPermission("control").
*/
public void setVMOption(String name, String value);
-
- /**
- * Returns the {@linkplain DiagnosticCommandInfo#getName() names}
- * of all diagnostic commands.
- * A diagnostic command is an action that can be invoked dynamically
- * mainly for troubleshooting and diagnosis. The list of diagnostic
- * commands may change at runtime. A diagnostic command may be
- * {@linkplain DiagnosticCommandInfo#isEnabled disabled} but will
- * not be removed from a previously returned list.
- *
- * @return the names of all diagnostic commands.
- *
- * @since 7u4
- */
- public List
- * <command name> [<option>=<value>] [<argument_value>]
- *
- *
- * @param commandLine command line to execute
- * @return a {@code String} object containing the diagnostic command
- * output.
- *
- * @throws java.lang.IllegalArgumentException if the command line doesn't
- * match any diagnostic command registered in the virtual machine
- * of if the parameters don't match the diagnostic command syntax.
- * @throws java.lang.SecurityException
- * if a security manager exists and the caller does not have
- * ManagementPermission("control").
- *
- * @since 7u4
- */
- public String execute(String commandLine);
-
- /**
- * Invokes the diagnostic command named {@code cmd} with the parameters
- * specified in {@code args}. Each command has its own syntax but
- * the generic syntax for parameters is:
- *
- * [<option>=<value>] [<argument_value>]
- *
- *
- * @param cmd a diagnostic command name
- * @param args the command parameters
- * @return a {@code String} object containing the diagnostic command
- * output.
- *
- * @throws java.lang.IllegalArgumentException if the command line doesn't
- * match any diagnostic command registered in the virtual machine
- * of if the parameters don't match the diagnostic command syntax.
- * @throws java.lang.SecurityException
- * if a security manager exists and the caller does not have
- * ManagementPermission("control").
- *
- * @since 7u4
- */
- public String execute(String cmd, String... args);
}
diff -r b1e37377b2a3 -r b6c37f4753fd jdk/src/share/classes/sun/management/HotSpotDiagnostic.java
--- a/jdk/src/share/classes/sun/management/HotSpotDiagnostic.java Wed Feb 15 09:29:05 2012 -0800
+++ b/jdk/src/share/classes/sun/management/HotSpotDiagnostic.java Wed Feb 15 10:46:55 2012 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2012, 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,13 +27,9 @@
import java.io.IOException;
import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
import java.util.List;
import javax.management.ObjectName;
-import com.sun.management.DiagnosticCommandInfo;
-import com.sun.management.DiagnosticCommandArgumentInfo;
import com.sun.management.HotSpotDiagnosticMXBean;
import com.sun.management.VMOption;
@@ -120,54 +116,7 @@
}
}
- public List