Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
58626400
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看板
提交
58626400
编写于
8月 16, 2013
作者:
E
egahlin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
6696970: Jconsole becomes unusable if a plugin throws an exception
Reviewed-by: mchung, jbachorik
上级
a45db9f8
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
142 addition
and
6 deletion
+142
-6
src/share/classes/sun/tools/jconsole/ExceptionSafePlugin.java
...share/classes/sun/tools/jconsole/ExceptionSafePlugin.java
+126
-0
src/share/classes/sun/tools/jconsole/Messages.java
src/share/classes/sun/tools/jconsole/Messages.java
+5
-0
src/share/classes/sun/tools/jconsole/VMPanel.java
src/share/classes/sun/tools/jconsole/VMPanel.java
+6
-6
src/share/classes/sun/tools/jconsole/resources/messages.properties
.../classes/sun/tools/jconsole/resources/messages.properties
+5
-0
未找到文件。
src/share/classes/sun/tools/jconsole/ExceptionSafePlugin.java
0 → 100644
浏览文件 @
58626400
/*
* 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. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* 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.
*/
package
sun.tools.jconsole
;
import
java.util.HashMap
;
import
java.util.Map
;
import
javax.swing.JOptionPane
;
import
javax.swing.JPanel
;
import
javax.swing.SwingWorker
;
import
com.sun.tools.jconsole.JConsolePlugin
;
/**
* Proxy that shields GUI from plug-in exceptions.
*
*/
final
class
ExceptionSafePlugin
extends
JConsolePlugin
{
private
static
boolean
ignoreExceptions
;
private
final
JConsolePlugin
plugin
;
public
ExceptionSafePlugin
(
JConsolePlugin
plugin
)
{
this
.
plugin
=
plugin
;
}
@Override
public
Map
<
String
,
JPanel
>
getTabs
()
{
try
{
return
plugin
.
getTabs
();
}
catch
(
RuntimeException
e
)
{
handleException
(
e
);
}
return
new
HashMap
<>();
}
@Override
public
SwingWorker
<?,
?>
newSwingWorker
()
{
try
{
return
plugin
.
newSwingWorker
();
}
catch
(
RuntimeException
e
)
{
handleException
(
e
);
}
return
null
;
}
@Override
public
void
dispose
()
{
try
{
plugin
.
dispose
();
}
catch
(
RuntimeException
e
)
{
handleException
(
e
);
}
}
public
void
executeSwingWorker
(
SwingWorker
<?,
?>
sw
)
{
try
{
sw
.
execute
();
}
catch
(
RuntimeException
e
)
{
handleException
(
e
);
}
}
private
void
handleException
(
Exception
e
)
{
if
(
JConsole
.
isDebug
())
{
System
.
err
.
println
(
"Plug-in exception:"
);
e
.
printStackTrace
();
}
else
{
if
(!
ignoreExceptions
)
{
showExceptionDialog
(
e
);
}
}
}
private
void
showExceptionDialog
(
Exception
e
)
{
Object
[]
buttonTexts
=
{
Messages
.
PLUGIN_EXCEPTION_DIALOG_BUTTON_OK
,
Messages
.
PLUGIN_EXCEPTION_DIALOG_BUTTON_EXIT
,
Messages
.
PLUGIN_EXCEPTION_DIALOG_BUTTON_IGNORE
};
String
message
=
String
.
format
(
Messages
.
PLUGIN_EXCEPTION_DIALOG_MESSAGE
,
plugin
.
getClass
().
getSimpleName
(),
String
.
valueOf
(
e
.
getMessage
())
);
int
buttonIndex
=
JOptionPane
.
showOptionDialog
(
null
,
message
,
Messages
.
PLUGIN_EXCEPTION_DIALOG_TITLE
,
JOptionPane
.
YES_NO_CANCEL_OPTION
,
JOptionPane
.
ERROR_MESSAGE
,
null
,
buttonTexts
,
buttonTexts
[
0
]
);
if
(
buttonIndex
==
1
)
{
System
.
exit
(
0
);
}
ignoreExceptions
=
buttonIndex
==
2
;
}
}
src/share/classes/sun/tools/jconsole/Messages.java
浏览文件 @
58626400
...
...
@@ -240,6 +240,11 @@ final public class Messages {
public
static
String
PLOTTER_ACCESSIBLE_NAME_NO_DATA
;
public
static
String
PLOTTER_SAVE_AS_MENU_ITEM
;
public
static
String
PLOTTER_TIME_RANGE_MENU
;
public
static
String
PLUGIN_EXCEPTION_DIALOG_BUTTON_EXIT
;
public
static
String
PLUGIN_EXCEPTION_DIALOG_BUTTON_IGNORE
;
public
static
String
PLUGIN_EXCEPTION_DIALOG_BUTTON_OK
;
public
static
String
PLUGIN_EXCEPTION_DIALOG_MESSAGE
;
public
static
String
PLUGIN_EXCEPTION_DIALOG_TITLE
;
public
static
String
PROBLEM_ADDING_LISTENER
;
public
static
String
PROBLEM_DISPLAYING_MBEAN
;
public
static
String
PROBLEM_INVOKING
;
...
...
src/share/classes/sun/tools/jconsole/VMPanel.java
浏览文件 @
58626400
/*
* Copyright (c) 2004, 201
2
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2004, 201
3
, 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
...
...
@@ -71,7 +71,7 @@ public class VMPanel extends JTabbedPane implements PropertyChangeListener {
// Each VMPanel has its own instance of the JConsolePlugin
// A map of JConsolePlugin to the previous SwingWorker
private
Map
<
JConsol
ePlugin
,
SwingWorker
<?,
?>>
plugins
=
null
;
private
Map
<
ExceptionSaf
ePlugin
,
SwingWorker
<?,
?>>
plugins
=
null
;
private
boolean
pluginTabsAdded
=
false
;
// Update these only on the EDT
...
...
@@ -107,10 +107,10 @@ public class VMPanel extends JTabbedPane implements PropertyChangeListener {
}
}
plugins
=
new
LinkedHashMap
<
JConsol
ePlugin
,
SwingWorker
<?,
?>>();
plugins
=
new
LinkedHashMap
<
ExceptionSaf
ePlugin
,
SwingWorker
<?,
?>>();
for
(
JConsolePlugin
p
:
JConsole
.
getPlugins
())
{
p
.
setContext
(
proxyClient
);
plugins
.
put
(
p
,
null
);
plugins
.
put
(
new
ExceptionSafePlugin
(
p
)
,
null
);
}
Utilities
.
updateTransparency
(
this
);
...
...
@@ -566,7 +566,7 @@ public class VMPanel extends JTabbedPane implements PropertyChangeListener {
}
// plugin GUI update
for
(
JConsol
ePlugin
p
:
plugins
.
keySet
())
{
for
(
ExceptionSaf
ePlugin
p
:
plugins
.
keySet
())
{
SwingWorker
<?,
?>
sw
=
p
.
newSwingWorker
();
SwingWorker
<?,
?>
prevSW
=
plugins
.
get
(
p
);
// schedule SwingWorker to run only if the previous
...
...
@@ -575,7 +575,7 @@ public class VMPanel extends JTabbedPane implements PropertyChangeListener {
if
(
sw
==
null
||
sw
.
getState
()
==
SwingWorker
.
StateValue
.
PENDING
)
{
plugins
.
put
(
p
,
sw
);
if
(
sw
!=
null
)
{
sw
.
execute
(
);
p
.
executeSwingWorker
(
sw
);
}
}
}
...
...
src/share/classes/sun/tools/jconsole/resources/messages.properties
浏览文件 @
58626400
...
...
@@ -198,6 +198,11 @@ PLOTTER_ACCESSIBLE_NAME_KEY_AND_VALUE={0}={1}\n
PLOTTER_ACCESSIBLE_NAME_NO_DATA
=
No data plotted.
PLOTTER_SAVE_AS_MENU_ITEM
=
Save data &as...
PLOTTER_TIME_RANGE_MENU
=
&Time Range
PLUGIN_EXCEPTION_DIALOG_BUTTON_EXIT
=
Exit
PLUGIN_EXCEPTION_DIALOG_BUTTON_IGNORE
=
Ignore
PLUGIN_EXCEPTION_DIALOG_BUTTON_OK
=
OK
PLUGIN_EXCEPTION_DIALOG_MESSAGE
=
An unexpected exception has occurred in %s:
\n\n
%s
\n\n
Start with -debug for details. Ignore will suppress further exceptions.
PLUGIN_EXCEPTION_DIALOG_TITLE
=
Plug-in exception
PROBLEM_ADDING_LISTENER
=
Problem adding listener
PROBLEM_DISPLAYING_MBEAN
=
Problem displaying MBean
PROBLEM_INVOKING
=
Problem invoking
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录