Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
310e5f02
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看板
提交
310e5f02
编写于
4月 02, 2013
作者:
S
sjiang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8007467: Better JMX type conversion
Reviewed-by: dfuchs, mchung, skoivu
上级
99e147f3
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
26 addition
and
7 deletion
+26
-7
src/share/classes/com/sun/jmx/mbeanserver/ConvertingMethod.java
...are/classes/com/sun/jmx/mbeanserver/ConvertingMethod.java
+2
-1
src/share/classes/com/sun/jmx/mbeanserver/DefaultMXBeanMappingFactory.java
.../com/sun/jmx/mbeanserver/DefaultMXBeanMappingFactory.java
+11
-4
src/share/classes/com/sun/jmx/mbeanserver/StandardMBeanIntrospector.java
...es/com/sun/jmx/mbeanserver/StandardMBeanIntrospector.java
+2
-1
src/share/classes/javax/management/openmbean/CompositeDataInvocationHandler.java
.../management/openmbean/CompositeDataInvocationHandler.java
+2
-0
src/share/classes/javax/management/openmbean/OpenMBeanAttributeInfoSupport.java
...x/management/openmbean/OpenMBeanAttributeInfoSupport.java
+9
-1
未找到文件。
src/share/classes/com/sun/jmx/mbeanserver/ConvertingMethod.java
浏览文件 @
310e5f02
...
...
@@ -33,6 +33,7 @@ import javax.management.Descriptor;
import
javax.management.MBeanException
;
import
javax.management.openmbean.OpenDataException
;
import
javax.management.openmbean.OpenType
;
import
sun.reflect.misc.MethodUtil
;
final
class
ConvertingMethod
{
static
ConvertingMethod
from
(
Method
m
)
{
...
...
@@ -189,7 +190,7 @@ final class ConvertingMethod {
"from open values: "
+
e
;
throw
new
MBeanException
(
e
,
msg
);
}
final
Object
javaReturn
=
method
.
invoke
(
obj
,
javaParams
);
final
Object
javaReturn
=
MethodUtil
.
invoke
(
method
,
obj
,
javaParams
);
try
{
return
returnMapping
.
toOpenValue
(
javaReturn
);
}
catch
(
OpenDataException
e
)
{
...
...
src/share/classes/com/sun/jmx/mbeanserver/DefaultMXBeanMappingFactory.java
浏览文件 @
310e5f02
...
...
@@ -74,6 +74,8 @@ import javax.management.openmbean.SimpleType;
import
javax.management.openmbean.TabularData
;
import
javax.management.openmbean.TabularDataSupport
;
import
javax.management.openmbean.TabularType
;
import
sun.reflect.misc.MethodUtil
;
import
sun.reflect.misc.ReflectUtil
;
/**
* <p>A converter between Java types and the limited set of classes
...
...
@@ -299,6 +301,7 @@ public class DefaultMXBeanMappingFactory extends MXBeanMappingFactory {
private
static
<
T
extends
Enum
<
T
>>
MXBeanMapping
makeEnumMapping
(
Class
<?>
enumClass
,
Class
<
T
>
fake
)
{
ReflectUtil
.
checkPackageAccess
(
enumClass
);
return
new
EnumMapping
<
T
>(
Util
.<
Class
<
T
>>
cast
(
enumClass
));
}
...
...
@@ -423,6 +426,7 @@ public class DefaultMXBeanMappingFactory extends MXBeanMappingFactory {
(
c
.
getName
().
equals
(
"com.sun.management.GcInfo"
)
&&
c
.
getClassLoader
()
==
null
);
ReflectUtil
.
checkPackageAccess
(
c
);
final
List
<
Method
>
methods
=
MBeanAnalyzer
.
eliminateCovariantMethods
(
Arrays
.
asList
(
c
.
getMethods
()));
final
SortedMap
<
String
,
Method
>
getterMap
=
newSortedMap
();
...
...
@@ -828,7 +832,7 @@ public class DefaultMXBeanMappingFactory extends MXBeanMappingFactory {
Object
[]
values
=
new
Object
[
getters
.
length
];
for
(
int
i
=
0
;
i
<
getters
.
length
;
i
++)
{
try
{
Object
got
=
getters
[
i
].
invoke
(
value
,
(
Object
[])
null
);
Object
got
=
MethodUtil
.
invoke
(
getters
[
i
],
value
,
(
Object
[])
null
);
values
[
i
]
=
getterMappings
[
i
].
toOpenValue
(
got
);
}
catch
(
Exception
e
)
{
throw
openDataException
(
"Error calling getter for "
+
...
...
@@ -1011,7 +1015,7 @@ public class DefaultMXBeanMappingFactory extends MXBeanMappingFactory {
MXBeanMapping
[]
converters
)
throws
InvalidObjectException
{
try
{
return
fromMethod
.
invoke
(
null
,
cd
);
return
MethodUtil
.
invoke
(
fromMethod
,
null
,
new
Object
[]
{
cd
}
);
}
catch
(
Exception
e
)
{
final
String
msg
=
"Failed to invoke from(CompositeData)"
;
throw
invalidObjectException
(
msg
,
e
);
...
...
@@ -1107,13 +1111,15 @@ public class DefaultMXBeanMappingFactory extends MXBeanMappingFactory {
throws
InvalidObjectException
{
Object
o
;
try
{
o
=
getTargetClass
().
newInstance
();
final
Class
<?>
targetClass
=
getTargetClass
();
ReflectUtil
.
checkPackageAccess
(
targetClass
);
o
=
targetClass
.
newInstance
();
for
(
int
i
=
0
;
i
<
itemNames
.
length
;
i
++)
{
if
(
cd
.
containsKey
(
itemNames
[
i
]))
{
Object
openItem
=
cd
.
get
(
itemNames
[
i
]);
Object
javaItem
=
converters
[
i
].
fromOpenValue
(
openItem
);
setters
[
i
].
invoke
(
o
,
javaItem
);
MethodUtil
.
invoke
(
setters
[
i
],
o
,
new
Object
[]
{
javaItem
}
);
}
}
}
catch
(
Exception
e
)
{
...
...
@@ -1363,6 +1369,7 @@ public class DefaultMXBeanMappingFactory extends MXBeanMappingFactory {
}
try
{
ReflectUtil
.
checkPackageAccess
(
max
.
constructor
.
getDeclaringClass
());
return
max
.
constructor
.
newInstance
(
params
);
}
catch
(
Exception
e
)
{
final
String
msg
=
...
...
src/share/classes/com/sun/jmx/mbeanserver/StandardMBeanIntrospector.java
浏览文件 @
310e5f02
...
...
@@ -38,6 +38,7 @@ import javax.management.MBeanOperationInfo;
import
javax.management.NotCompliantMBeanException
;
import
javax.management.NotificationBroadcaster
;
import
javax.management.NotificationBroadcasterSupport
;
import
sun.reflect.misc.MethodUtil
;
/**
* @since 1.6
...
...
@@ -108,7 +109,7 @@ class StandardMBeanIntrospector extends MBeanIntrospector<Method> {
Object
invokeM2
(
Method
m
,
Object
target
,
Object
[]
args
,
Object
cookie
)
throws
InvocationTargetException
,
IllegalAccessException
,
MBeanException
{
return
m
.
invoke
(
target
,
args
);
return
MethodUtil
.
invoke
(
m
,
target
,
args
);
}
@Override
...
...
src/share/classes/javax/management/openmbean/CompositeDataInvocationHandler.java
浏览文件 @
310e5f02
...
...
@@ -169,6 +169,8 @@ public class CompositeDataInvocationHandler implements InvocationHandler {
the only non-final methods in Object that are not
handled above are finalize and clone, and these
are not overridden in generated proxies. */
// this plain Method.invoke is called only if the declaring class
// is Object and so it's safe.
return
method
.
invoke
(
this
,
args
);
}
}
...
...
src/share/classes/javax/management/openmbean/OpenMBeanAttributeInfoSupport.java
浏览文件 @
310e5f02
...
...
@@ -45,6 +45,9 @@ import javax.management.DescriptorRead;
import
javax.management.ImmutableDescriptor
;
import
javax.management.MBeanAttributeInfo
;
import
com.sun.jmx.remote.util.EnvHelp
;
import
sun.reflect.misc.ConstructorUtil
;
import
sun.reflect.misc.MethodUtil
;
import
sun.reflect.misc.ReflectUtil
;
/**
* Describes an attribute of an open MBean.
...
...
@@ -690,6 +693,7 @@ public class OpenMBeanAttributeInfoSupport
private
static
<
T
>
T
convertFromString
(
String
s
,
OpenType
<
T
>
openType
)
{
Class
<
T
>
c
;
try
{
ReflectUtil
.
checkPackageAccess
(
openType
.
safeGetClassName
());
c
=
cast
(
Class
.
forName
(
openType
.
safeGetClassName
()));
}
catch
(
ClassNotFoundException
e
)
{
throw
new
NoClassDefFoundError
(
e
.
toString
());
// can't happen
...
...
@@ -698,6 +702,8 @@ public class OpenMBeanAttributeInfoSupport
// Look for: public static T valueOf(String)
Method
valueOf
;
try
{
// It is safe to call this plain Class.getMethod because the class "c"
// was checked before by ReflectUtil.checkPackageAccess(openType.safeGetClassName());
valueOf
=
c
.
getMethod
(
"valueOf"
,
String
.
class
);
if
(!
Modifier
.
isStatic
(
valueOf
.
getModifiers
())
||
valueOf
.
getReturnType
()
!=
c
)
...
...
@@ -707,7 +713,7 @@ public class OpenMBeanAttributeInfoSupport
}
if
(
valueOf
!=
null
)
{
try
{
return
c
.
cast
(
valueOf
.
invoke
(
null
,
s
));
return
c
.
cast
(
MethodUtil
.
invoke
(
valueOf
,
null
,
new
Object
[]
{
s
}
));
}
catch
(
Exception
e
)
{
final
String
msg
=
"Could not convert \""
+
s
+
"\" using method: "
+
valueOf
;
...
...
@@ -718,6 +724,8 @@ public class OpenMBeanAttributeInfoSupport
// Look for: public T(String)
Constructor
<
T
>
con
;
try
{
// It is safe to call this plain Class.getConstructor because the class "c"
// was checked before by ReflectUtil.checkPackageAccess(openType.safeGetClassName());
con
=
c
.
getConstructor
(
String
.
class
);
}
catch
(
NoSuchMethodException
e
)
{
con
=
null
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录