Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
d21eba9c
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看板
提交
d21eba9c
编写于
4月 29, 2009
作者:
A
asaha
浏览文件
操作
浏览文件
下载
差异文件
Merge
上级
74a49f64
f53baeba
变更
14
隐藏空白更改
内联
并排
Showing
14 changed file
with
679 addition
and
45 deletion
+679
-45
src/share/classes/java/beans/Introspector.java
src/share/classes/java/beans/Introspector.java
+22
-7
src/share/classes/java/beans/MetaData.java
src/share/classes/java/beans/MetaData.java
+45
-38
test/java/beans/Introspector/Test6660539.java
test/java/beans/Introspector/Test6660539.java
+68
-0
test/java/beans/XMLEncoder/6777487/TestBox.java
test/java/beans/XMLEncoder/6777487/TestBox.java
+52
-0
test/java/beans/XMLEncoder/6777487/TestCheckedCollection.java
.../java/beans/XMLEncoder/6777487/TestCheckedCollection.java
+48
-0
test/java/beans/XMLEncoder/6777487/TestCheckedList.java
test/java/beans/XMLEncoder/6777487/TestCheckedList.java
+48
-0
test/java/beans/XMLEncoder/6777487/TestCheckedMap.java
test/java/beans/XMLEncoder/6777487/TestCheckedMap.java
+49
-0
test/java/beans/XMLEncoder/6777487/TestCheckedRandomAccessList.java
...beans/XMLEncoder/6777487/TestCheckedRandomAccessList.java
+48
-0
test/java/beans/XMLEncoder/6777487/TestCheckedSet.java
test/java/beans/XMLEncoder/6777487/TestCheckedSet.java
+48
-0
test/java/beans/XMLEncoder/6777487/TestCheckedSortedMap.java
test/java/beans/XMLEncoder/6777487/TestCheckedSortedMap.java
+49
-0
test/java/beans/XMLEncoder/6777487/TestCheckedSortedSet.java
test/java/beans/XMLEncoder/6777487/TestCheckedSortedSet.java
+48
-0
test/java/beans/XMLEncoder/6777487/TestEncoder.java
test/java/beans/XMLEncoder/6777487/TestEncoder.java
+60
-0
test/java/beans/XMLEncoder/6777487/TestEnumMap.java
test/java/beans/XMLEncoder/6777487/TestEnumMap.java
+47
-0
test/java/beans/XMLEncoder/6777487/TestEnumSet.java
test/java/beans/XMLEncoder/6777487/TestEnumSet.java
+47
-0
未找到文件。
src/share/classes/java/beans/Introspector.java
浏览文件 @
d21eba9c
/*
/*
* Copyright 1996-200
6
Sun Microsystems, Inc. All Rights Reserved.
* Copyright 1996-200
9
Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -45,6 +45,7 @@ import java.util.EventListener;
...
@@ -45,6 +45,7 @@ import java.util.EventListener;
import
java.util.List
;
import
java.util.List
;
import
java.util.WeakHashMap
;
import
java.util.WeakHashMap
;
import
java.util.TreeMap
;
import
java.util.TreeMap
;
import
sun.awt.AppContext
;
import
sun.reflect.misc.ReflectUtil
;
import
sun.reflect.misc.ReflectUtil
;
/**
/**
...
@@ -111,8 +112,8 @@ public class Introspector {
...
@@ -111,8 +112,8 @@ public class Introspector {
// Static Caches to speed up introspection.
// Static Caches to speed up introspection.
private
static
Map
declaredMethodCache
=
private
static
Map
declaredMethodCache
=
Collections
.
synchronizedMap
(
new
WeakHashMap
());
Collections
.
synchronizedMap
(
new
WeakHashMap
());
private
static
Map
beanInfoCache
=
Collections
.
synchronizedMap
(
new
WeakHashMap
()
);
private
static
final
Object
BEANINFO_CACHE
=
new
Object
(
);
private
Class
beanClass
;
private
Class
beanClass
;
private
BeanInfo
explicitBeanInfo
;
private
BeanInfo
explicitBeanInfo
;
...
@@ -175,10 +176,18 @@ public class Introspector {
...
@@ -175,10 +176,18 @@ public class Introspector {
if
(!
ReflectUtil
.
isPackageAccessible
(
beanClass
))
{
if
(!
ReflectUtil
.
isPackageAccessible
(
beanClass
))
{
return
(
new
Introspector
(
beanClass
,
null
,
USE_ALL_BEANINFO
)).
getBeanInfo
();
return
(
new
Introspector
(
beanClass
,
null
,
USE_ALL_BEANINFO
)).
getBeanInfo
();
}
}
BeanInfo
bi
=
(
BeanInfo
)
beanInfoCache
.
get
(
beanClass
);
Map
<
Class
<?>,
BeanInfo
>
map
;
synchronized
(
BEANINFO_CACHE
)
{
map
=
(
Map
<
Class
<?>,
BeanInfo
>)
AppContext
.
getAppContext
().
get
(
BEANINFO_CACHE
);
if
(
map
==
null
)
{
map
=
Collections
.
synchronizedMap
(
new
WeakHashMap
<
Class
<?>,
BeanInfo
>());
AppContext
.
getAppContext
().
put
(
BEANINFO_CACHE
,
map
);
}
}
BeanInfo
bi
=
map
.
get
(
beanClass
);
if
(
bi
==
null
)
{
if
(
bi
==
null
)
{
bi
=
(
new
Introspector
(
beanClass
,
null
,
USE_ALL_BEANINFO
)).
getBeanInfo
();
bi
=
(
new
Introspector
(
beanClass
,
null
,
USE_ALL_BEANINFO
)).
getBeanInfo
();
beanInfoCache
.
put
(
beanClass
,
bi
);
map
.
put
(
beanClass
,
bi
);
}
}
return
bi
;
return
bi
;
}
}
...
@@ -351,7 +360,10 @@ public class Introspector {
...
@@ -351,7 +360,10 @@ public class Introspector {
*/
*/
public
static
void
flushCaches
()
{
public
static
void
flushCaches
()
{
beanInfoCache
.
clear
();
Map
map
=
(
Map
)
AppContext
.
getAppContext
().
get
(
BEANINFO_CACHE
);
if
(
map
!=
null
)
{
map
.
clear
();
}
declaredMethodCache
.
clear
();
declaredMethodCache
.
clear
();
}
}
...
@@ -374,7 +386,10 @@ public class Introspector {
...
@@ -374,7 +386,10 @@ public class Introspector {
if
(
clz
==
null
)
{
if
(
clz
==
null
)
{
throw
new
NullPointerException
();
throw
new
NullPointerException
();
}
}
beanInfoCache
.
remove
(
clz
);
Map
map
=
(
Map
)
AppContext
.
getAppContext
().
get
(
BEANINFO_CACHE
);
if
(
map
!=
null
)
{
map
.
remove
(
clz
);
}
declaredMethodCache
.
remove
(
clz
);
declaredMethodCache
.
remove
(
clz
);
}
}
...
...
src/share/classes/java/beans/MetaData.java
浏览文件 @
d21eba9c
/*
/*
* Copyright 2000-200
8
Sun Microsystems, Inc. All Rights Reserved.
* Copyright 2000-200
9
Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -333,31 +333,6 @@ abstract class java_util_Collections extends PersistenceDelegate {
...
@@ -333,31 +333,6 @@ abstract class java_util_Collections extends PersistenceDelegate {
return
(
oldC
.
size
()
==
newC
.
size
())
&&
oldC
.
containsAll
(
newC
);
return
(
oldC
.
size
()
==
newC
.
size
())
&&
oldC
.
containsAll
(
newC
);
}
}
static
Object
getPrivateField
(
final
Object
instance
,
final
String
name
)
{
return
AccessController
.
doPrivileged
(
new
PrivilegedAction
()
{
public
Object
run
()
{
Class
type
=
instance
.
getClass
();
while
(
true
)
{
try
{
Field
field
=
type
.
getDeclaredField
(
name
);
field
.
setAccessible
(
true
);
return
field
.
get
(
instance
);
}
catch
(
NoSuchFieldException
exception
)
{
type
=
type
.
getSuperclass
();
if
(
type
==
null
)
{
throw
new
IllegalStateException
(
"Could not find field "
+
name
,
exception
);
}
}
catch
(
Exception
exception
)
{
throw
new
IllegalStateException
(
"Could not get value "
+
type
.
getName
()
+
'.'
+
name
,
exception
);
}
}
}
}
);
}
static
final
class
EmptyList_PersistenceDelegate
extends
java_util_Collections
{
static
final
class
EmptyList_PersistenceDelegate
extends
java_util_Collections
{
protected
Expression
instantiate
(
Object
oldInstance
,
Encoder
out
)
{
protected
Expression
instantiate
(
Object
oldInstance
,
Encoder
out
)
{
return
new
Expression
(
oldInstance
,
Collections
.
class
,
"emptyList"
,
null
);
return
new
Expression
(
oldInstance
,
Collections
.
class
,
"emptyList"
,
null
);
...
@@ -498,7 +473,7 @@ abstract class java_util_Collections extends PersistenceDelegate {
...
@@ -498,7 +473,7 @@ abstract class java_util_Collections extends PersistenceDelegate {
static
final
class
CheckedCollection_PersistenceDelegate
extends
java_util_Collections
{
static
final
class
CheckedCollection_PersistenceDelegate
extends
java_util_Collections
{
protected
Expression
instantiate
(
Object
oldInstance
,
Encoder
out
)
{
protected
Expression
instantiate
(
Object
oldInstance
,
Encoder
out
)
{
Object
type
=
getPrivateField
(
oldInstance
,
"
type"
);
Object
type
=
MetaData
.
getPrivateFieldValue
(
oldInstance
,
"java.util.Collections$CheckedCollection.
type"
);
List
list
=
new
ArrayList
((
Collection
)
oldInstance
);
List
list
=
new
ArrayList
((
Collection
)
oldInstance
);
return
new
Expression
(
oldInstance
,
Collections
.
class
,
"checkedCollection"
,
new
Object
[]{
list
,
type
});
return
new
Expression
(
oldInstance
,
Collections
.
class
,
"checkedCollection"
,
new
Object
[]{
list
,
type
});
}
}
...
@@ -506,7 +481,7 @@ abstract class java_util_Collections extends PersistenceDelegate {
...
@@ -506,7 +481,7 @@ abstract class java_util_Collections extends PersistenceDelegate {
static
final
class
CheckedList_PersistenceDelegate
extends
java_util_Collections
{
static
final
class
CheckedList_PersistenceDelegate
extends
java_util_Collections
{
protected
Expression
instantiate
(
Object
oldInstance
,
Encoder
out
)
{
protected
Expression
instantiate
(
Object
oldInstance
,
Encoder
out
)
{
Object
type
=
getPrivateField
(
oldInstance
,
"
type"
);
Object
type
=
MetaData
.
getPrivateFieldValue
(
oldInstance
,
"java.util.Collections$CheckedCollection.
type"
);
List
list
=
new
LinkedList
((
Collection
)
oldInstance
);
List
list
=
new
LinkedList
((
Collection
)
oldInstance
);
return
new
Expression
(
oldInstance
,
Collections
.
class
,
"checkedList"
,
new
Object
[]{
list
,
type
});
return
new
Expression
(
oldInstance
,
Collections
.
class
,
"checkedList"
,
new
Object
[]{
list
,
type
});
}
}
...
@@ -514,7 +489,7 @@ abstract class java_util_Collections extends PersistenceDelegate {
...
@@ -514,7 +489,7 @@ abstract class java_util_Collections extends PersistenceDelegate {
static
final
class
CheckedRandomAccessList_PersistenceDelegate
extends
java_util_Collections
{
static
final
class
CheckedRandomAccessList_PersistenceDelegate
extends
java_util_Collections
{
protected
Expression
instantiate
(
Object
oldInstance
,
Encoder
out
)
{
protected
Expression
instantiate
(
Object
oldInstance
,
Encoder
out
)
{
Object
type
=
getPrivateField
(
oldInstance
,
"
type"
);
Object
type
=
MetaData
.
getPrivateFieldValue
(
oldInstance
,
"java.util.Collections$CheckedCollection.
type"
);
List
list
=
new
ArrayList
((
Collection
)
oldInstance
);
List
list
=
new
ArrayList
((
Collection
)
oldInstance
);
return
new
Expression
(
oldInstance
,
Collections
.
class
,
"checkedList"
,
new
Object
[]{
list
,
type
});
return
new
Expression
(
oldInstance
,
Collections
.
class
,
"checkedList"
,
new
Object
[]{
list
,
type
});
}
}
...
@@ -522,7 +497,7 @@ abstract class java_util_Collections extends PersistenceDelegate {
...
@@ -522,7 +497,7 @@ abstract class java_util_Collections extends PersistenceDelegate {
static
final
class
CheckedSet_PersistenceDelegate
extends
java_util_Collections
{
static
final
class
CheckedSet_PersistenceDelegate
extends
java_util_Collections
{
protected
Expression
instantiate
(
Object
oldInstance
,
Encoder
out
)
{
protected
Expression
instantiate
(
Object
oldInstance
,
Encoder
out
)
{
Object
type
=
getPrivateField
(
oldInstance
,
"
type"
);
Object
type
=
MetaData
.
getPrivateFieldValue
(
oldInstance
,
"java.util.Collections$CheckedCollection.
type"
);
Set
set
=
new
HashSet
((
Set
)
oldInstance
);
Set
set
=
new
HashSet
((
Set
)
oldInstance
);
return
new
Expression
(
oldInstance
,
Collections
.
class
,
"checkedSet"
,
new
Object
[]{
set
,
type
});
return
new
Expression
(
oldInstance
,
Collections
.
class
,
"checkedSet"
,
new
Object
[]{
set
,
type
});
}
}
...
@@ -530,7 +505,7 @@ abstract class java_util_Collections extends PersistenceDelegate {
...
@@ -530,7 +505,7 @@ abstract class java_util_Collections extends PersistenceDelegate {
static
final
class
CheckedSortedSet_PersistenceDelegate
extends
java_util_Collections
{
static
final
class
CheckedSortedSet_PersistenceDelegate
extends
java_util_Collections
{
protected
Expression
instantiate
(
Object
oldInstance
,
Encoder
out
)
{
protected
Expression
instantiate
(
Object
oldInstance
,
Encoder
out
)
{
Object
type
=
getPrivateField
(
oldInstance
,
"
type"
);
Object
type
=
MetaData
.
getPrivateFieldValue
(
oldInstance
,
"java.util.Collections$CheckedCollection.
type"
);
SortedSet
set
=
new
TreeSet
((
SortedSet
)
oldInstance
);
SortedSet
set
=
new
TreeSet
((
SortedSet
)
oldInstance
);
return
new
Expression
(
oldInstance
,
Collections
.
class
,
"checkedSortedSet"
,
new
Object
[]{
set
,
type
});
return
new
Expression
(
oldInstance
,
Collections
.
class
,
"checkedSortedSet"
,
new
Object
[]{
set
,
type
});
}
}
...
@@ -538,8 +513,8 @@ abstract class java_util_Collections extends PersistenceDelegate {
...
@@ -538,8 +513,8 @@ abstract class java_util_Collections extends PersistenceDelegate {
static
final
class
CheckedMap_PersistenceDelegate
extends
java_util_Collections
{
static
final
class
CheckedMap_PersistenceDelegate
extends
java_util_Collections
{
protected
Expression
instantiate
(
Object
oldInstance
,
Encoder
out
)
{
protected
Expression
instantiate
(
Object
oldInstance
,
Encoder
out
)
{
Object
keyType
=
getPrivateField
(
oldInstance
,
"
keyType"
);
Object
keyType
=
MetaData
.
getPrivateFieldValue
(
oldInstance
,
"java.util.Collections$CheckedMap.
keyType"
);
Object
valueType
=
getPrivateField
(
oldInstance
,
"
valueType"
);
Object
valueType
=
MetaData
.
getPrivateFieldValue
(
oldInstance
,
"java.util.Collections$CheckedMap.
valueType"
);
Map
map
=
new
HashMap
((
Map
)
oldInstance
);
Map
map
=
new
HashMap
((
Map
)
oldInstance
);
return
new
Expression
(
oldInstance
,
Collections
.
class
,
"checkedMap"
,
new
Object
[]{
map
,
keyType
,
valueType
});
return
new
Expression
(
oldInstance
,
Collections
.
class
,
"checkedMap"
,
new
Object
[]{
map
,
keyType
,
valueType
});
}
}
...
@@ -547,8 +522,8 @@ abstract class java_util_Collections extends PersistenceDelegate {
...
@@ -547,8 +522,8 @@ abstract class java_util_Collections extends PersistenceDelegate {
static
final
class
CheckedSortedMap_PersistenceDelegate
extends
java_util_Collections
{
static
final
class
CheckedSortedMap_PersistenceDelegate
extends
java_util_Collections
{
protected
Expression
instantiate
(
Object
oldInstance
,
Encoder
out
)
{
protected
Expression
instantiate
(
Object
oldInstance
,
Encoder
out
)
{
Object
keyType
=
getPrivateField
(
oldInstance
,
"
keyType"
);
Object
keyType
=
MetaData
.
getPrivateFieldValue
(
oldInstance
,
"java.util.Collections$CheckedMap.
keyType"
);
Object
valueType
=
getPrivateField
(
oldInstance
,
"
valueType"
);
Object
valueType
=
MetaData
.
getPrivateFieldValue
(
oldInstance
,
"java.util.Collections$CheckedMap.
valueType"
);
SortedMap
map
=
new
TreeMap
((
SortedMap
)
oldInstance
);
SortedMap
map
=
new
TreeMap
((
SortedMap
)
oldInstance
);
return
new
Expression
(
oldInstance
,
Collections
.
class
,
"checkedSortedMap"
,
new
Object
[]{
map
,
keyType
,
valueType
});
return
new
Expression
(
oldInstance
,
Collections
.
class
,
"checkedSortedMap"
,
new
Object
[]{
map
,
keyType
,
valueType
});
}
}
...
@@ -570,7 +545,7 @@ class java_util_EnumMap_PersistenceDelegate extends PersistenceDelegate {
...
@@ -570,7 +545,7 @@ class java_util_EnumMap_PersistenceDelegate extends PersistenceDelegate {
}
}
private
static
Object
getType
(
Object
instance
)
{
private
static
Object
getType
(
Object
instance
)
{
return
java_util_Collections
.
getPrivateField
(
instance
,
"
keyType"
);
return
MetaData
.
getPrivateFieldValue
(
instance
,
"java.util.EnumMap.
keyType"
);
}
}
}
}
...
@@ -589,7 +564,7 @@ class java_util_EnumSet_PersistenceDelegate extends PersistenceDelegate {
...
@@ -589,7 +564,7 @@ class java_util_EnumSet_PersistenceDelegate extends PersistenceDelegate {
}
}
private
static
Object
getType
(
Object
instance
)
{
private
static
Object
getType
(
Object
instance
)
{
return
java_util_Collections
.
getPrivateField
(
instance
,
"
elementType"
);
return
MetaData
.
getPrivateFieldValue
(
instance
,
"java.util.EnumSet.
elementType"
);
}
}
}
}
...
@@ -1280,7 +1255,7 @@ class javax_swing_Box_PersistenceDelegate extends DefaultPersistenceDelegate {
...
@@ -1280,7 +1255,7 @@ class javax_swing_Box_PersistenceDelegate extends DefaultPersistenceDelegate {
private
Integer
getAxis
(
Object
object
)
{
private
Integer
getAxis
(
Object
object
)
{
Box
box
=
(
Box
)
object
;
Box
box
=
(
Box
)
object
;
return
(
Integer
)
java_util_Collections
.
getPrivateField
(
box
.
getLayout
(),
"
axis"
);
return
(
Integer
)
MetaData
.
getPrivateFieldValue
(
box
.
getLayout
(),
"javax.swing.BoxLayout.
axis"
);
}
}
}
}
...
@@ -1363,6 +1338,7 @@ final class sun_swing_PrintColorUIResource_PersistenceDelegate extends Persisten
...
@@ -1363,6 +1338,7 @@ final class sun_swing_PrintColorUIResource_PersistenceDelegate extends Persisten
}
}
class
MetaData
{
class
MetaData
{
private
static
final
Map
<
String
,
Field
>
fields
=
Collections
.
synchronizedMap
(
new
WeakHashMap
<
String
,
Field
>());
private
static
Hashtable
internalPersistenceDelegates
=
new
Hashtable
();
private
static
Hashtable
internalPersistenceDelegates
=
new
Hashtable
();
private
static
PersistenceDelegate
nullPersistenceDelegate
=
new
NullPersistenceDelegate
();
private
static
PersistenceDelegate
nullPersistenceDelegate
=
new
NullPersistenceDelegate
();
...
@@ -1501,4 +1477,35 @@ class MetaData {
...
@@ -1501,4 +1477,35 @@ class MetaData {
return
null
;
return
null
;
}
}
}
}
static
Object
getPrivateFieldValue
(
Object
instance
,
String
name
)
{
Field
field
=
fields
.
get
(
name
);
if
(
field
==
null
)
{
int
index
=
name
.
lastIndexOf
(
'.'
);
final
String
className
=
name
.
substring
(
0
,
index
);
final
String
fieldName
=
name
.
substring
(
1
+
index
);
field
=
AccessController
.
doPrivileged
(
new
PrivilegedAction
<
Field
>()
{
public
Field
run
()
{
try
{
Field
field
=
Class
.
forName
(
className
).
getDeclaredField
(
fieldName
);
field
.
setAccessible
(
true
);
return
field
;
}
catch
(
ClassNotFoundException
exception
)
{
throw
new
IllegalStateException
(
"Could not find class"
,
exception
);
}
catch
(
NoSuchFieldException
exception
)
{
throw
new
IllegalStateException
(
"Could not find field"
,
exception
);
}
}
});
fields
.
put
(
name
,
field
);
}
try
{
return
field
.
get
(
instance
);
}
catch
(
IllegalAccessException
exception
)
{
throw
new
IllegalStateException
(
"Could not get value of the field"
,
exception
);
}
}
}
}
test/java/beans/Introspector/Test6660539.java
0 → 100644
浏览文件 @
d21eba9c
/*
* Copyright 2009 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
* 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/*
* @test
* @bug 6660539
* @summary Tests changeable BeanInfo cache in different application contexts
* @author Sergey Malenkov
*/
import
sun.awt.SunToolkit
;
import
java.beans.BeanInfo
;
import
java.beans.IntrospectionException
;
import
java.beans.Introspector
;
import
java.beans.PropertyDescriptor
;
public
class
Test6660539
implements
Runnable
{
private
static
final
String
NAME
=
"$$$"
;
public
static
void
main
(
String
[]
args
)
throws
Exception
{
for
(
PropertyDescriptor
pd
:
getPropertyDescriptors
())
{
pd
.
setDisplayName
(
NAME
);
}
ThreadGroup
group
=
new
ThreadGroup
(
NAME
);
Thread
thread
=
new
Thread
(
group
,
new
Test6660539
());
thread
.
start
();
thread
.
join
();
}
public
void
run
()
{
SunToolkit
.
createNewAppContext
();
for
(
PropertyDescriptor
pd
:
getPropertyDescriptors
())
{
if
(
pd
.
getDisplayName
().
equals
(
NAME
))
throw
new
Error
(
"shared BeanInfo cache"
);
}
}
private
static
PropertyDescriptor
[]
getPropertyDescriptors
()
{
try
{
BeanInfo
info
=
Introspector
.
getBeanInfo
(
Test6660539
.
class
);
return
info
.
getPropertyDescriptors
();
}
catch
(
IntrospectionException
exception
)
{
throw
new
Error
(
"unexpected"
,
exception
);
}
}
}
test/java/beans/XMLEncoder/6777487/TestBox.java
0 → 100644
浏览文件 @
d21eba9c
/*
* Copyright 2009 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
* 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/*
* @test
* @bug 6777487
* @summary Tests private field access for BoxLayout
* @author Sergey Malenkov
*/
import
java.awt.FlowLayout
;
import
javax.swing.Box
;
import
javax.swing.BoxLayout
;
public
final
class
TestBox
{
private
static
final
Integer
OBJECT
=
Integer
.
valueOf
(-
123
);
public
static
void
main
(
String
[]
args
)
{
TestEncoder
.
test
(
new
Box
(
BoxLayout
.
LINE_AXIS
),
new
Box
(
BoxLayout
.
PAGE_AXIS
)
{
@Override
public
FlowLayout
getLayout
()
{
return
new
FlowLayout
()
{
private
final
Object
axis
=
OBJECT
;
};
}
},
OBJECT
);
}
}
test/java/beans/XMLEncoder/6777487/TestCheckedCollection.java
0 → 100644
浏览文件 @
d21eba9c
/*
* Copyright 2009 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
* 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/*
* @test
* @bug 6777487
* @summary Tests private field access for CheckedCollection
* @author Sergey Malenkov
*/
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.List
;
public
final
class
TestCheckedCollection
{
private
static
final
Object
OBJECT
=
new
Object
();
public
static
void
main
(
String
[]
args
)
{
List
<
String
>
list
=
Collections
.
emptyList
();
TestEncoder
.
test
(
Collections
.
checkedCollection
(
list
,
String
.
class
),
new
ArrayList
()
{
private
final
Object
type
=
OBJECT
;
},
OBJECT
);
}
}
test/java/beans/XMLEncoder/6777487/TestCheckedList.java
0 → 100644
浏览文件 @
d21eba9c
/*
* Copyright 2009 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
* 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/*
* @test
* @bug 6777487
* @summary Tests private field access for CheckedList
* @author Sergey Malenkov
*/
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.List
;
public
final
class
TestCheckedList
{
private
static
final
Object
OBJECT
=
new
Object
();
public
static
void
main
(
String
[]
args
)
{
List
<
String
>
list
=
Collections
.
emptyList
();
TestEncoder
.
test
(
Collections
.
checkedList
(
list
,
String
.
class
),
new
ArrayList
()
{
private
final
Object
type
=
OBJECT
;
},
OBJECT
);
}
}
test/java/beans/XMLEncoder/6777487/TestCheckedMap.java
0 → 100644
浏览文件 @
d21eba9c
/*
* Copyright 2009 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
* 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/*
* @test
* @bug 6777487
* @summary Tests private field access for CheckedMap
* @author Sergey Malenkov
*/
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.Map
;
public
final
class
TestCheckedMap
{
private
static
final
Object
OBJECT
=
new
Object
();
public
static
void
main
(
String
[]
args
)
{
Map
<
String
,
String
>
map
=
Collections
.
emptyMap
();
TestEncoder
.
test
(
Collections
.
checkedMap
(
map
,
String
.
class
,
String
.
class
),
new
HashMap
()
{
private
final
Object
keyType
=
OBJECT
;
private
final
Object
valueType
=
OBJECT
;
},
OBJECT
);
}
}
test/java/beans/XMLEncoder/6777487/TestCheckedRandomAccessList.java
0 → 100644
浏览文件 @
d21eba9c
/*
* Copyright 2009 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
* 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/*
* @test
* @bug 6777487
* @summary Tests private field access for CheckedRandomAccessList
* @author Sergey Malenkov
*/
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.List
;
public
final
class
TestCheckedRandomAccessList
{
private
static
final
Object
OBJECT
=
new
Object
();
public
static
void
main
(
String
[]
args
)
{
List
<
String
>
list
=
new
ArrayList
<
String
>();
TestEncoder
.
test
(
Collections
.
checkedList
(
list
,
String
.
class
),
new
ArrayList
()
{
private
final
Object
type
=
OBJECT
;
},
OBJECT
);
}
}
test/java/beans/XMLEncoder/6777487/TestCheckedSet.java
0 → 100644
浏览文件 @
d21eba9c
/*
* Copyright 2009 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
* 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/*
* @test
* @bug 6777487
* @summary Tests private field access for CheckedSet
* @author Sergey Malenkov
*/
import
java.util.Collections
;
import
java.util.HashSet
;
import
java.util.Set
;
public
final
class
TestCheckedSet
{
private
static
final
Object
OBJECT
=
new
Object
();
public
static
void
main
(
String
[]
args
)
{
Set
<
String
>
set
=
Collections
.
emptySet
();
TestEncoder
.
test
(
Collections
.
checkedSet
(
set
,
String
.
class
),
new
HashSet
()
{
private
final
Object
type
=
OBJECT
;
},
OBJECT
);
}
}
test/java/beans/XMLEncoder/6777487/TestCheckedSortedMap.java
0 → 100644
浏览文件 @
d21eba9c
/*
* Copyright 2009 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
* 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/*
* @test
* @bug 6777487
* @summary Tests private field access for CheckedSortedMap
* @author Sergey Malenkov
*/
import
java.util.Collections
;
import
java.util.SortedMap
;
import
java.util.TreeMap
;
public
final
class
TestCheckedSortedMap
{
private
static
final
Object
OBJECT
=
new
Object
();
public
static
void
main
(
String
[]
args
)
{
SortedMap
<
String
,
String
>
map
=
new
TreeMap
<
String
,
String
>();
TestEncoder
.
test
(
Collections
.
checkedSortedMap
(
map
,
String
.
class
,
String
.
class
),
new
TreeMap
()
{
private
final
Object
keyType
=
OBJECT
;
private
final
Object
valueType
=
OBJECT
;
},
OBJECT
);
}
}
test/java/beans/XMLEncoder/6777487/TestCheckedSortedSet.java
0 → 100644
浏览文件 @
d21eba9c
/*
* Copyright 2009 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
* 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/*
* @test
* @bug 6777487
* @summary Tests private field access for CheckedSortedSet
* @author Sergey Malenkov
*/
import
java.util.Collections
;
import
java.util.SortedSet
;
import
java.util.TreeSet
;
public
final
class
TestCheckedSortedSet
{
private
static
final
Object
OBJECT
=
new
Object
();
public
static
void
main
(
String
[]
args
)
{
SortedSet
<
String
>
set
=
new
TreeSet
<
String
>();
TestEncoder
.
test
(
Collections
.
checkedSortedSet
(
set
,
String
.
class
),
new
TreeSet
()
{
private
final
Object
type
=
OBJECT
;
},
OBJECT
);
}
}
test/java/beans/XMLEncoder/6777487/TestEncoder.java
0 → 100644
浏览文件 @
d21eba9c
/*
* Copyright 2009 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
* 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
import
java.beans.Expression
;
import
java.beans.XMLEncoder
;
final
class
TestEncoder
extends
XMLEncoder
{
private
Expression
expression
;
private
TestEncoder
()
{
super
(
System
.
out
);
}
@Override
public
void
writeExpression
(
Expression
expression
)
{
if
(
this
.
expression
==
null
)
{
this
.
expression
=
expression
;
}
super
.
writeExpression
(
expression
);
}
public
static
void
test
(
Object
provider
,
Object
object
,
Object
value
)
{
System
.
setSecurityManager
(
new
SecurityManager
());
TestEncoder
encoder
=
new
TestEncoder
();
encoder
.
setPersistenceDelegate
(
object
.
getClass
(),
encoder
.
getPersistenceDelegate
(
provider
.
getClass
()));
encoder
.
writeObject
(
object
);
encoder
.
close
();
if
(
encoder
.
expression
!=
null
)
{
for
(
Object
argument
:
encoder
.
expression
.
getArguments
())
{
if
(
value
.
equals
(
argument
))
{
throw
new
Error
(
"Found private value!"
);
}
}
}
}
}
test/java/beans/XMLEncoder/6777487/TestEnumMap.java
0 → 100644
浏览文件 @
d21eba9c
/*
* Copyright 2009 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
* 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/*
* @test
* @bug 6777487
* @summary Tests private field access for EnumMap
* @author Sergey Malenkov
*/
import
java.util.EnumMap
;
import
java.util.HashMap
;
public
final
class
TestEnumMap
{
private
static
final
Object
OBJECT
=
new
Object
();
public
static
void
main
(
String
[]
args
)
{
TestEncoder
.
test
(
new
EnumMap
<
Point
,
String
>(
Point
.
class
),
new
HashMap
()
{
private
final
Object
keyType
=
OBJECT
;
},
OBJECT
);
}
public
enum
Point
{
X
,
Y
,
Z
}
}
test/java/beans/XMLEncoder/6777487/TestEnumSet.java
0 → 100644
浏览文件 @
d21eba9c
/*
* Copyright 2009 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
* 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/*
* @test
* @bug 6777487
* @summary Tests private field access for EnumSet
* @author Sergey Malenkov
*/
import
java.util.EnumSet
;
import
java.util.HashSet
;
public
final
class
TestEnumSet
{
private
static
final
Object
OBJECT
=
new
Object
();
public
static
void
main
(
String
[]
args
)
{
TestEncoder
.
test
(
EnumSet
.
noneOf
(
Point
.
class
),
new
HashSet
()
{
private
final
Object
elementType
=
OBJECT
;
},
OBJECT
);
}
public
enum
Point
{
X
,
Y
,
Z
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录