Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
e7a72e23
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
4
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_jdk
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e7a72e23
编写于
2月 15, 2012
作者:
F
fparain
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
7145925: Removing remote access to diagnostic commands in the HotSpotDiagnosticMBean
Reviewed-by: acorn, mchung, phh
上级
f639ca49
变更
9
显示空白变更内容
内联
并排
Showing
9 changed file
with
3 addition
and
808 deletion
+3
-808
make/java/management/mapfile-vers
make/java/management/mapfile-vers
+0
-3
src/share/classes/com/sun/management/DiagnosticCommandArgumentInfo.java
...ses/com/sun/management/DiagnosticCommandArgumentInfo.java
+0
-151
src/share/classes/com/sun/management/DiagnosticCommandInfo.java
...are/classes/com/sun/management/DiagnosticCommandInfo.java
+0
-110
src/share/classes/com/sun/management/HotSpotDiagnosticMXBean.java
...e/classes/com/sun/management/HotSpotDiagnosticMXBean.java
+1
-110
src/share/classes/sun/management/HotSpotDiagnostic.java
src/share/classes/sun/management/HotSpotDiagnostic.java
+1
-52
src/share/native/sun/management/HotSpotDiagnostic.c
src/share/native/sun/management/HotSpotDiagnostic.c
+1
-139
test/com/sun/management/HotSpotDiagnosticMXBean/ExecuteDiagnosticCommand.java
...ent/HotSpotDiagnosticMXBean/ExecuteDiagnosticCommand.java
+0
-64
test/com/sun/management/HotSpotDiagnosticMXBean/GetDiagnosticCommandInfo.java
...ent/HotSpotDiagnosticMXBean/GetDiagnosticCommandInfo.java
+0
-117
test/com/sun/management/HotSpotDiagnosticMXBean/GetDiagnosticCommands.java
...gement/HotSpotDiagnosticMXBean/GetDiagnosticCommands.java
+0
-62
未找到文件。
make/java/management/mapfile-vers
浏览文件 @
e7a72e23
...
...
@@ -54,9 +54,6 @@ SUNWprivate_1.1 {
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;
...
...
src/share/classes/com/sun/management/DiagnosticCommandArgumentInfo.java
已删除
100644 → 0
浏览文件 @
f639ca49
/*
* 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:
* <blockquote>
* <command name> [<option>=<value>] [<argument_value>]
* </blockquote>
* Example:
* <blockquote>
* command_name option1=value1 option2=value argumentA argumentB argumentC
* </blockquote>
* 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
;
}
}
src/share/classes/com/sun/management/DiagnosticCommandInfo.java
已删除
100644 → 0
浏览文件 @
f639ca49
/*
* 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
<
DiagnosticCommandArgumentInfo
>
arguments
;
/**
* Returns the diagnostic command name
*
* @return the diagnostic command name
*/
public
String
getName
()
{
return
name
;
}
/**
* Returns the diagnostic command description
*
* @return the diagnostic command description
*/
public
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
*/
public
String
getImpact
()
{
return
impact
;
}
/**
* 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
*/
public
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
*/
public
List
<
DiagnosticCommandArgumentInfo
>
getArgumentsInfo
()
{
return
arguments
;
}
@ConstructorProperties
({
"name"
,
"description"
,
"impact"
,
"enabled"
,
"argumentsInfo"
})
public
DiagnosticCommandInfo
(
String
name
,
String
description
,
String
impact
,
boolean
enabled
,
List
<
DiagnosticCommandArgumentInfo
>
arguments
)
{
this
.
name
=
name
;
this
.
description
=
description
;
this
.
impact
=
impact
;
this
.
enabled
=
enabled
;
this
.
arguments
=
arguments
;
}
}
src/share/classes/com/sun/management/HotSpotDiagnosticMXBean.java
浏览文件 @
e7a72e23
/*
* Copyright (c) 2005, 201
1
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 201
2
, 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
...
...
@@ -31,11 +31,6 @@ import java.lang.management.PlatformManagedObject;
/**
* Diagnostic management interface for the HotSpot Virtual Machine.
*
* <p>{@linkplain #getDiagnosticCommands Diagnostic commands}
* are actions that can be invoked dynamically and
* executed in a target Java virtual machine, mainly for troubleshooting
* and diagnosis.
*
* <p>The diagnostic MBean is registered to the platform MBeanServer
* as are other platform MBeans.
*
...
...
@@ -116,108 +111,4 @@ public interface HotSpotDiagnosticMXBean extends PlatformManagedObject {
* 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
<
String
>
getDiagnosticCommands
();
/**
* Returns a {@code DiagnosticCommandInfo} object describing the
* diagnostic command of the specified name {@code command}
*
* @param command a diagnostic command name
* @return a {@code DiagnosticCommandInfo} object
* @throws java.lang.IllegalArgumentException if the {@code command}
* doesn't match any diagnostic command registered in the
* targeted Java virtual machine.
*
* @since 7u4
*/
public
DiagnosticCommandInfo
getDiagnosticCommandInfo
(
String
command
);
/**
* Returns a list of {@code DiagnosticCommandInfo} object describing
* all diagnostic commands available on the targeted Java virtual machine
*
* @return a list of {@code DiagnosticCommandInfo} objects
*
* @since 7u4
*/
public
List
<
DiagnosticCommandInfo
>
getDiagnosticCommandInfo
();
/**
* Returns a list of {@code DiagnosticCommandInfo} object describing
* all diagnostic commands specified in the {@code commands} list.
*
* @param commands {@code List} of {@code String} containing diagnostic
* command names
* @return a {@code List} of {@code DiagnosticCommandInfo} objects
*
* @throws java.lang.IllegalArgumentException if at least one
* command specified in the {@code commands } list
* doesn't match any diagnostic command registered in the
* targeted Java virtual machine.
*
* @since 7u4
*/
public
List
<
DiagnosticCommandInfo
>
getDiagnosticCommandInfo
(
List
<
String
>
commands
);
/**
* Executes the command line {@code commandLine}. The command line must
* start with a diagnostic command name, optionally followed by parameters.
* Each command has its own syntax but the generic syntax for a diagnostic
* command line is:
* <blockquote>
* <command name> [<option>=<value>] [<argument_value>]
* </blockquote>
*
* @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:
* <blockquote>
* [<option>=<value>] [<argument_value>]
* </blockquote>
*
* @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
);
}
src/share/classes/sun/management/HotSpotDiagnostic.java
浏览文件 @
e7a72e23
/*
* Copyright (c) 2005, 201
1
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 201
2
, 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 @@ package sun.management;
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 class HotSpotDiagnostic implements HotSpotDiagnosticMXBean {
}
}
public
List
<
String
>
getDiagnosticCommands
()
{
String
[]
commands
=
getDiagnosticCommands0
();
return
commands
==
null
?
Collections
.<
String
>
emptyList
()
:
Arrays
.
asList
(
commands
);
}
public
DiagnosticCommandInfo
getDiagnosticCommandInfo
(
String
command
)
{
String
[]
array
=
new
String
[]
{
command
};
return
getDiagnosticCommandInfo0
(
array
)[
0
];
}
public
List
<
DiagnosticCommandInfo
>
getDiagnosticCommandInfo
()
{
String
[]
commands
=
getDiagnosticCommands0
();
return
Arrays
.
asList
(
getDiagnosticCommandInfo0
(
commands
));
}
public
List
<
DiagnosticCommandInfo
>
getDiagnosticCommandInfo
(
List
<
String
>
commands
)
{
return
Arrays
.
asList
(
getDiagnosticCommandInfo0
(
commands
.
toArray
(
new
String
[
commands
.
size
()])));
}
public
String
execute
(
String
command
)
{
Util
.
checkControlAccess
();
return
executeDiagnosticCommand0
(
command
);
}
public
String
execute
(
String
cmd
,
String
...
arguments
)
{
if
(
cmd
==
null
)
{
throw
new
NullPointerException
(
"Missing command name"
);
}
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
cmd
);
sb
.
append
(
" "
);
for
(
String
arg
:
arguments
)
{
sb
.
append
(
arg
);
sb
.
append
(
" "
);
}
return
execute
(
sb
.
toString
());
}
public
ObjectName
getObjectName
()
{
return
Util
.
newObjectName
(
"com.sun.management:type=HotSpotDiagnostic"
);
}
private
native
String
[]
getDiagnosticCommands0
();
private
native
DiagnosticCommandInfo
[]
getDiagnosticCommandInfo0
(
String
[]
commands
)
throws
IllegalArgumentException
;
private
native
String
executeDiagnosticCommand0
(
String
command
)
throws
IllegalArgumentException
;
}
src/share/native/sun/management/HotSpotDiagnostic.c
浏览文件 @
e7a72e23
/*
* Copyright (c) 2005, 201
1
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 201
2
, 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
...
...
@@ -34,141 +34,3 @@ Java_sun_management_HotSpotDiagnostic_dumpHeap
{
jmm_interface
->
DumpHeap0
(
env
,
outputfile
,
live
);
}
JNIEXPORT
jobjectArray
JNICALL
Java_sun_management_HotSpotDiagnostic_getDiagnosticCommands0
(
JNIEnv
*
env
,
jobject
dummy
)
{
if
((
jmm_version
>
JMM_VERSION_1_2_1
)
||
(
jmm_version
==
JMM_VERSION_1_2
&&
((
jmm_version
&
0xFF
)
>=
2
)))
{
return
jmm_interface
->
GetDiagnosticCommands
(
env
);
}
JNU_ThrowByName
(
env
,
"java/lang/UnsupportedOperationException"
,
"Diagnostic commands are not supported by this VM"
);
}
jobject
getDiagnosticCommandArgumentInfoArray
(
JNIEnv
*
env
,
jstring
command
,
int
num_arg
)
{
int
i
;
jobject
obj
;
jobjectArray
result
;
dcmdArgInfo
*
dcmd_arg_info_array
;
jclass
dcmdArgInfoCls
;
jclass
arraysCls
;
jmethodID
mid
;
jobject
resultList
;
dcmd_arg_info_array
=
(
dcmdArgInfo
*
)
malloc
(
num_arg
*
sizeof
(
dcmdArgInfo
));
if
(
dcmd_arg_info_array
==
NULL
)
{
return
NULL
;
}
jmm_interface
->
GetDiagnosticCommandArgumentsInfo
(
env
,
command
,
dcmd_arg_info_array
);
dcmdArgInfoCls
=
(
*
env
)
->
FindClass
(
env
,
"com/sun/management/DiagnosticCommandArgumentInfo"
);
result
=
(
*
env
)
->
NewObjectArray
(
env
,
num_arg
,
dcmdArgInfoCls
,
NULL
);
if
(
result
==
NULL
)
{
free
(
dcmd_arg_info_array
);
return
NULL
;
}
for
(
i
=
0
;
i
<
num_arg
;
i
++
)
{
obj
=
JNU_NewObjectByName
(
env
,
"com/sun/management/DiagnosticCommandArgumentInfo"
,
"(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZZI)V"
,
(
*
env
)
->
NewStringUTF
(
env
,
dcmd_arg_info_array
[
i
].
name
),
(
*
env
)
->
NewStringUTF
(
env
,
dcmd_arg_info_array
[
i
].
description
),
(
*
env
)
->
NewStringUTF
(
env
,
dcmd_arg_info_array
[
i
].
type
),
dcmd_arg_info_array
[
i
].
default_string
==
NULL
?
NULL
:
(
*
env
)
->
NewStringUTF
(
env
,
dcmd_arg_info_array
[
i
].
default_string
),
dcmd_arg_info_array
[
i
].
mandatory
,
dcmd_arg_info_array
[
i
].
option
,
dcmd_arg_info_array
[
i
].
position
);
if
(
obj
==
NULL
)
{
free
(
dcmd_arg_info_array
);
return
NULL
;
}
(
*
env
)
->
SetObjectArrayElement
(
env
,
result
,
i
,
obj
);
}
free
(
dcmd_arg_info_array
);
arraysCls
=
(
*
env
)
->
FindClass
(
env
,
"java/util/Arrays"
);
mid
=
(
*
env
)
->
GetStaticMethodID
(
env
,
arraysCls
,
"asList"
,
"([Ljava/lang/Object;)Ljava/util/List;"
);
resultList
=
(
*
env
)
->
CallStaticObjectMethod
(
env
,
arraysCls
,
mid
,
result
);
return
resultList
;
}
/* Throws IllegalArgumentException if at least one the diagnostic command
* passed in argument is not supported by the JVM
*/
JNIEXPORT
jobjectArray
JNICALL
Java_sun_management_HotSpotDiagnostic_getDiagnosticCommandInfo0
(
JNIEnv
*
env
,
jobject
dummy
,
jobjectArray
commands
)
{
int
i
;
jclass
dcmdInfoCls
;
jobject
result
;
jobjectArray
args
;
jobject
obj
;
if
(
commands
==
NULL
)
{
JNU_ThrowNullPointerException
(
env
,
"Invalid String Array"
);
return
NULL
;
}
if
((
jmm_version
>
JMM_VERSION_1_2_1
)
||
(
jmm_version
==
JMM_VERSION_1_2
&&
((
jmm_version
&
0xFF
)
>=
2
)))
{
jsize
num_commands
=
(
*
env
)
->
GetArrayLength
(
env
,
commands
);
dcmdInfo
*
dcmd_info_array
=
(
dcmdInfo
*
)
malloc
(
num_commands
*
sizeof
(
dcmdInfo
));
if
(
dcmd_info_array
==
NULL
)
{
JNU_ThrowOutOfMemoryError
(
env
,
NULL
);
}
jmm_interface
->
GetDiagnosticCommandInfo
(
env
,
commands
,
dcmd_info_array
);
dcmdInfoCls
=
(
*
env
)
->
FindClass
(
env
,
"com/sun/management/DiagnosticCommandInfo"
);
result
=
(
*
env
)
->
NewObjectArray
(
env
,
num_commands
,
dcmdInfoCls
,
NULL
);
if
(
result
==
NULL
)
{
free
(
dcmd_info_array
);
JNU_ThrowOutOfMemoryError
(
env
,
0
);
}
for
(
i
=
0
;
i
<
num_commands
;
i
++
)
{
args
=
getDiagnosticCommandArgumentInfoArray
(
env
,
(
*
env
)
->
GetObjectArrayElement
(
env
,
commands
,
i
),
dcmd_info_array
[
i
].
num_arguments
);
if
(
args
==
NULL
)
{
free
(
dcmd_info_array
);
JNU_ThrowOutOfMemoryError
(
env
,
0
);
}
obj
=
JNU_NewObjectByName
(
env
,
"com/sun/management/DiagnosticCommandInfo"
,
"(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZLjava/util/List;)V"
,
(
*
env
)
->
NewStringUTF
(
env
,
dcmd_info_array
[
i
].
name
),
(
*
env
)
->
NewStringUTF
(
env
,
dcmd_info_array
[
i
].
description
),
(
*
env
)
->
NewStringUTF
(
env
,
dcmd_info_array
[
i
].
impact
),
dcmd_info_array
[
i
].
enabled
,
args
);
if
(
obj
==
NULL
)
{
free
(
dcmd_info_array
);
JNU_ThrowOutOfMemoryError
(
env
,
0
);
}
(
*
env
)
->
SetObjectArrayElement
(
env
,
result
,
i
,
obj
);
}
free
(
dcmd_info_array
);
return
result
;
}
JNU_ThrowByName
(
env
,
"java/lang/UnsupportedOperationException"
,
"Diagnostic commands are not supported by this VM"
);
}
/* Throws IllegalArgumentException if the diagnostic command
* passed in argument is not supported by the JVM
*/
JNIEXPORT
jstring
JNICALL
Java_sun_management_HotSpotDiagnostic_executeDiagnosticCommand0
(
JNIEnv
*
env
,
jobject
dummy
,
jstring
command
)
{
if
((
jmm_version
>
JMM_VERSION_1_2_1
)
||
(
jmm_version
==
JMM_VERSION_1_2
&&
((
jmm_version
&
0xFF
)
>=
2
)))
{
return
jmm_interface
->
ExecuteDiagnosticCommand
(
env
,
command
);
}
JNU_ThrowByName
(
env
,
"java/lang/UnsupportedOperationException"
,
"Diagnostic commands are not supported by this VM"
);
}
test/com/sun/management/HotSpotDiagnosticMXBean/ExecuteDiagnosticCommand.java
已删除
100644 → 0
浏览文件 @
f639ca49
/*
* 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.
*
* 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.
*/
/*
* @test
* @bug 7104647
* @summary Basic Test for HotSpotDiagnosticMXBean.execute()
* @author Frederic Parain
*
* @run main ExecuteDiagnosticCommand
*/
import
com.sun.management.HotSpotDiagnosticMXBean
;
import
com.sun.management.VMOption
;
import
java.lang.management.ManagementFactory
;
import
java.util.List
;
import
javax.management.MBeanServer
;
public
class
ExecuteDiagnosticCommand
{
private
static
String
HOTSPOT_DIAGNOSTIC_MXBEAN_NAME
=
"com.sun.management:type=HotSpotDiagnostic"
;
public
static
void
main
(
String
[]
args
)
throws
Exception
{
HotSpotDiagnosticMXBean
mbean
=
ManagementFactory
.
getPlatformMXBean
(
HotSpotDiagnosticMXBean
.
class
);
executeDiagnosticCommand
(
mbean
);
MBeanServer
mbs
=
ManagementFactory
.
getPlatformMBeanServer
();
mbean
=
ManagementFactory
.
newPlatformMXBeanProxy
(
mbs
,
HOTSPOT_DIAGNOSTIC_MXBEAN_NAME
,
HotSpotDiagnosticMXBean
.
class
);
executeDiagnosticCommand
(
mbean
);
}
private
static
void
executeDiagnosticCommand
(
HotSpotDiagnosticMXBean
mbean
)
{
String
s
=
mbean
.
execute
(
"help help"
);
System
.
out
.
println
(
s
);
s
=
mbean
.
execute
(
"help"
,
"help"
);
System
.
out
.
println
(
s
);
String
tab
[]
=
{
"help"
};
s
=
mbean
.
execute
(
"help"
,
tab
);
System
.
out
.
println
(
s
);
}
}
test/com/sun/management/HotSpotDiagnosticMXBean/GetDiagnosticCommandInfo.java
已删除
100644 → 0
浏览文件 @
f639ca49
/*
* 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.
*
* 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.
*/
/*
* @test
* @bug 7104647
* @summary Basic Test for HotSpotDiagnosticMXBean.getDiagnosticCommandInfo()
* @author Frederic Parain
*
* @run main GetDiagnosticCommandInfo
*/
import
com.sun.management.HotSpotDiagnosticMXBean
;
import
com.sun.management.DiagnosticCommandInfo
;
import
com.sun.management.DiagnosticCommandArgumentInfo
;
import
com.sun.management.VMOption
;
import
java.lang.management.ManagementFactory
;
import
java.util.List
;
import
javax.management.MBeanServer
;
public
class
GetDiagnosticCommandInfo
{
private
static
String
HOTSPOT_DIAGNOSTIC_MXBEAN_NAME
=
"com.sun.management:type=HotSpotDiagnostic"
;
public
static
void
main
(
String
[]
args
)
throws
Exception
{
HotSpotDiagnosticMXBean
mbean
=
ManagementFactory
.
getPlatformMXBean
(
HotSpotDiagnosticMXBean
.
class
);
checkDiagnosticCommandArguments
(
mbean
);
MBeanServer
mbs
=
ManagementFactory
.
getPlatformMBeanServer
();
mbean
=
ManagementFactory
.
newPlatformMXBeanProxy
(
mbs
,
HOTSPOT_DIAGNOSTIC_MXBEAN_NAME
,
HotSpotDiagnosticMXBean
.
class
);
checkDiagnosticCommandArguments
(
mbean
);
}
private
static
void
checkDiagnosticCommandArguments
(
HotSpotDiagnosticMXBean
mbean
)
{
// check getDiagnosticCommandInfo()
StringBuilder
sb
=
new
StringBuilder
();
List
<
DiagnosticCommandInfo
>
infoList
=
mbean
.
getDiagnosticCommandInfo
();
for
(
DiagnosticCommandInfo
info
:
infoList
)
{
printCommandInfo
(
info
,
sb
);
}
// check getDiagnosticCommandInfo(List<String>)
List
<
String
>
commands
=
mbean
.
getDiagnosticCommands
();
List
<
DiagnosticCommandInfo
>
list2
=
mbean
.
getDiagnosticCommandInfo
(
commands
);
for
(
DiagnosticCommandInfo
info
:
list2
)
{
printCommandInfo
(
info
,
sb
);
}
// check getDiagnosticCommandInfo(String)
for
(
String
cmd
:
commands
)
{
DiagnosticCommandInfo
info2
=
mbean
.
getDiagnosticCommandInfo
(
cmd
);
printCommandInfo
(
info2
,
sb
);
}
System
.
out
.
println
(
sb
.
toString
());
}
private
static
void
printCommandInfo
(
DiagnosticCommandInfo
info
,
StringBuilder
sb
)
{
sb
.
append
(
"\t"
).
append
(
info
.
getName
()).
append
(
":\n"
);
sb
.
append
(
"\t\tDescription="
).
append
(
info
.
getDescription
()).
append
(
"\n"
);
sb
.
append
(
"\t\tImpact="
).
append
(
info
.
getImpact
()).
append
(
"\n"
);
sb
.
append
(
"\t\tStatus="
);
if
(
info
.
isEnabled
())
{
sb
.
append
(
"Enabled\n"
);
}
else
{
sb
.
append
(
"Disbled\n"
);
}
sb
.
append
(
"\t\tArguments="
);
for
(
DiagnosticCommandArgumentInfo
arg
:
info
.
getArgumentsInfo
())
{
printArgumentInfo
(
arg
,
sb
);
}
}
private
static
void
printArgumentInfo
(
DiagnosticCommandArgumentInfo
info
,
StringBuilder
sb
)
{
sb
.
append
(
"\t\t\t"
).
append
(
info
.
getName
()).
append
(
":\n"
);
sb
.
append
(
"\t\t\t\tType="
).
append
(
info
.
getType
()).
append
(
"\n"
);
sb
.
append
(
"\t\t\t\tDescription="
).
append
(
info
.
getDescription
()).
append
(
"\n"
);
if
(
info
.
getDefault
()
!=
null
)
{
sb
.
append
(
"\t\t\t\tDefault="
).
append
(
info
.
getDefault
()).
append
(
"\n"
);
}
if
(
info
.
isMandatory
())
{
sb
.
append
(
"\t\t\t\tMandatory\n"
);
}
else
{
sb
.
append
(
"\t\t\t\tOptional\n"
);
}
if
(
info
.
isOption
())
{
sb
.
append
(
"\t\t\t\tIs an option\n"
);
}
else
{
sb
.
append
(
"\t\t\t\tIs an argument expected at position"
);
sb
.
append
(
info
.
getPosition
());
sb
.
append
(
"\n"
);
}
}
}
test/com/sun/management/HotSpotDiagnosticMXBean/GetDiagnosticCommands.java
已删除
100644 → 0
浏览文件 @
f639ca49
/*
* 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.
*
* 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.
*/
/*
* @test
* @bug 7104647
* @summary Basic Test for HotSpotDiagnosticMXBean.getDiagnosticCommands()
* @author Frederic Parain
*
* @run main GetDiagnosticCommands
*/
import
com.sun.management.HotSpotDiagnosticMXBean
;
import
com.sun.management.VMOption
;
import
java.lang.management.ManagementFactory
;
import
java.util.List
;
import
javax.management.MBeanServer
;
public
class
GetDiagnosticCommands
{
private
static
String
HOTSPOT_DIAGNOSTIC_MXBEAN_NAME
=
"com.sun.management:type=HotSpotDiagnostic"
;
public
static
void
main
(
String
[]
args
)
throws
Exception
{
HotSpotDiagnosticMXBean
mbean
=
ManagementFactory
.
getPlatformMXBean
(
HotSpotDiagnosticMXBean
.
class
);
checkDiagnosticCommands
(
mbean
);
MBeanServer
mbs
=
ManagementFactory
.
getPlatformMBeanServer
();
mbean
=
ManagementFactory
.
newPlatformMXBeanProxy
(
mbs
,
HOTSPOT_DIAGNOSTIC_MXBEAN_NAME
,
HotSpotDiagnosticMXBean
.
class
);
checkDiagnosticCommands
(
mbean
);
}
private
static
void
checkDiagnosticCommands
(
HotSpotDiagnosticMXBean
mbean
)
{
List
<
String
>
commands
=
mbean
.
getDiagnosticCommands
();
System
.
out
.
println
(
"Commands:"
);
for
(
String
cmd
:
commands
)
{
System
.
out
.
println
(
cmd
);
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录