Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
b6c379bf
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看板
提交
b6c379bf
编写于
7月 22, 2011
作者:
D
denis
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
7019773: AWTKeyStroke.ctor is a mutable static
Reviewed-by: art
上级
47e3bc91
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
39 addition
and
13 deletion
+39
-13
src/share/classes/java/awt/AWTKeyStroke.java
src/share/classes/java/awt/AWTKeyStroke.java
+39
-13
未找到文件。
src/share/classes/java/awt/AWTKeyStroke.java
浏览文件 @
b6c379bf
...
...
@@ -25,6 +25,7 @@
package
java.awt
;
import
java.awt.event.KeyEvent
;
import
sun.awt.AppContext
;
import
java.awt.event.InputEvent
;
import
java.util.Collections
;
import
java.util.HashMap
;
...
...
@@ -66,9 +67,6 @@ import java.lang.reflect.Field;
public
class
AWTKeyStroke
implements
Serializable
{
static
final
long
serialVersionUID
=
-
6430539691155161871L
;
private
static
Map
cache
;
private
static
AWTKeyStroke
cacheKey
;
private
static
Constructor
ctor
=
getCtor
(
AWTKeyStroke
.
class
);
private
static
Map
modifierKeywords
;
/**
* Associates VK_XXX (as a String) with code (as Integer). This is
...
...
@@ -77,6 +75,25 @@ public class AWTKeyStroke implements Serializable {
*/
private
static
VKCollection
vks
;
//A key for the collection of AWTKeyStrokes within AppContext.
private
static
Object
APP_CONTEXT_CACHE_KEY
=
new
Object
();
//A key withing the cache
private
static
AWTKeyStroke
APP_CONTEXT_KEYSTROKE_KEY
=
new
AWTKeyStroke
();
/*
* Reads keystroke class from AppContext and if null, puts there the
* AWTKeyStroke class.
* Must be called under locked AWTKeyStro
*/
private
static
Class
getAWTKeyStrokeClass
()
{
Class
clazz
=
(
Class
)
AppContext
.
getAppContext
().
get
(
AWTKeyStroke
.
class
);
if
(
clazz
==
null
)
{
clazz
=
AWTKeyStroke
.
class
;
AppContext
.
getAppContext
().
put
(
AWTKeyStroke
.
class
,
AWTKeyStroke
.
class
);
}
return
clazz
;
}
private
char
keyChar
=
KeyEvent
.
CHAR_UNDEFINED
;
private
int
keyCode
=
KeyEvent
.
VK_UNDEFINED
;
private
int
modifiers
;
...
...
@@ -164,9 +181,12 @@ public class AWTKeyStroke implements Serializable {
if
(
subclass
==
null
)
{
throw
new
IllegalArgumentException
(
"subclass cannot be null"
);
}
if
(
AWTKeyStroke
.
ctor
.
getDeclaringClass
().
equals
(
subclass
))
{
// Already registered
return
;
synchronized
(
AWTKeyStroke
.
class
)
{
Class
keyStrokeClass
=
(
Class
)
AppContext
.
getAppContext
().
get
(
AWTKeyStroke
.
class
);
if
(
keyStrokeClass
!=
null
&&
keyStrokeClass
.
equals
(
subclass
)){
// Already registered
return
;
}
}
if
(!
AWTKeyStroke
.
class
.
isAssignableFrom
(
subclass
))
{
throw
new
ClassCastException
(
"subclass is not derived from AWTKeyStroke"
);
...
...
@@ -197,9 +217,9 @@ public class AWTKeyStroke implements Serializable {
}
synchronized
(
AWTKeyStroke
.
class
)
{
A
WTKeyStroke
.
ctor
=
ctor
;
cache
=
null
;
cacheKey
=
null
;
A
ppContext
.
getAppContext
().
put
(
AWTKeyStroke
.
class
,
subclass
)
;
AppContext
.
getAppContext
().
remove
(
APP_CONTEXT_CACHE_KEY
)
;
AppContext
.
getAppContext
().
remove
(
APP_CONTEXT_KEYSTROKE_KEY
)
;
}
}
...
...
@@ -229,13 +249,19 @@ public class AWTKeyStroke implements Serializable {
private
static
synchronized
AWTKeyStroke
getCachedStroke
(
char
keyChar
,
int
keyCode
,
int
modifiers
,
boolean
onKeyRelease
)
{
Map
cache
=
(
Map
)
AppContext
.
getAppContext
().
get
(
APP_CONTEXT_CACHE_KEY
);
AWTKeyStroke
cacheKey
=
(
AWTKeyStroke
)
AppContext
.
getAppContext
().
get
(
APP_CONTEXT_KEYSTROKE_KEY
);
if
(
cache
==
null
)
{
cache
=
new
HashMap
();
AppContext
.
getAppContext
().
put
(
APP_CONTEXT_CACHE_KEY
,
cache
);
}
if
(
cacheKey
==
null
)
{
try
{
cacheKey
=
(
AWTKeyStroke
)
ctor
.
newInstance
((
Object
[])
null
);
Class
clazz
=
getAWTKeyStrokeClass
();
cacheKey
=
(
AWTKeyStroke
)
getCtor
(
clazz
).
newInstance
((
Object
[])
null
);
AppContext
.
getAppContext
().
put
(
APP_CONTEXT_KEYSTROKE_KEY
,
cacheKey
);
}
catch
(
InstantiationException
e
)
{
assert
(
false
);
}
catch
(
IllegalAccessException
e
)
{
...
...
@@ -253,9 +279,8 @@ public class AWTKeyStroke implements Serializable {
if
(
stroke
==
null
)
{
stroke
=
cacheKey
;
cache
.
put
(
stroke
,
stroke
);
cacheKey
=
null
;
AppContext
.
getAppContext
().
remove
(
APP_CONTEXT_KEYSTROKE_KEY
)
;
}
return
stroke
;
}
...
...
@@ -778,7 +803,8 @@ public class AWTKeyStroke implements Serializable {
protected
Object
readResolve
()
throws
java
.
io
.
ObjectStreamException
{
synchronized
(
AWTKeyStroke
.
class
)
{
Class
newClass
=
getClass
();
if
(!
newClass
.
equals
(
ctor
.
getDeclaringClass
()))
{
Class
awtKeyStrokeClass
=
getAWTKeyStrokeClass
();
if
(!
newClass
.
equals
(
awtKeyStrokeClass
))
{
registerSubclass
(
newClass
);
}
return
getCachedStroke
(
keyChar
,
keyCode
,
modifiers
,
onKeyRelease
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录