Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
d58597e0
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看板
提交
d58597e0
编写于
8月 14, 2009
作者:
R
rupashka
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
6824600: OOM occurs when setLookAndFeel() is executed in Windows L&F(XP style)
Reviewed-by: alexp
上级
6471c8ff
变更
5
展开全部
隐藏空白更改
内联
并排
Showing
5 changed file
with
148 addition
and
158 deletion
+148
-158
src/share/classes/com/sun/java/swing/plaf/windows/DesktopProperty.java
...sses/com/sun/java/swing/plaf/windows/DesktopProperty.java
+15
-33
src/share/classes/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java
...s/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java
+57
-115
src/share/classes/javax/swing/plaf/metal/MetalFontDesktopProperty.java
...sses/javax/swing/plaf/metal/MetalFontDesktopProperty.java
+4
-6
src/share/classes/javax/swing/plaf/metal/MetalLookAndFeel.java
...hare/classes/javax/swing/plaf/metal/MetalLookAndFeel.java
+2
-4
test/com/sun/java/swing/plaf/windows/Test6824600.java
test/com/sun/java/swing/plaf/windows/Test6824600.java
+70
-0
未找到文件。
src/share/classes/com/sun/java/swing/plaf/windows/DesktopProperty.java
浏览文件 @
d58597e0
/*
* Copyright 2001-200
8
Sun Microsystems, Inc. All Rights Reserved.
* Copyright 2001-200
9
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
...
...
@@ -49,7 +49,7 @@ public class DesktopProperty implements UIDefaults.ActiveValue {
/**
* ReferenceQueue of unreferenced WeakPCLs.
*/
private
static
ReferenceQueue
<
DesktopProperty
>
queue
;
private
static
final
ReferenceQueue
<
DesktopProperty
>
queue
=
new
ReferenceQueue
<
DesktopProperty
>()
;
/**
* PropertyChangeListener attached to the Toolkit.
...
...
@@ -58,7 +58,7 @@ public class DesktopProperty implements UIDefaults.ActiveValue {
/**
* Key used to lookup value from desktop.
*/
private
String
key
;
private
final
String
key
;
/**
* Value to return.
*/
...
...
@@ -66,17 +66,8 @@ public class DesktopProperty implements UIDefaults.ActiveValue {
/**
* Fallback value in case we get null from desktop.
*/
private
Object
fallback
;
private
final
Object
fallback
;
/**
* Toolkit.
*/
private
Toolkit
toolkit
;
static
{
queue
=
new
ReferenceQueue
<
DesktopProperty
>();
}
/**
* Cleans up any lingering state held by unrefeernced
...
...
@@ -138,13 +129,10 @@ public class DesktopProperty implements UIDefaults.ActiveValue {
*
* @param key Key used in looking up desktop value.
* @param fallback Value used if desktop property is null.
* @param toolkit Toolkit used to fetch property from, can be null
* in which default will be used.
*/
public
DesktopProperty
(
String
key
,
Object
fallback
,
Toolkit
toolkit
)
{
public
DesktopProperty
(
String
key
,
Object
fallback
)
{
this
.
key
=
key
;
this
.
fallback
=
fallback
;
this
.
toolkit
=
toolkit
;
// The only sure fire way to clear our references is to create a
// Thread and wait for a reference to be added to the queue.
// Because it is so rare that you will actually change the look
...
...
@@ -175,13 +163,14 @@ public class DesktopProperty implements UIDefaults.ActiveValue {
* Returns the value from the desktop.
*/
protected
Object
getValueFromDesktop
()
{
if
(
this
.
toolkit
==
null
)
{
this
.
toolkit
=
Toolkit
.
getDefaultToolkit
();
Toolkit
toolkit
=
Toolkit
.
getDefaultToolkit
();
if
(
pcl
==
null
)
{
pcl
=
new
WeakPCL
(
this
,
getKey
(),
UIManager
.
getLookAndFeel
());
toolkit
.
addPropertyChangeListener
(
getKey
(),
pcl
);
}
Object
value
=
toolkit
.
getDesktopProperty
(
getKey
());
pcl
=
new
WeakPCL
(
this
,
toolkit
,
getKey
(),
UIManager
.
getLookAndFeel
());
toolkit
.
addPropertyChangeListener
(
getKey
(),
pcl
);
return
value
;
return
toolkit
.
getDesktopProperty
(
getKey
());
}
/**
...
...
@@ -205,12 +194,7 @@ public class DesktopProperty implements UIDefaults.ActiveValue {
* <code>createValue</code> will ask for the property again.
*/
public
void
invalidate
()
{
if
(
pcl
!=
null
)
{
toolkit
.
removePropertyChangeListener
(
getKey
(),
pcl
);
toolkit
=
null
;
pcl
=
null
;
value
=
null
;
}
value
=
null
;
}
/**
...
...
@@ -271,13 +255,11 @@ public class DesktopProperty implements UIDefaults.ActiveValue {
*/
private
static
class
WeakPCL
extends
WeakReference
<
DesktopProperty
>
implements
PropertyChangeListener
{
private
Toolkit
kit
;
private
String
key
;
private
LookAndFeel
laf
;
WeakPCL
(
DesktopProperty
target
,
Toolkit
kit
,
String
key
,
LookAndFeel
laf
)
{
WeakPCL
(
DesktopProperty
target
,
String
key
,
LookAndFeel
laf
)
{
super
(
target
,
queue
);
this
.
kit
=
kit
;
this
.
key
=
key
;
this
.
laf
=
laf
;
}
...
...
@@ -297,7 +279,7 @@ public class DesktopProperty implements UIDefaults.ActiveValue {
}
void
dispose
()
{
kit
.
removePropertyChangeListener
(
key
,
this
);
Toolkit
.
getDefaultToolkit
()
.
removePropertyChangeListener
(
key
,
this
);
}
}
}
src/share/classes/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java
浏览文件 @
d58597e0
此差异已折叠。
点击以展开。
src/share/classes/javax/swing/plaf/metal/MetalFontDesktopProperty.java
浏览文件 @
d58597e0
/*
* Copyright 2001 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 2001
-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
...
...
@@ -25,8 +25,6 @@
package
javax.swing.plaf.metal
;
import
java.awt.*
;
import
java.beans.*
;
import
javax.swing.*
;
/**
* DesktopProperty that only uses font height in configuring font. This
...
...
@@ -60,7 +58,7 @@ class MetalFontDesktopProperty extends com.sun.java.swing.plaf.windows.DesktopPr
* @param type MetalTheme font type.
*/
MetalFontDesktopProperty
(
int
type
)
{
this
(
propertyMapping
[
type
],
Toolkit
.
getDefaultToolkit
(),
type
);
this
(
propertyMapping
[
type
],
type
);
}
/**
...
...
@@ -72,8 +70,8 @@ class MetalFontDesktopProperty extends com.sun.java.swing.plaf.windows.DesktopPr
* @param type Type of font being used, corresponds to MetalTheme font
* type.
*/
MetalFontDesktopProperty
(
String
key
,
Toolkit
kit
,
int
type
)
{
super
(
key
,
null
,
kit
);
MetalFontDesktopProperty
(
String
key
,
int
type
)
{
super
(
key
,
null
);
this
.
type
=
type
;
}
...
...
src/share/classes/javax/swing/plaf/metal/MetalLookAndFeel.java
浏览文件 @
d58597e0
/*
* Copyright 1998-200
8
Sun Microsystems, Inc. All Rights Reserved.
* Copyright 1998-200
9
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
...
...
@@ -1541,10 +1541,8 @@ public class MetalLookAndFeel extends BasicLookAndFeel
table
.
putDefaults
(
defaults
);
if
(
isWindows
()
&&
useSystemFonts
()
&&
theme
.
isSystemTheme
())
{
Toolkit
kit
=
Toolkit
.
getDefaultToolkit
();
Object
messageFont
=
new
MetalFontDesktopProperty
(
"win.messagebox.font.height"
,
kit
,
MetalTheme
.
CONTROL_TEXT_FONT
);
"win.messagebox.font.height"
,
MetalTheme
.
CONTROL_TEXT_FONT
);
defaults
=
new
Object
[]
{
"OptionPane.messageFont"
,
messageFont
,
...
...
test/com/sun/java/swing/plaf/windows/Test6824600.java
0 → 100644
浏览文件 @
d58597e0
/*
* 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 6824600
@summary OOM occurs when setLookAndFeel() is executed in Windows L&F(XP style)
@author Pavel Porvatov
@run main Test6824600
*/
import
com.sun.java.swing.plaf.windows.DesktopProperty
;
import
java.awt.*
;
public
class
Test6824600
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
Toolkit
toolkit
=
Toolkit
.
getDefaultToolkit
();
HackedDesktopProperty
desktopProperty
=
new
HackedDesktopProperty
(
"Button.background"
,
null
);
// Register listener in toolkit
desktopProperty
.
getValueFromDesktop
();
int
length
=
toolkit
.
getPropertyChangeListeners
().
length
;
// Make several invocations
desktopProperty
.
getValueFromDesktop
();
desktopProperty
.
getValueFromDesktop
();
desktopProperty
.
invalidate
();
desktopProperty
.
getValueFromDesktop
();
desktopProperty
.
getValueFromDesktop
();
if
(
length
!=
toolkit
.
getPropertyChangeListeners
().
length
)
{
throw
new
RuntimeException
(
"New listeners were added into Toolkit"
);
}
}
public
static
class
HackedDesktopProperty
extends
DesktopProperty
{
public
HackedDesktopProperty
(
String
key
,
Object
fallback
)
{
super
(
key
,
fallback
);
}
// Publish the method
public
Object
getValueFromDesktop
()
{
return
super
.
getValueFromDesktop
();
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录