Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell11
提交
05d10a00
D
dragonwell11
项目概览
openanolis
/
dragonwell11
通知
7
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell11
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
05d10a00
编写于
3月 10, 2020
作者:
S
serb
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8233573: Toolkit.getScreenInsets(GraphicsConfiguration) may throw ClassCastException
Reviewed-by: prr, jdv
上级
3fb775be
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
273 addition
and
10 deletion
+273
-10
src/java.desktop/macosx/classes/sun/lwawt/macosx/LWCToolkit.java
...a.desktop/macosx/classes/sun/lwawt/macosx/LWCToolkit.java
+5
-2
src/java.desktop/unix/classes/sun/awt/X11/XToolkit.java
src/java.desktop/unix/classes/sun/awt/X11/XToolkit.java
+4
-5
src/java.desktop/windows/classes/sun/awt/windows/WToolkit.java
...ava.desktop/windows/classes/sun/awt/windows/WToolkit.java
+6
-3
test/jdk/java/awt/Toolkit/GetScreenInsetsCustomGC/GetScreenInsetsCustomGC.java
...lkit/GetScreenInsetsCustomGC/GetScreenInsetsCustomGC.java
+258
-0
未找到文件。
src/java.desktop/macosx/classes/sun/lwawt/macosx/LWCToolkit.java
浏览文件 @
05d10a00
...
@@ -102,7 +102,6 @@ import javax.swing.UIManager;
...
@@ -102,7 +102,6 @@ import javax.swing.UIManager;
import
com.apple.laf.AquaMenuBarUI
;
import
com.apple.laf.AquaMenuBarUI
;
import
sun.awt.AWTAccessor
;
import
sun.awt.AWTAccessor
;
import
sun.awt.AppContext
;
import
sun.awt.AppContext
;
import
sun.awt.CGraphicsConfig
;
import
sun.awt.CGraphicsDevice
;
import
sun.awt.CGraphicsDevice
;
import
sun.awt.LightweightFrame
;
import
sun.awt.LightweightFrame
;
import
sun.awt.SunToolkit
;
import
sun.awt.SunToolkit
;
...
@@ -470,7 +469,11 @@ public final class LWCToolkit extends LWToolkit {
...
@@ -470,7 +469,11 @@ public final class LWCToolkit extends LWToolkit {
@Override
@Override
public
Insets
getScreenInsets
(
final
GraphicsConfiguration
gc
)
{
public
Insets
getScreenInsets
(
final
GraphicsConfiguration
gc
)
{
return
((
CGraphicsConfig
)
gc
).
getDevice
().
getScreenInsets
();
GraphicsDevice
gd
=
gc
.
getDevice
();
if
(!(
gd
instanceof
CGraphicsDevice
))
{
return
super
.
getScreenInsets
(
gc
);
}
return
((
CGraphicsDevice
)
gd
).
getScreenInsets
();
}
}
@Override
@Override
...
...
src/java.desktop/unix/classes/sun/awt/X11/XToolkit.java
浏览文件 @
05d10a00
...
@@ -854,11 +854,10 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
...
@@ -854,11 +854,10 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
* _NET_WORKAREA may start at point x1,y1 and end at point x2,y2.
* _NET_WORKAREA may start at point x1,y1 and end at point x2,y2.
*/
*/
@Override
@Override
public
Insets
getScreenInsets
(
GraphicsConfiguration
gc
)
public
Insets
getScreenInsets
(
final
GraphicsConfiguration
gc
)
{
{
GraphicsDevice
gd
=
gc
.
getDevice
();
XNETProtocol
netProto
=
XWM
.
getWM
().
getNETProtocol
();
XNETProtocol
np
=
XWM
.
getWM
().
getNETProtocol
();
if
((
netProto
==
null
)
||
!
netProto
.
active
())
if
(
np
==
null
||
!(
gd
instanceof
X11GraphicsDevice
)
||
!
np
.
active
())
{
{
return
super
.
getScreenInsets
(
gc
);
return
super
.
getScreenInsets
(
gc
);
}
}
...
...
src/java.desktop/windows/classes/sun/awt/windows/WToolkit.java
浏览文件 @
05d10a00
...
@@ -607,9 +607,12 @@ public final class WToolkit extends SunToolkit implements Runnable {
...
@@ -607,9 +607,12 @@ public final class WToolkit extends SunToolkit implements Runnable {
static
ColorModel
screenmodel
;
static
ColorModel
screenmodel
;
@Override
@Override
public
Insets
getScreenInsets
(
GraphicsConfiguration
gc
)
public
Insets
getScreenInsets
(
final
GraphicsConfiguration
gc
)
{
{
GraphicsDevice
gd
=
gc
.
getDevice
();
return
getScreenInsets
(((
Win32GraphicsDevice
)
gc
.
getDevice
()).
getScreen
());
if
(!(
gd
instanceof
Win32GraphicsDevice
))
{
return
super
.
getScreenInsets
(
gc
);
}
return
getScreenInsets
(((
Win32GraphicsDevice
)
gd
).
getScreen
());
}
}
@Override
@Override
...
...
test/jdk/java/awt/Toolkit/GetScreenInsetsCustomGC/GetScreenInsetsCustomGC.java
0 → 100644
浏览文件 @
05d10a00
/*
* Copyright (c) 2020, 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
java.awt.Dialog
;
import
java.awt.Dimension
;
import
java.awt.EventQueue
;
import
java.awt.Font
;
import
java.awt.FontMetrics
;
import
java.awt.Frame
;
import
java.awt.Graphics2D
;
import
java.awt.GraphicsConfiguration
;
import
java.awt.GraphicsDevice
;
import
java.awt.GraphicsEnvironment
;
import
java.awt.HeadlessException
;
import
java.awt.Image
;
import
java.awt.Insets
;
import
java.awt.PrintJob
;
import
java.awt.Rectangle
;
import
java.awt.Toolkit
;
import
java.awt.datatransfer.Clipboard
;
import
java.awt.font.TextAttribute
;
import
java.awt.geom.AffineTransform
;
import
java.awt.im.InputMethodHighlight
;
import
java.awt.image.BufferedImage
;
import
java.awt.image.ColorModel
;
import
java.awt.image.ImageObserver
;
import
java.awt.image.ImageProducer
;
import
java.net.URL
;
import
java.util.Map
;
import
java.util.Properties
;
/**
* @test
* @bug 8233573
* @key headful
* @summary Toolkit.getScreenInsets should work for custom GraphicsConfiguration
*/
public
final
class
GetScreenInsetsCustomGC
{
public
static
void
main
(
final
String
[]
args
)
{
// Default GraphicsConfiguration
GraphicsConfiguration
dc
=
GraphicsEnvironment
.
getLocalGraphicsEnvironment
()
.
getDefaultScreenDevice
()
.
getDefaultConfiguration
();
// Custom GraphicsConfiguration
GraphicsConfiguration
cd
=
new
_GraphicsConfiguration
();
// GraphicsConfiguration of BufferedImage
BufferedImage
bi
=
new
BufferedImage
(
1
,
1
,
BufferedImage
.
TYPE_INT_ARGB
);
Graphics2D
g
=
bi
.
createGraphics
();
GraphicsConfiguration
bic
=
g
.
getDeviceConfiguration
();
g
.
dispose
();
// Default toolkit
// mey return empty and non-empty insets but never null
if
(
Toolkit
.
getDefaultToolkit
().
getScreenInsets
(
dc
)
==
null
)
{
throw
new
NullPointerException
();
}
// return empty insets only for non-default GC
testEmpty
(
Toolkit
.
getDefaultToolkit
().
getScreenInsets
(
cd
));
testEmpty
(
Toolkit
.
getDefaultToolkit
().
getScreenInsets
(
bic
));
try
{
Toolkit
.
getDefaultToolkit
().
getScreenInsets
(
null
);
throw
new
RuntimeException
(
"NullPointerException is not thrown"
);
}
catch
(
NullPointerException
ignored
)
{
// ok
}
// Custom toolkit
Toolkit
tk
=
new
_Toolkit
();
// mey return empty and non-empty insets but never null
if
(
tk
.
getScreenInsets
(
dc
)
==
null
)
{
throw
new
NullPointerException
();
}
// return empty insets only for non-default GC
testEmpty
(
tk
.
getScreenInsets
(
cd
));
testEmpty
(
tk
.
getScreenInsets
(
bic
));
try
{
tk
.
getScreenInsets
(
null
);
throw
new
RuntimeException
(
"NullPointerException is not thrown"
);
}
catch
(
NullPointerException
ignored
)
{
// ok
}
}
private
static
void
testEmpty
(
final
Insets
insets
)
{
if
((
insets
.
left
|
insets
.
top
|
insets
.
bottom
|
insets
.
right
)
!=
0
)
{
System
.
err
.
println
(
"Expected empty insets"
);
System
.
err
.
println
(
"Actual: "
+
insets
);
throw
new
RuntimeException
();
}
}
private
static
class
_GraphicsConfiguration
extends
GraphicsConfiguration
{
@Override
public
GraphicsDevice
getDevice
()
{
return
null
;
}
@Override
public
ColorModel
getColorModel
()
{
return
null
;
}
@Override
public
ColorModel
getColorModel
(
int
transparency
)
{
return
null
;
}
@Override
public
AffineTransform
getDefaultTransform
()
{
return
null
;
}
@Override
public
AffineTransform
getNormalizingTransform
()
{
return
null
;
}
@Override
public
Rectangle
getBounds
()
{
return
null
;
}
}
private
static
class
_Toolkit
extends
Toolkit
{
@Override
public
Dimension
getScreenSize
()
throws
HeadlessException
{
return
null
;
}
@Override
public
int
getScreenResolution
()
throws
HeadlessException
{
return
0
;
}
@Override
public
ColorModel
getColorModel
()
throws
HeadlessException
{
return
null
;
}
@Override
public
String
[]
getFontList
()
{
return
new
String
[
0
];
}
@Override
public
FontMetrics
getFontMetrics
(
Font
font
)
{
return
null
;
}
@Override
public
void
sync
()
{
}
@Override
public
Image
getImage
(
String
filename
)
{
return
null
;
}
@Override
public
Image
getImage
(
URL
url
)
{
return
null
;
}
@Override
public
Image
createImage
(
String
filename
)
{
return
null
;
}
@Override
public
Image
createImage
(
URL
url
)
{
return
null
;
}
@Override
public
boolean
prepareImage
(
Image
image
,
int
width
,
int
height
,
ImageObserver
observer
)
{
return
false
;
}
@Override
public
int
checkImage
(
Image
image
,
int
width
,
int
height
,
ImageObserver
observer
)
{
return
0
;
}
@Override
public
Image
createImage
(
ImageProducer
producer
)
{
return
null
;
}
@Override
public
Image
createImage
(
byte
[]
imagedata
,
int
imageoffset
,
int
imagelength
)
{
return
null
;
}
@Override
public
PrintJob
getPrintJob
(
Frame
frame
,
String
jobtitle
,
Properties
props
)
{
return
null
;
}
@Override
public
void
beep
()
{
}
@Override
public
Clipboard
getSystemClipboard
()
throws
HeadlessException
{
return
null
;
}
@Override
protected
EventQueue
getSystemEventQueueImpl
()
{
return
null
;
}
@Override
public
boolean
isModalityTypeSupported
(
Dialog
.
ModalityType
modalityType
)
{
return
false
;
}
@Override
public
boolean
isModalExclusionTypeSupported
(
Dialog
.
ModalExclusionType
modalExclusionType
)
{
return
false
;
}
@Override
public
Map
<
TextAttribute
,
?>
mapInputMethodHighlight
(
InputMethodHighlight
highlight
)
throws
HeadlessException
{
return
null
;
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录