Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
ec8f21d4
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看板
提交
ec8f21d4
编写于
4月 30, 2013
作者:
M
mcherkas
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8012004: JInternalFrame not being finalized after closing
Reviewed-by: alexsch, alexp
上级
4d81c7c3
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
147 addition
and
0 deletion
+147
-0
src/share/classes/javax/swing/JDesktopPane.java
src/share/classes/javax/swing/JDesktopPane.java
+9
-0
test/javax/swing/JInternalFrame/InternalFrameIsNotCollectedTest.java
...swing/JInternalFrame/InternalFrameIsNotCollectedTest.java
+138
-0
未找到文件。
src/share/classes/javax/swing/JDesktopPane.java
浏览文件 @
ec8f21d4
...
@@ -427,6 +427,15 @@ public class JDesktopPane extends JLayeredPane implements Accessible
...
@@ -427,6 +427,15 @@ public class JDesktopPane extends JLayeredPane implements Accessible
}
}
}
}
/**
* {@inheritDoc}
*/
@Override
public
void
remove
(
Component
comp
)
{
super
.
remove
(
comp
);
updateFramesCache
();
}
/**
/**
* Selects the next <code>JInternalFrame</code> in this desktop pane.
* Selects the next <code>JInternalFrame</code> in this desktop pane.
*
*
...
...
test/javax/swing/JInternalFrame/InternalFrameIsNotCollectedTest.java
0 → 100644
浏览文件 @
ec8f21d4
/*
* Copyright (c) 2013, 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 8012004
@summary JINTERNALFRAME NOT BEING FINALIZED AFTER CLOSING
@author mcherkas
@run main InternalFrameIsNotCollectedTest
*/
import
sun.awt.SunToolkit
;
import
javax.swing.*
;
import
java.awt.*
;
import
java.awt.event.KeyEvent
;
import
java.beans.PropertyVetoException
;
import
java.util.Date
;
public
class
InternalFrameIsNotCollectedTest
{
public
static
final
int
waitTime
=
10000
;
private
static
Robot
robot
;
public
static
void
sync
()
{
SunToolkit
toolkit
=
(
SunToolkit
)
Toolkit
.
getDefaultToolkit
();
toolkit
.
realSync
();
}
public
static
void
main
(
String
[]
args
)
throws
Exception
{
initRobot
();
SwingUtilities
.
invokeAndWait
(
new
Runnable
()
{
@Override
public
void
run
()
{
initUI
();
try
{
closeInternalFrame
();
}
catch
(
PropertyVetoException
e
)
{
throw
new
RuntimeException
(
e
);
}
}
});
sync
();
invokeGC
();
Thread
.
sleep
(
1000
);
// it's better to wait 1 sec now then 10 sec later
Date
startWaiting
=
new
Date
();
synchronized
(
CustomInternalFrame
.
waiter
)
{
// Sync with finalization thread.
Date
now
=
new
Date
();
while
(
now
.
getTime
()
-
startWaiting
.
getTime
()
<
waitTime
&&
!
CustomInternalFrame
.
finalized
)
{
CustomInternalFrame
.
waiter
.
wait
(
waitTime
);
now
=
new
Date
();
}
}
if
(!
CustomInternalFrame
.
finalized
)
{
throw
new
RuntimeException
(
"Closed internal frame wasn't collected"
);
}
}
private
static
void
initRobot
()
throws
AWTException
{
robot
=
new
Robot
();
robot
.
setAutoDelay
(
100
);
}
private
static
void
closeInternalFrame
()
throws
PropertyVetoException
{
robot
.
keyPress
(
KeyEvent
.
VK_CONTROL
);
robot
.
keyPress
(
KeyEvent
.
VK_F4
);
robot
.
keyRelease
(
KeyEvent
.
VK_F4
);
robot
.
keyRelease
(
KeyEvent
.
VK_CONTROL
);
}
private
static
void
initUI
()
{
JFrame
frame
=
new
JFrame
(
"Internal Frame Test"
);
frame
.
getContentPane
().
setLayout
(
new
BorderLayout
());
JDesktopPane
desktopPane
=
new
JDesktopPane
();
desktopPane
.
setDesktopManager
(
new
DefaultDesktopManager
());
frame
.
getContentPane
().
add
(
desktopPane
,
BorderLayout
.
CENTER
);
CustomInternalFrame
iFrame
=
new
CustomInternalFrame
(
"Dummy Frame"
);
iFrame
.
setSize
(
200
,
200
);
iFrame
.
setDefaultCloseOperation
(
WindowConstants
.
DISPOSE_ON_CLOSE
);
desktopPane
.
add
(
iFrame
);
frame
.
setSize
(
800
,
600
);
frame
.
setDefaultCloseOperation
(
WindowConstants
.
DISPOSE_ON_CLOSE
);
frame
.
setVisible
(
true
);
iFrame
.
setVisible
(
true
);
}
private
static
void
invokeGC
()
{
System
.
out
.
println
(
"Firing garbage collection!"
);
try
{
StringBuilder
sb
=
new
StringBuilder
();
while
(
true
)
{
sb
.
append
(
"any string. some test. a little bit more text."
+
sb
.
toString
());
}
}
catch
(
Throwable
e
)
{
// do nothing
}
}
public
static
class
CustomInternalFrame
extends
JInternalFrame
{
public
static
volatile
boolean
finalized
=
false
;
public
static
Object
waiter
=
new
Object
();
public
CustomInternalFrame
(
String
title
)
{
super
(
title
,
true
,
true
,
true
,
true
);
}
protected
void
finalize
()
{
System
.
out
.
println
(
"Finalized!"
);
finalized
=
true
;
waiter
.
notifyAll
();
}
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录