Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
be479f20
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看板
提交
be479f20
编写于
7月 29, 2008
作者:
W
wetmore
浏览文件
操作
浏览文件
下载
差异文件
Merge
上级
16f02abb
39a42d0f
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
51 addition
and
22 deletion
+51
-22
src/share/classes/com/sun/jmx/mbeanserver/Util.java
src/share/classes/com/sun/jmx/mbeanserver/Util.java
+29
-0
src/share/classes/javax/management/ImmutableDescriptor.java
src/share/classes/javax/management/ImmutableDescriptor.java
+7
-18
src/share/classes/javax/management/modelmbean/DescriptorSupport.java
...lasses/javax/management/modelmbean/DescriptorSupport.java
+15
-4
未找到文件。
src/share/classes/com/sun/jmx/mbeanserver/Util.java
浏览文件 @
be479f20
...
...
@@ -26,6 +26,7 @@
package
com.sun.jmx.mbeanserver
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Collection
;
import
java.util.Collections
;
import
java.util.Comparator
;
...
...
@@ -113,4 +114,32 @@ public class Util {
public
static
<
T
>
T
cast
(
Object
x
)
{
return
(
T
)
x
;
}
/**
* Computes a descriptor hashcode from its names and values.
* @param names the sorted array of descriptor names.
* @param values the array of descriptor values.
* @return a hash code value, as described in {@link #hashCode(Descriptor)}
*/
public
static
int
hashCode
(
String
[]
names
,
Object
[]
values
)
{
int
hash
=
0
;
for
(
int
i
=
0
;
i
<
names
.
length
;
i
++)
{
Object
v
=
values
[
i
];
int
h
;
if
(
v
==
null
)
{
h
=
0
;
}
else
if
(
v
instanceof
Object
[])
{
h
=
Arrays
.
deepHashCode
((
Object
[])
v
);
}
else
if
(
v
.
getClass
().
isArray
())
{
h
=
Arrays
.
deepHashCode
(
new
Object
[]{
v
})
-
31
;
// hashcode of a list containing just v is
// v.hashCode() + 31, see List.hashCode()
}
else
{
h
=
v
.
hashCode
();
}
hash
+=
names
[
i
].
toLowerCase
().
hashCode
()
^
h
;
}
return
hash
;
}
}
src/share/classes/javax/management/ImmutableDescriptor.java
浏览文件 @
be479f20
/*
* Copyright 2004-200
6
Sun Microsystems, Inc. All Rights Reserved.
* Copyright 2004-200
8
Sun Microsystems, Inc. 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,6 +25,7 @@
package
javax.management
;
import
com.sun.jmx.mbeanserver.Util
;
import
java.io.InvalidObjectException
;
import
java.lang.reflect.Array
;
import
java.util.Arrays
;
...
...
@@ -362,6 +363,7 @@ public class ImmutableDescriptor implements Descriptor {
*/
// Note: this Javadoc is copied from javax.management.Descriptor
// due to 6369229.
@Override
public
boolean
equals
(
Object
o
)
{
if
(
o
==
this
)
return
true
;
...
...
@@ -410,29 +412,15 @@ public class ImmutableDescriptor implements Descriptor {
*/
// Note: this Javadoc is copied from javax.management.Descriptor
// due to 6369229.
@Override
public
int
hashCode
()
{
if
(
hashCode
==
-
1
)
{
int
hash
=
0
;
for
(
int
i
=
0
;
i
<
names
.
length
;
i
++)
{
Object
v
=
values
[
i
];
int
h
;
if
(
v
==
null
)
h
=
0
;
else
if
(
v
instanceof
Object
[])
h
=
Arrays
.
deepHashCode
((
Object
[])
v
);
else
if
(
v
.
getClass
().
isArray
())
{
h
=
Arrays
.
deepHashCode
(
new
Object
[]
{
v
})
-
31
;
// hashcode of a list containing just v is
// v.hashCode() + 31, see List.hashCode()
}
else
h
=
v
.
hashCode
();
hash
+=
names
[
i
].
toLowerCase
().
hashCode
()
^
h
;
}
hashCode
=
hash
;
hashCode
=
Util
.
hashCode
(
names
,
values
);
}
return
hashCode
;
}
@Override
public
String
toString
()
{
StringBuilder
sb
=
new
StringBuilder
(
"{"
);
for
(
int
i
=
0
;
i
<
names
.
length
;
i
++)
{
...
...
@@ -479,6 +467,7 @@ public class ImmutableDescriptor implements Descriptor {
* If the descriptor construction fails for any reason, this exception will
* be thrown.
*/
@Override
public
Descriptor
clone
()
{
return
this
;
}
...
...
src/share/classes/javax/management/modelmbean/DescriptorSupport.java
浏览文件 @
be479f20
...
...
@@ -33,6 +33,7 @@ package javax.management.modelmbean;
import
static
com
.
sun
.
jmx
.
defaults
.
JmxProperties
.
MODELMBEAN_LOGGER
;
import
static
com
.
sun
.
jmx
.
mbeanserver
.
Util
.
cast
;
import
com.sun.jmx.mbeanserver.GetPropertyAction
;
import
com.sun.jmx.mbeanserver.Util
;
import
java.io.IOException
;
import
java.io.ObjectInputStream
;
...
...
@@ -774,6 +775,7 @@ public class DescriptorSupport
* fails for any reason, this exception will be thrown.
*/
@Override
public
synchronized
Object
clone
()
throws
RuntimeOperationsException
{
if
(
MODELMBEAN_LOGGER
.
isLoggable
(
Level
.
FINEST
))
{
MODELMBEAN_LOGGER
.
logp
(
Level
.
FINEST
,
...
...
@@ -814,13 +816,16 @@ public class DescriptorSupport
* otherwise.
*
*/
// XXXX TODO: This is not very efficient!
// Note: this Javadoc is copied from javax.management.Descriptor
// due to 6369229.
@Override
public
synchronized
boolean
equals
(
Object
o
)
{
if
(
o
==
this
)
return
true
;
if
(!
(
o
instanceof
Descriptor
))
return
false
;
if
(
o
instanceof
ImmutableDescriptor
)
return
o
.
equals
(
this
);
return
new
ImmutableDescriptor
(
descriptorMap
).
equals
(
o
);
}
...
...
@@ -844,11 +849,16 @@ public class DescriptorSupport
* @return A hash code value for this object.
*
*/
// XXXX TODO: This is not very efficient!
// Note: this Javadoc is copied from javax.management.Descriptor
// due to 6369229.
@Override
public
synchronized
int
hashCode
()
{
return
new
ImmutableDescriptor
(
descriptorMap
).
hashCode
();
final
int
size
=
descriptorMap
.
size
();
// descriptorMap is sorted with a comparator that ignores cases.
//
return
Util
.
hashCode
(
descriptorMap
.
keySet
().
toArray
(
new
String
[
size
]),
descriptorMap
.
values
().
toArray
(
new
Object
[
size
]));
}
/**
...
...
@@ -1278,6 +1288,7 @@ public class DescriptorSupport
* field Names or field Values. If the descriptor string fails
* for any reason, this exception will be thrown.
*/
@Override
public
synchronized
String
toString
()
{
if
(
MODELMBEAN_LOGGER
.
isLoggable
(
Level
.
FINEST
))
{
MODELMBEAN_LOGGER
.
logp
(
Level
.
FINEST
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录