Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
39b88e35
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看板
提交
39b88e35
编写于
3月 28, 2011
作者:
D
dav
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
7023011: Toolkit.getPrintJob(Frame,String,Properties) throws HE instead of specified NPE
Reviewed-by: dcherepanov, art
上级
e9f1dce7
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
112 addition
and
30 deletion
+112
-30
src/share/classes/java/awt/Toolkit.java
src/share/classes/java/awt/Toolkit.java
+2
-15
src/share/classes/sun/awt/HeadlessToolkit.java
src/share/classes/sun/awt/HeadlessToolkit.java
+2
-4
src/solaris/classes/sun/awt/X11/XToolkit.java
src/solaris/classes/sun/awt/X11/XToolkit.java
+6
-7
src/windows/classes/sun/awt/windows/WToolkit.java
src/windows/classes/sun/awt/windows/WToolkit.java
+4
-4
test/java/awt/Toolkit/Headless/GetPrintJob/GetPrintJob.java
test/java/awt/Toolkit/Headless/GetPrintJob/GetPrintJob.java
+48
-0
test/java/awt/Toolkit/Headless/GetPrintJob/GetPrintJobHeadless.java
...awt/Toolkit/Headless/GetPrintJob/GetPrintJobHeadless.java
+50
-0
未找到文件。
src/share/classes/java/awt/Toolkit.java
浏览文件 @
39b88e35
...
@@ -1157,12 +1157,9 @@ public abstract class Toolkit {
...
@@ -1157,12 +1157,9 @@ public abstract class Toolkit {
* takes JobAttributes and PageAttributes objects. This object
* takes JobAttributes and PageAttributes objects. This object
* may be updated to reflect the user's job choices on exit. May
* may be updated to reflect the user's job choices on exit. May
* be null.
* be null.
*
* @return a <code>PrintJob</code> object, or <code>null</code> if the
* @return a <code>PrintJob</code> object, or <code>null</code> if the
* user cancelled the print job.
* user cancelled the print job.
* @throws NullPointerException if frame is null. This exception is
* @throws NullPointerException if frame is null
* always thrown when GraphicsEnvironment.isHeadless() returns
* true.
* @throws SecurityException if this thread is not allowed to initiate a
* @throws SecurityException if this thread is not allowed to initiate a
* print job request
* print job request
* @see java.awt.GraphicsEnvironment#isHeadless
* @see java.awt.GraphicsEnvironment#isHeadless
...
@@ -1201,12 +1198,9 @@ public abstract class Toolkit {
...
@@ -1201,12 +1198,9 @@ public abstract class Toolkit {
* job. The attributes will be updated to reflect the user's
* job. The attributes will be updated to reflect the user's
* choices as outlined in the PageAttributes documentation. May be
* choices as outlined in the PageAttributes documentation. May be
* null.
* null.
*
* @return a <code>PrintJob</code> object, or <code>null</code> if the
* @return a <code>PrintJob</code> object, or <code>null</code> if the
* user cancelled the print job.
* user cancelled the print job.
* @throws NullPointerException if frame is null and either jobAttributes
* @throws NullPointerException if frame is null
* is null or jobAttributes.getDialog() returns
* JobAttributes.DialogType.NATIVE.
* @throws IllegalArgumentException if pageAttributes specifies differing
* @throws IllegalArgumentException if pageAttributes specifies differing
* cross feed and feed resolutions. Also if this thread has
* cross feed and feed resolutions. Also if this thread has
* access to the file system and jobAttributes specifies
* access to the file system and jobAttributes specifies
...
@@ -1218,9 +1212,6 @@ public abstract class Toolkit {
...
@@ -1218,9 +1212,6 @@ public abstract class Toolkit {
* opportunity to select a file and proceed with printing.
* opportunity to select a file and proceed with printing.
* The dialog will ensure that the selected output file
* The dialog will ensure that the selected output file
* is valid before returning from this method.
* is valid before returning from this method.
* <p>
* This exception is always thrown when GraphicsEnvironment.isHeadless()
* returns true.
* @throws SecurityException if this thread is not allowed to initiate a
* @throws SecurityException if this thread is not allowed to initiate a
* print job request, or if jobAttributes specifies print to file,
* print job request, or if jobAttributes specifies print to file,
* and this thread is not allowed to access the file system
* and this thread is not allowed to access the file system
...
@@ -1236,10 +1227,6 @@ public abstract class Toolkit {
...
@@ -1236,10 +1227,6 @@ public abstract class Toolkit {
PageAttributes
pageAttributes
)
{
PageAttributes
pageAttributes
)
{
// Override to add printing support with new job/page control classes
// Override to add printing support with new job/page control classes
if
(
GraphicsEnvironment
.
isHeadless
())
{
throw
new
IllegalArgumentException
();
}
if
(
this
!=
Toolkit
.
getDefaultToolkit
())
{
if
(
this
!=
Toolkit
.
getDefaultToolkit
())
{
return
Toolkit
.
getDefaultToolkit
().
getPrintJob
(
frame
,
jobtitle
,
return
Toolkit
.
getDefaultToolkit
().
getPrintJob
(
frame
,
jobtitle
,
jobAttributes
,
jobAttributes
,
...
...
src/share/classes/sun/awt/HeadlessToolkit.java
浏览文件 @
39b88e35
...
@@ -320,8 +320,7 @@ public class HeadlessToolkit extends Toolkit
...
@@ -320,8 +320,7 @@ public class HeadlessToolkit extends Toolkit
// Should never happen
// Should never happen
throw
new
HeadlessException
();
throw
new
HeadlessException
();
}
}
throw
new
IllegalArgumentException
(
throw
new
NullPointerException
(
"frame must not be null"
);
"PrintJob not supported in a headless environment"
);
}
}
public
PrintJob
getPrintJob
(
Frame
frame
,
String
doctitle
,
Properties
props
)
public
PrintJob
getPrintJob
(
Frame
frame
,
String
doctitle
,
Properties
props
)
...
@@ -330,8 +329,7 @@ public class HeadlessToolkit extends Toolkit
...
@@ -330,8 +329,7 @@ public class HeadlessToolkit extends Toolkit
// Should never happen
// Should never happen
throw
new
HeadlessException
();
throw
new
HeadlessException
();
}
}
throw
new
IllegalArgumentException
(
throw
new
NullPointerException
(
"frame must not be null"
);
"PrintJob not supported in a headless environment"
);
}
}
/*
/*
...
...
src/solaris/classes/sun/awt/X11/XToolkit.java
浏览文件 @
39b88e35
...
@@ -1222,8 +1222,8 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
...
@@ -1222,8 +1222,8 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
public
PrintJob
getPrintJob
(
final
Frame
frame
,
final
String
doctitle
,
public
PrintJob
getPrintJob
(
final
Frame
frame
,
final
String
doctitle
,
final
Properties
props
)
{
final
Properties
props
)
{
if
(
GraphicsEnvironment
.
isHeadless
()
)
{
if
(
frame
==
null
)
{
throw
new
IllegalArgumentException
(
);
throw
new
NullPointerException
(
"frame must not be null"
);
}
}
PrintJob2D
printJob
=
new
PrintJob2D
(
frame
,
doctitle
,
props
);
PrintJob2D
printJob
=
new
PrintJob2D
(
frame
,
doctitle
,
props
);
...
@@ -1236,11 +1236,10 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
...
@@ -1236,11 +1236,10 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
public
PrintJob
getPrintJob
(
final
Frame
frame
,
final
String
doctitle
,
public
PrintJob
getPrintJob
(
final
Frame
frame
,
final
String
doctitle
,
final
JobAttributes
jobAttributes
,
final
JobAttributes
jobAttributes
,
final
PageAttributes
pageAttributes
)
{
final
PageAttributes
pageAttributes
)
{
if
(
frame
==
null
)
{
if
(
GraphicsEnvironment
.
isHeadless
())
{
throw
new
NullPointerException
(
"frame must not be null"
);
throw
new
IllegalArgumentException
();
}
}
PrintJob2D
printJob
=
new
PrintJob2D
(
frame
,
doctitle
,
PrintJob2D
printJob
=
new
PrintJob2D
(
frame
,
doctitle
,
...
...
src/windows/classes/sun/awt/windows/WToolkit.java
浏览文件 @
39b88e35
...
@@ -630,10 +630,10 @@ public class WToolkit extends SunToolkit implements Runnable {
...
@@ -630,10 +630,10 @@ public class WToolkit extends SunToolkit implements Runnable {
public
PrintJob
getPrintJob
(
Frame
frame
,
String
doctitle
,
public
PrintJob
getPrintJob
(
Frame
frame
,
String
doctitle
,
JobAttributes
jobAttributes
,
JobAttributes
jobAttributes
,
PageAttributes
pageAttributes
)
{
PageAttributes
pageAttributes
)
{
if
(
GraphicsEnvironment
.
isHeadless
()
)
{
if
(
frame
==
null
)
{
throw
new
IllegalArgumentException
(
);
throw
new
NullPointerException
(
"frame must not be null"
);
}
}
PrintJob2D
printJob
=
new
PrintJob2D
(
frame
,
doctitle
,
PrintJob2D
printJob
=
new
PrintJob2D
(
frame
,
doctitle
,
...
...
test/java/awt/Toolkit/Headless/GetPrintJob/GetPrintJob.java
0 → 100644
浏览文件 @
39b88e35
/*
@test
@bug 7023011
@library ../../../regtesthelpers
@build Sysout
@summary Toolkit.getPrintJob() throws wrong exceptions
@author andrei dmitriev: area=awt.headless
@run main GetPrintJob
*/
import
java.awt.*
;
import
java.util.Properties
;
import
test.java.awt.regtesthelpers.Sysout
;
/*
* In headfull mode we should always getting NPE on the getPrintJob() call if frame == null.
*/
public
class
GetPrintJob
{
public
static
void
main
(
String
[]
s
)
{
boolean
stage1Passed
=
false
;
boolean
stage2Passed
=
false
;
try
{
Toolkit
.
getDefaultToolkit
().
getPrintJob
(
(
Frame
)
null
,
"title"
,
new
Properties
());
}
catch
(
NullPointerException
e
)
{
stage1Passed
=
true
;
Sysout
.
println
(
"Stage 1 passed. getPrintJob(null, String, property) has thrown NPE."
);
}
if
(!
stage1Passed
)
{
throw
new
RuntimeException
(
"getPrintJob() should have thrown NPE but didn't."
);
}
try
{
Toolkit
.
getDefaultToolkit
().
getPrintJob
(
(
Frame
)
null
,
"title"
,
new
JobAttributes
(),
new
PageAttributes
());
}
catch
(
NullPointerException
e
)
{
stage2Passed
=
true
;
Sysout
.
println
(
"Stage 2 passed. getPrintJob(null, String, jobAttrs, pageAttr) has thrown NPE."
);
}
if
(!
stage2Passed
)
{
throw
new
RuntimeException
(
"getPrintJob() should have thrown NPE but didn't."
);
}
Sysout
.
println
(
"Test PASSED"
);
}
}
test/java/awt/Toolkit/Headless/GetPrintJob/GetPrintJobHeadless.java
0 → 100644
浏览文件 @
39b88e35
/*
@test
@bug 7023011
@library ../../../regtesthelpers
@build Sysout
@summary Toolkit.getPrintJob() throws wrong exceptions
@author andrei dmitriev: area=awt.headless
@run main/othervm -Djava.awt.headless=true GetPrintJobHeadless
*/
/*
* In headless mode we should always getting NPE on the getPrintJob() call
*/
import
java.awt.*
;
import
java.util.Properties
;
import
test.java.awt.regtesthelpers.Sysout
;
public
class
GetPrintJobHeadless
{
public
static
void
main
(
String
[]
s
)
{
boolean
stage1Passed
=
false
;
boolean
stage2Passed
=
false
;
try
{
Toolkit
.
getDefaultToolkit
().
getPrintJob
(
(
Frame
)
null
,
"title"
,
new
Properties
());
}
catch
(
NullPointerException
e
)
{
stage1Passed
=
true
;
e
.
printStackTrace
();
Sysout
.
println
(
"Stage 1 passed. getPrintJob(null, String, property) has thrown NPE."
);
}
if
(!
stage1Passed
)
{
throw
new
RuntimeException
(
"getPrintJob() should have thrown NPE but didn't."
);
}
try
{
Toolkit
.
getDefaultToolkit
().
getPrintJob
(
(
Frame
)
null
,
"title"
,
new
JobAttributes
(),
new
PageAttributes
());
}
catch
(
NullPointerException
e
)
{
stage2Passed
=
true
;
e
.
printStackTrace
();
Sysout
.
println
(
"Stage 2 passed. getPrintJob(null, String, jobAttrs, pageAttr) has thrown NPE."
);
}
if
(!
stage2Passed
)
{
throw
new
RuntimeException
(
"getPrintJob() should have thrown NPE but didn't."
);
}
Sysout
.
println
(
"Test PASSED"
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录