Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
9a9ef684
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看板
提交
9a9ef684
编写于
9月 27, 2010
作者:
M
malenkov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
6976577: JCK7 api/java_beans/EventSetDescriptor/descriptions.html#Ctor1 fails since jdk7 b102
Reviewed-by: peterz
上级
15fddd82
变更
7
显示空白变更内容
内联
并排
Showing
7 changed file
with
251 addition
and
30 deletion
+251
-30
src/share/classes/java/beans/EventSetDescriptor.java
src/share/classes/java/beans/EventSetDescriptor.java
+3
-2
src/share/classes/java/beans/IndexedPropertyDescriptor.java
src/share/classes/java/beans/IndexedPropertyDescriptor.java
+7
-3
src/share/classes/java/beans/Introspector.java
src/share/classes/java/beans/Introspector.java
+81
-19
src/share/classes/java/beans/MethodDescriptor.java
src/share/classes/java/beans/MethodDescriptor.java
+2
-2
src/share/classes/java/beans/PropertyDescriptor.java
src/share/classes/java/beans/PropertyDescriptor.java
+6
-4
test/java/beans/Introspector/6976577/Test6976577.java
test/java/beans/Introspector/6976577/Test6976577.java
+71
-0
test/java/beans/Introspector/6976577/test/Accessor.java
test/java/beans/Introspector/6976577/test/Accessor.java
+81
-0
未找到文件。
src/share/classes/java/beans/EventSetDescriptor.java
浏览文件 @
9a9ef684
...
...
@@ -176,8 +176,9 @@ public class EventSetDescriptor extends FeatureDescriptor {
setRemoveListenerMethod
(
getMethod
(
sourceClass
,
removeListenerMethodName
,
1
));
// Be more forgiving of not finding the getListener method.
if
(
getListenerMethodName
!=
null
)
{
setGetListenerMethod
(
Introspector
.
findInstanceMethod
(
sourceClass
,
getListenerMethodName
));
Method
method
=
Introspector
.
findMethod
(
sourceClass
,
getListenerMethodName
,
0
);
if
(
method
!=
null
)
{
setGetListenerMethod
(
method
);
}
}
...
...
src/share/classes/java/beans/IndexedPropertyDescriptor.java
浏览文件 @
9a9ef684
...
...
@@ -189,11 +189,13 @@ public class IndexedPropertyDescriptor extends PropertyDescriptor {
indexedReadMethodName
=
Introspector
.
GET_PREFIX
+
getBaseName
();
}
}
indexedReadMethod
=
Introspector
.
findInstanceMethod
(
cls
,
indexedReadMethodName
,
int
.
class
);
Class
[]
args
=
{
int
.
class
};
indexedReadMethod
=
Introspector
.
findMethod
(
cls
,
indexedReadMethodName
,
1
,
args
);
if
(
indexedReadMethod
==
null
)
{
// no "is" method, so look for a "get" method.
indexedReadMethodName
=
Introspector
.
GET_PREFIX
+
getBaseName
();
indexedReadMethod
=
Introspector
.
find
InstanceMethod
(
cls
,
indexedReadMethodName
,
int
.
clas
s
);
indexedReadMethod
=
Introspector
.
find
Method
(
cls
,
indexedReadMethodName
,
1
,
arg
s
);
}
setIndexedReadMethod0
(
indexedReadMethod
);
}
...
...
@@ -265,7 +267,9 @@ public class IndexedPropertyDescriptor extends PropertyDescriptor {
if
(
indexedWriteMethodName
==
null
)
{
indexedWriteMethodName
=
Introspector
.
SET_PREFIX
+
getBaseName
();
}
indexedWriteMethod
=
Introspector
.
findInstanceMethod
(
cls
,
indexedWriteMethodName
,
int
.
class
,
type
);
Class
[]
args
=
(
type
==
null
)
?
null
:
new
Class
[]
{
int
.
class
,
type
};
indexedWriteMethod
=
Introspector
.
findMethod
(
cls
,
indexedWriteMethodName
,
2
,
args
);
if
(
indexedWriteMethod
!=
null
)
{
if
(!
indexedWriteMethod
.
getReturnType
().
equals
(
void
.
class
))
{
indexedWriteMethod
=
null
;
...
...
src/share/classes/java/beans/Introspector.java
浏览文件 @
9a9ef684
...
...
@@ -28,7 +28,6 @@ package java.beans;
import
com.sun.beans.WeakCache
;
import
com.sun.beans.finder.BeanInfoFinder
;
import
com.sun.beans.finder.ClassFinder
;
import
com.sun.beans.finder.MethodFinder
;
import
java.lang.ref.Reference
;
import
java.lang.ref.SoftReference
;
...
...
@@ -843,8 +842,8 @@ public class Introspector {
Method
read
=
result
.
getReadMethod
();
if
(
read
==
null
&&
write
!=
null
)
{
read
=
find
Instance
Method
(
result
.
getClass0
(),
GET_PREFIX
+
NameGenerator
.
capitalize
(
result
.
getName
())
);
read
=
findMethod
(
result
.
getClass0
(),
GET_PREFIX
+
NameGenerator
.
capitalize
(
result
.
getName
()),
0
);
if
(
read
!=
null
)
{
try
{
result
.
setReadMethod
(
read
);
...
...
@@ -854,9 +853,9 @@ public class Introspector {
}
}
if
(
write
==
null
&&
read
!=
null
)
{
write
=
find
Instance
Method
(
result
.
getClass0
(),
SET_PREFIX
+
NameGenerator
.
capitalize
(
result
.
getName
())
,
FeatureDescriptor
.
getReturnType
(
result
.
getClass0
(),
read
)
);
write
=
findMethod
(
result
.
getClass0
(),
SET_PREFIX
+
NameGenerator
.
capitalize
(
result
.
getName
()),
1
,
new
Class
[]
{
FeatureDescriptor
.
getReturnType
(
result
.
getClass0
(),
read
)
}
);
if
(
write
!=
null
)
{
try
{
result
.
setWriteMethod
(
write
);
...
...
@@ -1280,27 +1279,90 @@ public class Introspector {
// Package private support methods.
//======================================================================
static
Method
findMethod
(
Class
<?>
type
,
String
name
,
int
args
)
{
for
(
Method
method
:
type
.
getMethods
())
{
if
(
method
.
getName
().
equals
(
name
)
&&
(
args
==
method
.
getParameterTypes
().
length
))
{
try
{
return
MethodFinder
.
findAccessibleMethod
(
method
);
/**
* Internal support for finding a target methodName with a given
* parameter list on a given class.
*/
private
static
Method
internalFindMethod
(
Class
start
,
String
methodName
,
int
argCount
,
Class
args
[])
{
// For overriden methods we need to find the most derived version.
// So we start with the given class and walk up the superclass chain.
Method
method
=
null
;
for
(
Class
cl
=
start
;
cl
!=
null
;
cl
=
cl
.
getSuperclass
())
{
Method
methods
[]
=
getPublicDeclaredMethods
(
cl
);
for
(
int
i
=
0
;
i
<
methods
.
length
;
i
++)
{
method
=
methods
[
i
];
if
(
method
==
null
)
{
continue
;
}
catch
(
NoSuchMethodException
exception
)
{
// continue search for a method with the specified count of parameters
// make sure method signature matches.
Class
params
[]
=
FeatureDescriptor
.
getParameterTypes
(
start
,
method
);
if
(
method
.
getName
().
equals
(
methodName
)
&&
params
.
length
==
argCount
)
{
if
(
args
!=
null
)
{
boolean
different
=
false
;
if
(
argCount
>
0
)
{
for
(
int
j
=
0
;
j
<
argCount
;
j
++)
{
if
(
params
[
j
]
!=
args
[
j
])
{
different
=
true
;
continue
;
}
}
if
(
different
)
{
continue
;
}
}
}
return
method
;
}
return
null
;
}
}
method
=
null
;
static
Method
findInstanceMethod
(
Class
<?>
type
,
String
name
,
Class
<?>...
args
)
{
try
{
return
MethodFinder
.
findInstanceMethod
(
type
,
name
,
args
);
// Now check any inherited interfaces. This is necessary both when
// the argument class is itself an interface, and when the argument
// class is an abstract class.
Class
ifcs
[]
=
start
.
getInterfaces
();
for
(
int
i
=
0
;
i
<
ifcs
.
length
;
i
++)
{
// Note: The original implementation had both methods calling
// the 3 arg method. This is preserved but perhaps it should
// pass the args array instead of null.
method
=
internalFindMethod
(
ifcs
[
i
],
methodName
,
argCount
,
null
);
if
(
method
!=
null
)
{
break
;
}
}
return
method
;
}
/**
* Find a target methodName on a given class.
*/
static
Method
findMethod
(
Class
cls
,
String
methodName
,
int
argCount
)
{
return
findMethod
(
cls
,
methodName
,
argCount
,
null
);
}
catch
(
NoSuchMethodException
exception
)
{
/**
* Find a target methodName with specific parameter list on a given class.
* <p>
* Used in the contructors of the EventSetDescriptor,
* PropertyDescriptor and the IndexedPropertyDescriptor.
* <p>
* @param cls The Class object on which to retrieve the method.
* @param methodName Name of the method.
* @param argCount Number of arguments for the desired method.
* @param args Array of argument types for the method.
* @return the method or null if not found
*/
static
Method
findMethod
(
Class
cls
,
String
methodName
,
int
argCount
,
Class
args
[])
{
if
(
methodName
==
null
)
{
return
null
;
}
return
internalFindMethod
(
cls
,
methodName
,
argCount
,
args
);
}
/**
...
...
src/share/classes/java/beans/MethodDescriptor.java
浏览文件 @
9a9ef684
...
...
@@ -90,13 +90,13 @@ public class MethodDescriptor extends FeatureDescriptor {
// Find methods for up to 2 params. We are guessing here.
// This block should never execute unless the classloader
// that loaded the argument classes disappears.
method
=
Introspector
.
findMethod
(
cls
,
name
,
i
);
method
=
Introspector
.
findMethod
(
cls
,
name
,
i
,
null
);
if
(
method
!=
null
)
{
break
;
}
}
}
else
{
method
=
Statement
.
getMethod
(
cls
,
name
,
params
);
method
=
Introspector
.
findMethod
(
cls
,
name
,
params
.
length
,
params
);
}
setMethod
(
method
);
}
...
...
src/share/classes/java/beans/PropertyDescriptor.java
浏览文件 @
9a9ef684
...
...
@@ -112,7 +112,8 @@ public class PropertyDescriptor extends FeatureDescriptor {
// If this class or one of its base classes allow PropertyChangeListener,
// then we assume that any properties we discover are "bound".
// See Introspector.getTargetPropertyInfo() method.
this
.
bound
=
null
!=
Introspector
.
findInstanceMethod
(
beanClass
,
"addPropertyChangeListener"
,
PropertyChangeListener
.
class
);
Class
[]
args
=
{
PropertyChangeListener
.
class
};
this
.
bound
=
null
!=
Introspector
.
findMethod
(
beanClass
,
"addPropertyChangeListener"
,
args
.
length
,
args
);
}
/**
...
...
@@ -223,10 +224,10 @@ public class PropertyDescriptor extends FeatureDescriptor {
// property type is. For booleans, there can be "is" and "get"
// methods. If an "is" method exists, this is the official
// reader method so look for this one first.
readMethod
=
Introspector
.
find
InstanceMethod
(
cls
,
readMethodName
);
readMethod
=
Introspector
.
find
Method
(
cls
,
readMethodName
,
0
);
if
(
readMethod
==
null
)
{
readMethodName
=
Introspector
.
GET_PREFIX
+
getBaseName
();
readMethod
=
Introspector
.
find
InstanceMethod
(
cls
,
readMethodName
);
readMethod
=
Introspector
.
find
Method
(
cls
,
readMethodName
,
0
);
}
try
{
setReadMethod
(
readMethod
);
...
...
@@ -291,7 +292,8 @@ public class PropertyDescriptor extends FeatureDescriptor {
writeMethodName
=
Introspector
.
SET_PREFIX
+
getBaseName
();
}
writeMethod
=
Introspector
.
findInstanceMethod
(
cls
,
writeMethodName
,
type
);
Class
[]
args
=
(
type
==
null
)
?
null
:
new
Class
[]
{
type
};
writeMethod
=
Introspector
.
findMethod
(
cls
,
writeMethodName
,
1
,
args
);
if
(
writeMethod
!=
null
)
{
if
(!
writeMethod
.
getReturnType
().
equals
(
void
.
class
))
{
writeMethod
=
null
;
...
...
test/java/beans/Introspector/6976577/Test6976577.java
0 → 100644
浏览文件 @
9a9ef684
/*
* Copyright (c) 2010, 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 6976577
* @summary Tests public methods in non-public beans
* @author Sergey Malenkov
*/
import
test.Accessor
;
import
java.beans.EventSetDescriptor
;
import
java.beans.IndexedPropertyDescriptor
;
import
java.beans.PropertyDescriptor
;
import
java.lang.reflect.Method
;
public
class
Test6976577
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
Class
<?>
bt
=
Accessor
.
getBeanType
();
Class
<?>
lt
=
Accessor
.
getListenerType
();
// test PropertyDescriptor
PropertyDescriptor
pd
=
new
PropertyDescriptor
(
"boolean"
,
bt
);
test
(
pd
.
getReadMethod
());
test
(
pd
.
getWriteMethod
());
// test IndexedPropertyDescriptor
IndexedPropertyDescriptor
ipd
=
new
IndexedPropertyDescriptor
(
"indexed"
,
bt
);
test
(
ipd
.
getReadMethod
());
test
(
ipd
.
getWriteMethod
());
test
(
ipd
.
getIndexedReadMethod
());
test
(
ipd
.
getIndexedWriteMethod
());
// test EventSetDescriptor
EventSetDescriptor
esd
=
new
EventSetDescriptor
(
bt
,
"test"
,
lt
,
"process"
);
test
(
esd
.
getAddListenerMethod
());
test
(
esd
.
getRemoveListenerMethod
());
test
(
esd
.
getGetListenerMethod
());
test
(
esd
.
getListenerMethods
());
}
private
static
void
test
(
Method
...
methods
)
{
for
(
Method
method
:
methods
)
{
if
(
method
==
null
)
{
throw
new
Error
(
"public method is not found"
);
}
}
}
}
test/java/beans/Introspector/6976577/test/Accessor.java
0 → 100644
浏览文件 @
9a9ef684
package
test
;
import
java.beans.PropertyChangeListener
;
import
java.beans.PropertyChangeSupport
;
import
java.util.EventListener
;
import
java.util.TooManyListenersException
;
public
class
Accessor
{
public
static
Class
<?>
getBeanType
()
{
return
Bean
.
class
;
}
public
static
Class
<?>
getListenerType
()
{
return
TestListener
.
class
;
}
}
interface
TestEvent
{
}
interface
TestListener
extends
EventListener
{
void
process
(
TestEvent
event
);
}
class
Bean
{
private
boolean
b
;
private
int
[]
indexed
;
private
TestListener
listener
;
private
final
PropertyChangeSupport
pcs
=
new
PropertyChangeSupport
(
this
);
public
void
addPropertyChangeListener
(
PropertyChangeListener
listener
)
{
this
.
pcs
.
addPropertyChangeListener
(
listener
);
}
public
void
addTestListener
(
TestListener
listener
)
throws
TooManyListenersException
{
if
(
listener
!=
null
)
{
if
(
this
.
listener
!=
null
)
{
throw
new
TooManyListenersException
();
}
this
.
listener
=
listener
;
}
}
public
void
removeTestListener
(
TestListener
listener
)
{
if
(
this
.
listener
==
listener
)
{
this
.
listener
=
null
;
}
}
public
TestListener
[]
getTestListeners
()
{
return
(
this
.
listener
!=
null
)
?
new
TestListener
[]
{
this
.
listener
}
:
new
TestListener
[
0
];
}
public
boolean
isBoolean
()
{
return
this
.
b
;
}
public
void
setBoolean
(
boolean
b
)
{
this
.
b
=
b
;
}
public
int
[]
getIndexed
()
{
return
this
.
indexed
;
}
public
void
setIndexed
(
int
[]
values
)
{
this
.
indexed
=
values
;
}
public
int
getIndexed
(
int
index
)
{
return
this
.
indexed
[
index
];
}
public
void
setIndexed
(
int
index
,
int
value
)
{
this
.
indexed
[
index
]
=
value
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录