Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
433e57be
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看板
提交
433e57be
编写于
9月 18, 2013
作者:
S
sjiang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8023954: MBean*Info.equals: throw NPE
Reviewed-by: dfuchs, dholmes
上级
15f1a4ef
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
240 addition
and
21 deletion
+240
-21
src/share/classes/javax/management/MBeanAttributeInfo.java
src/share/classes/javax/management/MBeanAttributeInfo.java
+4
-4
src/share/classes/javax/management/MBeanConstructorInfo.java
src/share/classes/javax/management/MBeanConstructorInfo.java
+3
-3
src/share/classes/javax/management/MBeanFeatureInfo.java
src/share/classes/javax/management/MBeanFeatureInfo.java
+4
-3
src/share/classes/javax/management/MBeanNotificationInfo.java
...share/classes/javax/management/MBeanNotificationInfo.java
+4
-3
src/share/classes/javax/management/MBeanOperationInfo.java
src/share/classes/javax/management/MBeanOperationInfo.java
+4
-4
src/share/classes/javax/management/MBeanParameterInfo.java
src/share/classes/javax/management/MBeanParameterInfo.java
+5
-4
test/javax/management/MBeanInfo/MBeanInfoEqualsNPETest.java
test/javax/management/MBeanInfo/MBeanInfoEqualsNPETest.java
+216
-0
未找到文件。
src/share/classes/javax/management/MBeanAttributeInfo.java
浏览文件 @
433e57be
...
...
@@ -286,10 +286,10 @@ public class MBeanAttributeInfo extends MBeanFeatureInfo implements Cloneable {
if
(!(
o
instanceof
MBeanAttributeInfo
))
return
false
;
MBeanAttributeInfo
p
=
(
MBeanAttributeInfo
)
o
;
return
(
p
.
getName
().
equals
(
getName
())
&&
p
.
getType
().
equals
(
getType
())
&&
p
.
getDescription
().
equals
(
getDescription
())
&&
p
.
getDescriptor
().
equals
(
getDescriptor
())
&&
return
(
Objects
.
equals
(
p
.
getName
(),
getName
())
&&
Objects
.
equals
(
p
.
getType
(),
getType
())
&&
Objects
.
equals
(
p
.
getDescription
(),
getDescription
())
&&
Objects
.
equals
(
p
.
getDescriptor
(),
getDescriptor
())
&&
p
.
isReadable
()
==
isReadable
()
&&
p
.
isWritable
()
==
isWritable
()
&&
p
.
isIs
()
==
isIs
());
...
...
src/share/classes/javax/management/MBeanConstructorInfo.java
浏览文件 @
433e57be
...
...
@@ -191,10 +191,10 @@ public class MBeanConstructorInfo extends MBeanFeatureInfo implements Cloneable
if
(!(
o
instanceof
MBeanConstructorInfo
))
return
false
;
MBeanConstructorInfo
p
=
(
MBeanConstructorInfo
)
o
;
return
(
p
.
getName
().
equals
(
getName
())
&&
p
.
getDescription
().
equals
(
getDescription
())
&&
return
(
Objects
.
equals
(
p
.
getName
(),
getName
())
&&
Objects
.
equals
(
p
.
getDescription
(),
getDescription
())
&&
Arrays
.
equals
(
p
.
fastGetSignature
(),
fastGetSignature
())
&&
p
.
getDescriptor
().
equals
(
getDescriptor
()));
Objects
.
equals
(
p
.
getDescriptor
(),
getDescriptor
()));
}
/* Unlike attributes and operations, it's quite likely we'll have
...
...
src/share/classes/javax/management/MBeanFeatureInfo.java
浏览文件 @
433e57be
...
...
@@ -30,6 +30,7 @@ import java.io.ObjectInputStream;
import
java.io.ObjectOutputStream
;
import
java.io.Serializable
;
import
java.io.StreamCorruptedException
;
import
java.util.Objects
;
/**
* <p>Provides general information for an MBean descriptor object.
...
...
@@ -147,9 +148,9 @@ public class MBeanFeatureInfo implements Serializable, DescriptorRead {
if
(!(
o
instanceof
MBeanFeatureInfo
))
return
false
;
MBeanFeatureInfo
p
=
(
MBeanFeatureInfo
)
o
;
return
(
p
.
getName
().
equals
(
getName
())
&&
p
.
getDescription
().
equals
(
getDescription
())
&&
p
.
getDescriptor
().
equals
(
getDescriptor
()));
return
(
Objects
.
equals
(
p
.
getName
(),
getName
())
&&
Objects
.
equals
(
p
.
getDescription
(),
getDescription
())
&&
Objects
.
equals
(
p
.
getDescriptor
(),
getDescriptor
()));
}
public
int
hashCode
()
{
...
...
src/share/classes/javax/management/MBeanNotificationInfo.java
浏览文件 @
433e57be
...
...
@@ -26,6 +26,7 @@
package
javax.management
;
import
java.util.Arrays
;
import
java.util.Objects
;
/**
* <p>The <CODE>MBeanNotificationInfo</CODE> class is used to describe the
...
...
@@ -191,9 +192,9 @@ public class MBeanNotificationInfo extends MBeanFeatureInfo implements Cloneable
if
(!(
o
instanceof
MBeanNotificationInfo
))
return
false
;
MBeanNotificationInfo
p
=
(
MBeanNotificationInfo
)
o
;
return
(
p
.
getName
().
equals
(
getName
())
&&
p
.
getDescription
().
equals
(
getDescription
())
&&
p
.
getDescriptor
().
equals
(
getDescriptor
())
&&
return
(
Objects
.
equals
(
p
.
getName
(),
getName
())
&&
Objects
.
equals
(
p
.
getDescription
(),
getDescription
())
&&
Objects
.
equals
(
p
.
getDescriptor
(),
getDescriptor
())
&&
Arrays
.
equals
(
p
.
fastGetNotifTypes
(),
fastGetNotifTypes
()));
}
...
...
src/share/classes/javax/management/MBeanOperationInfo.java
浏览文件 @
433e57be
...
...
@@ -294,12 +294,12 @@ public class MBeanOperationInfo extends MBeanFeatureInfo implements Cloneable {
if
(!(
o
instanceof
MBeanOperationInfo
))
return
false
;
MBeanOperationInfo
p
=
(
MBeanOperationInfo
)
o
;
return
(
p
.
getName
().
equals
(
getName
())
&&
p
.
getReturnType
().
equals
(
getReturnType
())
&&
p
.
getDescription
().
equals
(
getDescription
())
&&
return
(
Objects
.
equals
(
p
.
getName
(),
getName
())
&&
Objects
.
equals
(
p
.
getReturnType
(),
getReturnType
())
&&
Objects
.
equals
(
p
.
getDescription
(),
getDescription
())
&&
p
.
getImpact
()
==
getImpact
()
&&
Arrays
.
equals
(
p
.
fastGetSignature
(),
fastGetSignature
())
&&
p
.
getDescriptor
().
equals
(
getDescriptor
()));
Objects
.
equals
(
p
.
getDescriptor
(),
getDescriptor
()));
}
/* We do not include everything in the hashcode. We assume that
...
...
src/share/classes/javax/management/MBeanParameterInfo.java
浏览文件 @
433e57be
...
...
@@ -27,6 +27,7 @@ package javax.management;
import
java.util.Objects
;
/**
* Describes an argument of an operation exposed by an MBean.
* Instances of this class are immutable. Subclasses may be mutable
...
...
@@ -137,10 +138,10 @@ public class MBeanParameterInfo extends MBeanFeatureInfo implements Cloneable {
if
(!(
o
instanceof
MBeanParameterInfo
))
return
false
;
MBeanParameterInfo
p
=
(
MBeanParameterInfo
)
o
;
return
(
p
.
getName
().
equals
(
getName
())
&&
p
.
getType
().
equals
(
getType
())
&&
p
.
getDescription
().
equals
(
getDescription
())
&&
p
.
getDescriptor
().
equals
(
getDescriptor
()));
return
(
Objects
.
equals
(
p
.
getName
(),
getName
())
&&
Objects
.
equals
(
p
.
getType
(),
getType
())
&&
Objects
.
equals
(
p
.
getDescription
(),
getDescription
())
&&
Objects
.
equals
(
p
.
getDescriptor
(),
getDescriptor
()));
}
public
int
hashCode
()
{
...
...
test/javax/management/MBeanInfo/MBeanInfoEqualsNPETest.java
0 → 100644
浏览文件 @
433e57be
/*
* 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.
*
* 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.
*/
import
javax.management.MBeanAttributeInfo
;
import
javax.management.MBeanConstructorInfo
;
import
javax.management.MBeanFeatureInfo
;
import
javax.management.MBeanInfo
;
import
javax.management.MBeanNotificationInfo
;
import
javax.management.MBeanOperationInfo
;
import
javax.management.MBeanParameterInfo
;
import
javax.management.modelmbean.DescriptorSupport
;
import
javax.management.openmbean.SimpleType
;
/*
* @test
* @bug 8023954
* @summary Test that MBean*Info.equals do not throw NPE
* @author Shanliang JIANG
* @run clean MBeanInfoEqualsNPETest
* @run build MBeanInfoEqualsNPETest
* @run main MBeanInfoEqualsNPETest
*/
public
class
MBeanInfoEqualsNPETest
{
private
static
int
failed
=
0
;
public
static
void
main
(
String
[]
args
)
throws
Exception
{
System
.
out
.
println
(
"---MBeanInfoEqualsNPETest-main ..."
);
// ----
System
.
out
.
println
(
"\n---Testing on MBeanAttributeInfo..."
);
MBeanAttributeInfo
mbeanAttributeInfo0
=
new
MBeanAttributeInfo
(
"name"
,
SimpleType
.
INTEGER
.
getClassName
(),
"description"
,
true
,
true
,
false
);
MBeanAttributeInfo
mbeanAttributeInfo
=
new
MBeanAttributeInfo
(
null
,
SimpleType
.
INTEGER
.
getClassName
(),
"description"
,
true
,
true
,
false
);
test
(
mbeanAttributeInfo0
,
mbeanAttributeInfo
,
"class name"
);
mbeanAttributeInfo
=
new
MBeanAttributeInfo
(
"name"
,
null
,
"description"
,
true
,
true
,
false
);
test
(
mbeanAttributeInfo0
,
mbeanAttributeInfo
,
"type"
);
mbeanAttributeInfo
=
new
MBeanAttributeInfo
(
"name"
,
SimpleType
.
INTEGER
.
getClassName
(),
null
,
true
,
true
,
false
);
test
(
mbeanAttributeInfo0
,
mbeanAttributeInfo
,
"description"
);
// ----
System
.
out
.
println
(
"\n---Testing on MBeanConstructorInfo..."
);
MBeanConstructorInfo
mbeanConstructorInfo0
=
new
MBeanConstructorInfo
(
""
,
""
,
new
MBeanParameterInfo
[]{},
new
DescriptorSupport
());
MBeanConstructorInfo
mbeanConstructorInfo
=
new
MBeanConstructorInfo
(
null
,
""
,
new
MBeanParameterInfo
[]{},
new
DescriptorSupport
());
test
(
mbeanConstructorInfo0
,
mbeanConstructorInfo
,
"name"
);
mbeanConstructorInfo
=
new
MBeanConstructorInfo
(
""
,
null
,
new
MBeanParameterInfo
[]{},
new
DescriptorSupport
());
test
(
mbeanConstructorInfo0
,
mbeanConstructorInfo
,
"description"
);
mbeanConstructorInfo
=
new
MBeanConstructorInfo
(
""
,
""
,
null
,
new
DescriptorSupport
());
test
(
mbeanConstructorInfo0
,
mbeanConstructorInfo
,
"MBeanParameterInfo"
);
mbeanConstructorInfo
=
new
MBeanConstructorInfo
(
""
,
""
,
new
MBeanParameterInfo
[]{},
null
);
test
(
mbeanConstructorInfo0
,
mbeanConstructorInfo
,
"descriptor"
);
// ----
System
.
out
.
println
(
"\n---Testing on MBeanOperationInfo..."
);
MBeanOperationInfo
mbeanOperationInfo0
=
new
MBeanOperationInfo
(
"name"
,
"description"
,
new
MBeanParameterInfo
[]{},
"type"
,
MBeanOperationInfo
.
UNKNOWN
,
new
DescriptorSupport
());
MBeanOperationInfo
mbeanOperationInfo
=
new
MBeanOperationInfo
(
null
,
"description"
,
new
MBeanParameterInfo
[]{},
"type"
,
MBeanOperationInfo
.
UNKNOWN
,
new
DescriptorSupport
());
test
(
mbeanOperationInfo0
,
mbeanOperationInfo
,
"name"
);
mbeanOperationInfo
=
new
MBeanOperationInfo
(
"name"
,
null
,
new
MBeanParameterInfo
[]{},
"type"
,
MBeanOperationInfo
.
UNKNOWN
,
new
DescriptorSupport
());
test
(
mbeanOperationInfo0
,
mbeanOperationInfo
,
"description"
);
mbeanOperationInfo
=
new
MBeanOperationInfo
(
"name"
,
"description"
,
null
,
"type"
,
1
,
new
DescriptorSupport
());
test
(
mbeanOperationInfo0
,
mbeanOperationInfo
,
"MBeanParameterInfo"
);
mbeanOperationInfo
=
new
MBeanOperationInfo
(
"name"
,
"description"
,
new
MBeanParameterInfo
[]{},
null
,
MBeanOperationInfo
.
UNKNOWN
,
new
DescriptorSupport
());
test
(
mbeanOperationInfo0
,
mbeanOperationInfo
,
"type"
);
mbeanOperationInfo
=
new
MBeanOperationInfo
(
"name"
,
"description"
,
new
MBeanParameterInfo
[]{},
null
,
MBeanOperationInfo
.
UNKNOWN
,
null
);
test
(
mbeanOperationInfo0
,
mbeanOperationInfo
,
"Descriptor"
);
// ----
System
.
out
.
println
(
"\n---Testing on MBeanParameterInfo..."
);
MBeanParameterInfo
mbeanParameterInfo0
=
new
MBeanParameterInfo
(
"name"
,
"type"
,
"description"
,
new
DescriptorSupport
());
MBeanParameterInfo
mbeanParameterInfo
=
new
MBeanParameterInfo
(
null
,
"type"
,
"description"
,
new
DescriptorSupport
());
test
(
mbeanParameterInfo0
,
mbeanParameterInfo
,
"name"
);
mbeanParameterInfo
=
new
MBeanParameterInfo
(
"name"
,
null
,
"description"
,
new
DescriptorSupport
());
test
(
mbeanParameterInfo0
,
mbeanParameterInfo
,
"type"
);
mbeanParameterInfo
=
new
MBeanParameterInfo
(
"name"
,
"type"
,
null
,
new
DescriptorSupport
());
test
(
mbeanParameterInfo0
,
mbeanParameterInfo
,
"description"
);
mbeanParameterInfo
=
new
MBeanParameterInfo
(
"name"
,
"type"
,
"description"
,
null
);
test
(
mbeanParameterInfo0
,
mbeanParameterInfo
,
"Descriptor"
);
// ----
System
.
out
.
println
(
"\n---Testing on MBeanFeatureInfo ..."
);
MBeanFeatureInfo
mbeanFeatureInfo0
=
new
MBeanFeatureInfo
(
"name"
,
"description"
,
new
DescriptorSupport
());
MBeanFeatureInfo
mbeanFeatureInfo
=
new
MBeanFeatureInfo
(
null
,
"description"
,
new
DescriptorSupport
());
test
(
mbeanFeatureInfo0
,
mbeanFeatureInfo
,
"name"
);
mbeanFeatureInfo
=
new
MBeanFeatureInfo
(
"name"
,
null
,
new
DescriptorSupport
());
test
(
mbeanParameterInfo0
,
mbeanParameterInfo
,
"description"
);
mbeanFeatureInfo
=
new
MBeanFeatureInfo
(
"name"
,
"description"
,
null
);
test
(
mbeanParameterInfo0
,
mbeanParameterInfo
,
"Descriptor"
);
// ----
System
.
out
.
println
(
"\n---Testing on MBeanInfo..."
);
String
className
=
"toto"
;
String
description
=
"titi"
;
MBeanAttributeInfo
[]
attrInfos
=
new
MBeanAttributeInfo
[]{};
MBeanConstructorInfo
[]
constrInfos
=
new
MBeanConstructorInfo
[]{};
MBeanOperationInfo
[]
operaInfos
=
new
MBeanOperationInfo
[]{};
MBeanNotificationInfo
[]
notifInfos
=
new
MBeanNotificationInfo
[]{};
MBeanInfo
minfo0
=
new
MBeanInfo
(
"toto"
,
description
,
attrInfos
,
constrInfos
,
operaInfos
,
notifInfos
);
MBeanInfo
minfo
=
new
MBeanInfo
(
null
,
description
,
attrInfos
,
constrInfos
,
operaInfos
,
notifInfos
);
test
(
minfo0
,
minfo
,
"class name"
);
minfo
=
new
MBeanInfo
(
className
,
null
,
attrInfos
,
constrInfos
,
operaInfos
,
notifInfos
);
test
(
minfo0
,
minfo
,
"description"
);
minfo
=
new
MBeanInfo
(
className
,
description
,
null
,
constrInfos
,
operaInfos
,
notifInfos
);
test
(
minfo0
,
minfo
,
"attrInfos"
);
minfo
=
new
MBeanInfo
(
className
,
description
,
attrInfos
,
null
,
operaInfos
,
notifInfos
);
test
(
minfo0
,
minfo
,
"constrInfos"
);
minfo
=
new
MBeanInfo
(
className
,
description
,
attrInfos
,
constrInfos
,
null
,
notifInfos
);
test
(
minfo0
,
minfo
,
"operaInfos"
);
minfo
=
new
MBeanInfo
(
className
,
description
,
attrInfos
,
constrInfos
,
operaInfos
,
null
);
test
(
minfo0
,
minfo
,
"notifInfos"
);
if
(
failed
>
0
)
{
throw
new
RuntimeException
(
"Test failed: "
+
failed
);
}
else
{
System
.
out
.
println
(
"---Test: PASSED"
);
}
}
private
static
void
test
(
Object
obj1
,
Object
obj2
,
String
param
)
{
try
{
obj1
.
equals
(
obj2
);
System
.
out
.
println
(
"OK-1: "
+
obj1
.
getClass
().
getSimpleName
()+
".equals worked with a null paramer: "
+
param
);
}
catch
(
NullPointerException
npe
)
{
System
.
out
.
println
(
"--->KO-1!!! "
+
obj1
.
getClass
().
getSimpleName
()+
".equals got NPE with a null paramer: "
+
param
);
npe
.
printStackTrace
();
failed
++;
}
try
{
obj2
.
equals
(
obj1
);
System
.
out
.
println
(
"OK-2: "
+
obj2
.
getClass
().
getSimpleName
()+
".equals worked with a null paramer: "
+
param
);
}
catch
(
NullPointerException
npe
)
{
System
.
out
.
println
(
"--->KO-2!!! "
+
obj2
.
getClass
().
getSimpleName
()+
".equals got NPE with a null paramer: "
+
param
);
npe
.
printStackTrace
();
failed
++;
}
try
{
obj1
.
equals
(
null
);
obj2
.
equals
(
null
);
System
.
out
.
println
(
"OK-3: "
+
obj1
.
getClass
().
getSimpleName
()+
".equals worked with a null field."
);
}
catch
(
NullPointerException
npe
)
{
System
.
out
.
println
(
"--->KO-3!!! "
+
obj1
.
getClass
().
getSimpleName
()+
".equals got NPE with a null field."
);
npe
.
printStackTrace
();
failed
++;
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录