Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
d63480bd
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看板
提交
d63480bd
编写于
4月 18, 2014
作者:
M
malenkov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8039137: KSS: JTextComponent.isProcessInputMethodEventOverridden
Reviewed-by: alexsch, serb
上级
8d1fe65a
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
117 addition
and
74 deletion
+117
-74
src/share/classes/com/sun/beans/util/Cache.java
src/share/classes/com/sun/beans/util/Cache.java
+2
-2
src/share/classes/javax/swing/text/JTextComponent.java
src/share/classes/javax/swing/text/JTextComponent.java
+32
-72
test/java/beans/Introspector/TestCacheRecursion.java
test/java/beans/Introspector/TestCacheRecursion.java
+83
-0
未找到文件。
src/share/classes/com/sun/beans/util/Cache.java
浏览文件 @
d63480bd
...
...
@@ -119,13 +119,13 @@ public abstract class Cache<K,V> {
synchronized
(
this
.
queue
)
{
// synchronized search improves stability
// we must create and add new value if there are no needed entry
int
index
=
index
(
hash
,
this
.
table
);
current
=
getEntryValue
(
key
,
hash
,
this
.
table
[
index
]);
current
=
getEntryValue
(
key
,
hash
,
this
.
table
[
index
(
hash
,
this
.
table
)]);
if
(
current
!=
null
)
{
return
current
;
}
V
value
=
create
(
key
);
Objects
.
requireNonNull
(
value
,
"value"
);
int
index
=
index
(
hash
,
this
.
table
);
this
.
table
[
index
]
=
new
CacheEntry
<>(
hash
,
key
,
value
,
this
.
table
[
index
]);
if
(++
this
.
size
>=
this
.
threshold
)
{
if
(
this
.
table
.
length
==
MAXIMUM_CAPACITY
)
{
...
...
src/share/classes/javax/swing/text/JTextComponent.java
浏览文件 @
d63480bd
...
...
@@ -24,18 +24,16 @@
*/
package
javax.swing.text
;
import
java.lang.reflect.Method
;
import
com.sun.beans.util.Cache
;
import
java.security.AccessController
;
import
java.security.PrivilegedAction
;
import
java.beans.Transient
;
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.Hashtable
;
import
java.util.Enumeration
;
import
java.util.Vector
;
import
java.util.Map
;
import
java.util.concurrent.*
;
...
...
@@ -1191,47 +1189,6 @@ public abstract class JTextComponent extends JComponent implements Scrollable, A
}
}
/**
* Returns true if <code>klass</code> is NOT a JTextComponent and it or
* one of its superclasses (stoping at JTextComponent) overrides
* <code>processInputMethodEvent</code>. It is assumed this will be
* invoked from within a <code>doPrivileged</code>, and it is also
* assumed <code>klass</code> extends <code>JTextComponent</code>.
*/
private
static
Boolean
isProcessInputMethodEventOverridden
(
Class
<?>
klass
)
{
if
(
klass
==
JTextComponent
.
class
)
{
return
Boolean
.
FALSE
;
}
Boolean
retValue
=
overrideMap
.
get
(
klass
.
getName
());
if
(
retValue
!=
null
)
{
return
retValue
;
}
Boolean
sOverriden
=
isProcessInputMethodEventOverridden
(
klass
.
getSuperclass
());
if
(
sOverriden
.
booleanValue
())
{
// If our superclass has overriden it, then by definition klass
// overrides it.
overrideMap
.
put
(
klass
.
getName
(),
sOverriden
);
return
sOverriden
;
}
// klass's superclass didn't override it, check for an override in
// klass.
try
{
Class
[]
classes
=
new
Class
[
1
];
classes
[
0
]
=
InputMethodEvent
.
class
;
Method
m
=
klass
.
getDeclaredMethod
(
"processInputMethodEvent"
,
classes
);
retValue
=
Boolean
.
TRUE
;
}
catch
(
NoSuchMethodException
nsme
)
{
retValue
=
Boolean
.
FALSE
;
}
overrideMap
.
put
(
klass
.
getName
(),
retValue
);
return
retValue
;
}
/**
* Fetches the current color used to render the
* caret.
...
...
@@ -3913,7 +3870,33 @@ public abstract class JTextComponent extends JComponent implements Scrollable, A
* Maps from class name to Boolean indicating if
* <code>processInputMethodEvent</code> has been overriden.
*/
private
static
Map
<
String
,
Boolean
>
overrideMap
;
private
static
Cache
<
Class
<?>,
Boolean
>
METHOD_OVERRIDDEN
=
new
Cache
<
Class
<?>,
Boolean
>(
Cache
.
Kind
.
WEAK
,
Cache
.
Kind
.
STRONG
)
{
/**
* Returns {@code true} if the specified {@code type} extends {@link JTextComponent}
* and the {@link JTextComponent#processInputMethodEvent} method is overridden.
*/
@Override
public
Boolean
create
(
final
Class
<?>
type
)
{
if
(
JTextComponent
.
class
==
type
)
{
return
Boolean
.
FALSE
;
}
if
(
get
(
type
.
getSuperclass
()))
{
return
Boolean
.
TRUE
;
}
return
AccessController
.
doPrivileged
(
new
PrivilegedAction
<
Boolean
>()
{
public
Boolean
run
()
{
try
{
type
.
getDeclaredMethod
(
"processInputMethodEvent"
,
InputMethodEvent
.
class
);
return
Boolean
.
TRUE
;
}
catch
(
NoSuchMethodException
exception
)
{
return
Boolean
.
FALSE
;
}
}
});
}
};
/**
* Returns a string representation of this <code>JTextComponent</code>.
...
...
@@ -4938,38 +4921,15 @@ public abstract class JTextComponent extends JComponent implements Scrollable, A
*/
private
boolean
shouldSynthensizeKeyEvents
()
{
if
(!
checkedInputOverride
)
{
// Checks whether the client code overrides processInputMethodEvent.
// If it is overridden, need not to generate KeyTyped events for committed text.
// If it's not, behave as an passive input method client.
needToSendKeyTypedEvent
=
!
METHOD_OVERRIDDEN
.
get
(
getClass
());
checkedInputOverride
=
true
;
needToSendKeyTypedEvent
=
!
isProcessInputMethodEventOverridden
();
}
return
needToSendKeyTypedEvent
;
}
//
// Checks whether the client code overrides processInputMethodEvent. If it is overridden,
// need not to generate KeyTyped events for committed text. If it's not, behave as an
// passive input method client.
//
private
boolean
isProcessInputMethodEventOverridden
()
{
if
(
overrideMap
==
null
)
{
overrideMap
=
Collections
.
synchronizedMap
(
new
HashMap
<
String
,
Boolean
>());
}
Boolean
retValue
=
overrideMap
.
get
(
getClass
().
getName
());
if
(
retValue
!=
null
)
{
return
retValue
.
booleanValue
();
}
Boolean
ret
=
AccessController
.
doPrivileged
(
new
PrivilegedAction
<
Boolean
>()
{
public
Boolean
run
()
{
return
isProcessInputMethodEventOverridden
(
JTextComponent
.
this
.
getClass
());
}
});
return
ret
.
booleanValue
();
}
//
// Checks whether a composed text in this text component
//
...
...
test/java/beans/Introspector/TestCacheRecursion.java
0 → 100644
浏览文件 @
d63480bd
/*
* Copyright (c) 2014, 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
com.sun.beans.util.Cache
;
/*
* @test
* @bug 8039137
* @summary Tests Cache recursion
* @author Sergey Malenkov
* @compile -XDignore.symbol.file TestCacheRecursion.java
* @run main TestCacheRecursion
*/
public
class
TestCacheRecursion
{
private
static
boolean
ERROR
;
private
static
final
Cache
<
Class
<?>,
Boolean
>
CACHE
=
new
Cache
<
Class
<?>,
Boolean
>(
Cache
.
Kind
.
WEAK
,
Cache
.
Kind
.
STRONG
)
{
@Override
public
Boolean
create
(
Class
<?>
type
)
{
if
(
ERROR
)
{
throw
new
Error
(
"not initialized"
);
}
type
=
type
.
getSuperclass
();
return
(
type
!=
null
)
&&
get
(
type
);
}
};
public
static
void
main
(
String
[]
args
)
{
CACHE
.
get
(
Z
.
class
);
ERROR
=
true
;
for
(
Class
<?>
type
=
Z
.
class
;
type
!=
null
;
type
=
type
.
getSuperclass
())
{
CACHE
.
get
(
type
);
}
}
private
class
A
{}
private
class
B
extends
A
{}
private
class
C
extends
B
{}
private
class
D
extends
C
{}
private
class
E
extends
D
{}
private
class
F
extends
E
{}
private
class
G
extends
F
{}
private
class
H
extends
G
{}
private
class
I
extends
H
{}
private
class
J
extends
I
{}
private
class
K
extends
J
{}
private
class
L
extends
K
{}
private
class
M
extends
L
{}
private
class
N
extends
M
{}
private
class
O
extends
N
{}
private
class
P
extends
O
{}
private
class
Q
extends
P
{}
private
class
R
extends
Q
{}
private
class
S
extends
R
{}
private
class
T
extends
S
{}
private
class
U
extends
T
{}
private
class
V
extends
U
{}
private
class
W
extends
V
{}
private
class
X
extends
W
{}
private
class
Y
extends
X
{}
private
class
Z
extends
Y
{}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录