Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
ffab6390
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看板
提交
ffab6390
编写于
5月 02, 2011
作者:
D
darcy
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
7041136: Use Objects.equals in JDK platform classes
Reviewed-by: alanb, mduigou
上级
0924c27d
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
13 addition
and
25 deletion
+13
-25
src/share/classes/java/beans/DefaultPersistenceDelegate.java
src/share/classes/java/beans/DefaultPersistenceDelegate.java
+3
-6
src/share/classes/java/beans/MetaData.java
src/share/classes/java/beans/MetaData.java
+8
-10
src/share/classes/java/net/HttpCookie.java
src/share/classes/java/net/HttpCookie.java
+2
-9
未找到文件。
src/share/classes/java/beans/DefaultPersistenceDelegate.java
浏览文件 @
ffab6390
...
...
@@ -26,6 +26,7 @@ package java.beans;
import
java.util.*
;
import
java.lang.reflect.*
;
import
java.util.Objects
;
import
sun.reflect.misc.*
;
...
...
@@ -181,10 +182,6 @@ public class DefaultPersistenceDelegate extends PersistenceDelegate {
return
method
;
}
private
static
boolean
equals
(
Object
o1
,
Object
o2
)
{
return
(
o1
==
null
)
?
(
o2
==
null
)
:
o1
.
equals
(
o2
);
}
private
void
doProperty
(
Class
type
,
PropertyDescriptor
pd
,
Object
oldInstance
,
Object
newInstance
,
Encoder
out
)
throws
Exception
{
Method
getter
=
pd
.
getReadMethod
();
Method
setter
=
pd
.
getWriteMethod
();
...
...
@@ -195,7 +192,7 @@ public class DefaultPersistenceDelegate extends PersistenceDelegate {
Object
oldValue
=
oldGetExp
.
getValue
();
Object
newValue
=
newGetExp
.
getValue
();
out
.
writeExpression
(
oldGetExp
);
if
(!
equals
(
newValue
,
out
.
get
(
oldValue
)))
{
if
(!
Objects
.
equals
(
newValue
,
out
.
get
(
oldValue
)))
{
// Search for a static constant with this value;
Object
e
=
(
Object
[])
pd
.
getValue
(
"enumerationValues"
);
if
(
e
instanceof
Object
[]
&&
Array
.
getLength
(
e
)
%
3
==
0
)
{
...
...
@@ -233,7 +230,7 @@ public class DefaultPersistenceDelegate extends PersistenceDelegate {
Object
oldValue
=
oldGetExp
.
getValue
();
Object
newValue
=
newGetExp
.
getValue
();
out
.
writeExpression
(
oldGetExp
);
if
(!
equals
(
newValue
,
out
.
get
(
oldValue
)))
{
if
(!
Objects
.
equals
(
newValue
,
out
.
get
(
oldValue
)))
{
out
.
writeStatement
(
new
Statement
(
field
,
"set"
,
new
Object
[]
{
oldInstance
,
oldValue
}));
}
}
...
...
src/share/classes/java/beans/MetaData.java
浏览文件 @
ffab6390
...
...
@@ -56,6 +56,8 @@ import javax.swing.plaf.ColorUIResource;
import
sun.swing.PrintColorUIResource
;
import
java.util.Objects
;
/*
* Like the <code>Intropector</code>, the <code>MetaData</code> class
* contains <em>meta</em> objects that describe the way
...
...
@@ -134,7 +136,7 @@ class ArrayPersistenceDelegate extends PersistenceDelegate {
Object
oldValue
=
oldGetExp
.
getValue
();
Object
newValue
=
newGetExp
.
getValue
();
out
.
writeExpression
(
oldGetExp
);
if
(!
MetaData
.
equals
(
newValue
,
out
.
get
(
oldValue
)))
{
if
(!
Objects
.
equals
(
newValue
,
out
.
get
(
oldValue
)))
{
// System.out.println("Not equal: " + newGetExp + " != " + actualGetExp);
// invokeStatement(Array.class, "set", new Object[]{oldInstance, index, oldValue}, out);
DefaultPersistenceDelegate
.
invokeStatement
(
oldInstance
,
"set"
,
new
Object
[]{
index
,
oldValue
},
out
);
...
...
@@ -635,7 +637,7 @@ class java_util_List_PersistenceDelegate extends DefaultPersistenceDelegate {
Object
oldValue
=
oldGetExp
.
getValue
();
Object
newValue
=
newGetExp
.
getValue
();
out
.
writeExpression
(
oldGetExp
);
if
(!
MetaData
.
equals
(
newValue
,
out
.
get
(
oldValue
)))
{
if
(!
Objects
.
equals
(
newValue
,
out
.
get
(
oldValue
)))
{
invokeStatement
(
oldInstance
,
"set"
,
new
Object
[]{
index
,
oldValue
},
out
);
}
}
...
...
@@ -675,7 +677,7 @@ class java_util_Map_PersistenceDelegate extends DefaultPersistenceDelegate {
Object
oldValue
=
oldGetExp
.
getValue
();
Object
newValue
=
newGetExp
.
getValue
();
out
.
writeExpression
(
oldGetExp
);
if
(!
MetaData
.
equals
(
newValue
,
out
.
get
(
oldValue
)))
{
if
(!
Objects
.
equals
(
newValue
,
out
.
get
(
oldValue
)))
{
invokeStatement
(
oldInstance
,
"put"
,
new
Object
[]{
oldKey
,
oldValue
},
out
);
}
else
if
((
newValue
==
null
)
&&
!
newMap
.
containsKey
(
oldKey
))
{
// put oldValue(=null?) if oldKey is absent in newMap
...
...
@@ -899,17 +901,17 @@ class java_awt_Component_PersistenceDelegate extends DefaultPersistenceDelegate
if
(!(
oldInstance
instanceof
java
.
awt
.
Window
))
{
Object
oldBackground
=
c
.
isBackgroundSet
()
?
c
.
getBackground
()
:
null
;
Object
newBackground
=
c2
.
isBackgroundSet
()
?
c2
.
getBackground
()
:
null
;
if
(!
MetaData
.
equals
(
oldBackground
,
newBackground
))
{
if
(!
Objects
.
equals
(
oldBackground
,
newBackground
))
{
invokeStatement
(
oldInstance
,
"setBackground"
,
new
Object
[]
{
oldBackground
},
out
);
}
Object
oldForeground
=
c
.
isForegroundSet
()
?
c
.
getForeground
()
:
null
;
Object
newForeground
=
c2
.
isForegroundSet
()
?
c2
.
getForeground
()
:
null
;
if
(!
MetaData
.
equals
(
oldForeground
,
newForeground
))
{
if
(!
Objects
.
equals
(
oldForeground
,
newForeground
))
{
invokeStatement
(
oldInstance
,
"setForeground"
,
new
Object
[]
{
oldForeground
},
out
);
}
Object
oldFont
=
c
.
isFontSet
()
?
c
.
getFont
()
:
null
;
Object
newFont
=
c2
.
isFontSet
()
?
c2
.
getFont
()
:
null
;
if
(!
MetaData
.
equals
(
oldFont
,
newFont
))
{
if
(!
Objects
.
equals
(
oldFont
,
newFont
))
{
invokeStatement
(
oldInstance
,
"setFont"
,
new
Object
[]
{
oldFont
},
out
);
}
}
...
...
@@ -1306,10 +1308,6 @@ class MetaData {
internalPersistenceDelegates
.
put
(
"java.util.RegularEnumSet"
,
new
java_util_EnumSet_PersistenceDelegate
());
}
/*pp*/
static
boolean
equals
(
Object
o1
,
Object
o2
)
{
return
(
o1
==
null
)
?
(
o2
==
null
)
:
o1
.
equals
(
o2
);
}
public
synchronized
static
PersistenceDelegate
getPersistenceDelegate
(
Class
type
)
{
if
(
type
==
null
)
{
return
nullPersistenceDelegate
;
...
...
src/share/classes/java/net/HttpCookie.java
浏览文件 @
ffab6390
...
...
@@ -34,6 +34,7 @@ import java.util.Date;
import
java.lang.NullPointerException
;
// for javadoc
import
java.util.Locale
;
import
java.util.Objects
;
/**
* An HttpCookie object represents an http cookie, which carries state
...
...
@@ -817,7 +818,7 @@ public final class HttpCookie implements Cloneable {
// 3. and have same path (case-sensitive).
return
equalsIgnoreCase
(
getName
(),
other
.
getName
())
&&
equalsIgnoreCase
(
getDomain
(),
other
.
getDomain
())
&&
equals
(
getPath
(),
other
.
getPath
());
Objects
.
equals
(
getPath
(),
other
.
getPath
());
}
...
...
@@ -1162,14 +1163,6 @@ public final class HttpCookie implements Cloneable {
return
false
;
}
private
static
boolean
equals
(
String
s
,
String
t
)
{
if
(
s
==
t
)
return
true
;
if
((
s
!=
null
)
&&
(
t
!=
null
))
{
return
s
.
equals
(
t
);
}
return
false
;
}
private
static
boolean
startsWithIgnoreCase
(
String
s
,
String
start
)
{
if
(
s
==
null
||
start
==
null
)
return
false
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录