Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
f06312b5
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看板
提交
f06312b5
编写于
9月 11, 2012
作者:
M
malenkov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
7193977: REGRESSION:Java 7's JavaBeans persistence ignoring the "transient" flag on properties
Reviewed-by: rupashka
上级
6f0f907e
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
197 addition
and
19 deletion
+197
-19
src/share/classes/java/beans/IndexedPropertyDescriptor.java
src/share/classes/java/beans/IndexedPropertyDescriptor.java
+10
-0
src/share/classes/java/beans/Introspector.java
src/share/classes/java/beans/Introspector.java
+18
-19
src/share/classes/java/beans/PropertyDescriptor.java
src/share/classes/java/beans/PropertyDescriptor.java
+10
-0
test/java/beans/Introspector/Test7193977.java
test/java/beans/Introspector/Test7193977.java
+159
-0
未找到文件。
src/share/classes/java/beans/IndexedPropertyDescriptor.java
浏览文件 @
f06312b5
...
@@ -495,6 +495,16 @@ public class IndexedPropertyDescriptor extends PropertyDescriptor {
...
@@ -495,6 +495,16 @@ public class IndexedPropertyDescriptor extends PropertyDescriptor {
indexedReadMethodName
=
old
.
indexedReadMethodName
;
indexedReadMethodName
=
old
.
indexedReadMethodName
;
}
}
void
updateGenericsFor
(
Class
<?>
type
)
{
super
.
updateGenericsFor
(
type
);
try
{
setIndexedPropertyType
(
findIndexedPropertyType
(
getIndexedReadMethod0
(),
getIndexedWriteMethod0
()));
}
catch
(
IntrospectionException
exception
)
{
setIndexedPropertyType
(
null
);
}
}
/**
/**
* Returns a hash code value for the object.
* Returns a hash code value for the object.
* See {@link java.lang.Object#hashCode} for a complete description.
* See {@link java.lang.Object#hashCode} for a complete description.
...
...
src/share/classes/java/beans/Introspector.java
浏览文件 @
f06312b5
...
@@ -574,26 +574,25 @@ public class Introspector {
...
@@ -574,26 +574,25 @@ public class Introspector {
// replace existing property descriptor
// replace existing property descriptor
// only if we have types to resolve
// only if we have types to resolve
// in the context of this.beanClass
// in the context of this.beanClass
try
{
Method
read
=
pd
.
getReadMethod
();
String
name
=
pd
.
getName
();
Method
write
=
pd
.
getWriteMethod
();
Method
read
=
pd
.
getReadMethod
();
boolean
cls
=
true
;
Method
write
=
pd
.
getWriteMethod
();
if
(
read
!=
null
)
cls
=
cls
&&
read
.
getGenericReturnType
()
instanceof
Class
;
boolean
cls
=
true
;
if
(
write
!=
null
)
cls
=
cls
&&
write
.
getGenericParameterTypes
()[
0
]
instanceof
Class
;
if
(
read
!=
null
)
cls
=
cls
&&
read
.
getGenericReturnType
()
instanceof
Class
;
if
(
pd
instanceof
IndexedPropertyDescriptor
)
{
if
(
write
!=
null
)
cls
=
cls
&&
write
.
getGenericParameterTypes
()[
0
]
instanceof
Class
;
IndexedPropertyDescriptor
ipd
=
(
IndexedPropertyDescriptor
)
pd
;
if
(
pd
instanceof
IndexedPropertyDescriptor
)
{
Method
readI
=
ipd
.
getIndexedReadMethod
();
IndexedPropertyDescriptor
ipd
=
(
IndexedPropertyDescriptor
)
pd
;
Method
writeI
=
ipd
.
getIndexedWriteMethod
();
Method
readI
=
ipd
.
getIndexedReadMethod
();
if
(
readI
!=
null
)
cls
=
cls
&&
readI
.
getGenericReturnType
()
instanceof
Class
;
Method
writeI
=
ipd
.
getIndexedWriteMethod
();
if
(
writeI
!=
null
)
cls
=
cls
&&
writeI
.
getGenericParameterTypes
()[
1
]
instanceof
Class
;
if
(
readI
!=
null
)
cls
=
cls
&&
readI
.
getGenericReturnType
()
instanceof
Class
;
if
(!
cls
)
{
if
(
writeI
!=
null
)
cls
=
cls
&&
writeI
.
getGenericParameterTypes
()[
1
]
instanceof
Class
;
pd
=
new
IndexedPropertyDescriptor
(
ipd
);
if
(!
cls
)
{
pd
.
updateGenericsFor
(
this
.
beanClass
);
pd
=
new
IndexedPropertyDescriptor
(
this
.
beanClass
,
name
,
read
,
write
,
readI
,
writeI
);
}
}
else
if
(!
cls
)
{
pd
=
new
PropertyDescriptor
(
this
.
beanClass
,
name
,
read
,
write
);
}
}
}
catch
(
IntrospectionException
e
)
{
}
else
if
(!
cls
)
{
pd
=
new
PropertyDescriptor
(
pd
);
pd
.
updateGenericsFor
(
this
.
beanClass
);
}
}
}
}
list
.
add
(
pd
);
list
.
add
(
pd
);
...
...
src/share/classes/java/beans/PropertyDescriptor.java
浏览文件 @
f06312b5
...
@@ -632,6 +632,16 @@ public class PropertyDescriptor extends FeatureDescriptor {
...
@@ -632,6 +632,16 @@ public class PropertyDescriptor extends FeatureDescriptor {
constrained
=
old
.
constrained
;
constrained
=
old
.
constrained
;
}
}
void
updateGenericsFor
(
Class
<?>
type
)
{
setClass0
(
type
);
try
{
setPropertyType
(
findPropertyType
(
getReadMethod0
(),
getWriteMethod0
()));
}
catch
(
IntrospectionException
exception
)
{
setPropertyType
(
null
);
}
}
/**
/**
* Returns the property type that corresponds to the read and write method.
* Returns the property type that corresponds to the read and write method.
* The type precedence is given to the readMethod.
* The type precedence is given to the readMethod.
...
...
test/java/beans/Introspector/Test7193977.java
0 → 100644
浏览文件 @
f06312b5
/*
* Copyright (c) 2012, 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 7193977
* @summary Tests that generified property descriptors do not loose additional info
* @author Sergey Malenkov
*/
import
java.awt.Image
;
import
java.beans.BeanDescriptor
;
import
java.beans.BeanInfo
;
import
java.beans.EventSetDescriptor
;
import
java.beans.IntrospectionException
;
import
java.beans.Introspector
;
import
java.beans.MethodDescriptor
;
import
java.beans.PropertyDescriptor
;
import
java.util.Arrays
;
import
java.util.List
;
public
class
Test7193977
{
private
static
final
List
<
String
>
names
=
Arrays
.
asList
(
"listType"
,
"list"
,
"value"
);
public
static
void
main
(
String
args
[])
{
for
(
String
name
:
names
)
{
test
(
Abstract
.
class
,
name
);
test
(
Concrete
.
class
,
name
);
}
}
private
static
void
test
(
Class
<?>
type
,
String
name
)
{
if
(!
Boolean
.
TRUE
.
equals
(
BeanUtils
.
getPropertyDescriptor
(
type
,
name
).
getValue
(
"transient"
)))
{
throw
new
Error
(
"property '"
+
name
+
"' is not transient"
);
}
}
public
static
final
class
Concrete
extends
Abstract
<
String
>
{
}
public
static
abstract
class
Abstract
<
T
>
{
private
List
<
T
>
list
;
public
List
<
T
>
getList
()
{
return
this
.
list
;
}
public
void
setList
(
List
<
T
>
list
)
{
this
.
list
=
list
;
}
public
T
getValue
(
int
index
)
{
return
(
0
<=
index
)
&&
(
this
.
list
!=
null
)
&&
(
index
<
this
.
list
.
size
())
?
this
.
list
.
get
(
index
)
:
null
;
}
public
void
setValue
(
int
index
,
T
value
)
{
if
((
0
<=
index
)
&&
(
this
.
list
!=
null
))
{
if
(
index
==
this
.
list
.
size
())
{
this
.
list
.
add
(
value
);
}
else
if
(
index
<
this
.
list
.
size
())
{
this
.
list
.
set
(
index
,
value
);
}
}
}
public
String
getListType
()
{
return
(
this
.
list
!=
null
)
?
this
.
list
.
getClass
().
getName
()
:
null
;
}
public
void
setListType
(
String
type
)
throws
Exception
{
this
.
list
=
(
type
!=
null
)
?
(
List
<
T
>)
Class
.
forName
(
type
).
newInstance
()
:
null
;
}
}
public
static
final
class
ConcreteBeanInfo
extends
Wrapper
{
public
ConcreteBeanInfo
()
throws
IntrospectionException
{
super
(
Concrete
.
class
);
}
}
public
static
final
class
AbstractBeanInfo
extends
Wrapper
{
public
AbstractBeanInfo
()
throws
IntrospectionException
{
super
(
Abstract
.
class
);
for
(
PropertyDescriptor
pd
:
getPropertyDescriptors
())
{
if
(
names
.
contains
(
pd
.
getName
()))
{
pd
.
setValue
(
"transient"
,
Boolean
.
TRUE
);
}
}
}
}
private
static
class
Wrapper
implements
BeanInfo
{
private
final
BeanInfo
info
;
Wrapper
(
Class
<?>
type
)
throws
IntrospectionException
{
this
.
info
=
Introspector
.
getBeanInfo
(
type
,
Introspector
.
IGNORE_IMMEDIATE_BEANINFO
);
}
public
BeanDescriptor
getBeanDescriptor
()
{
return
this
.
info
.
getBeanDescriptor
();
}
public
EventSetDescriptor
[]
getEventSetDescriptors
()
{
return
this
.
info
.
getEventSetDescriptors
();
}
public
int
getDefaultEventIndex
()
{
return
this
.
info
.
getDefaultEventIndex
();
}
public
PropertyDescriptor
[]
getPropertyDescriptors
()
{
return
this
.
info
.
getPropertyDescriptors
();
}
public
int
getDefaultPropertyIndex
()
{
return
this
.
info
.
getDefaultPropertyIndex
();
}
public
MethodDescriptor
[]
getMethodDescriptors
()
{
return
this
.
info
.
getMethodDescriptors
();
}
public
BeanInfo
[]
getAdditionalBeanInfo
()
{
return
this
.
info
.
getAdditionalBeanInfo
();
}
public
Image
getIcon
(
int
kind
)
{
return
this
.
info
.
getIcon
(
kind
);
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录