Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_langtools
提交
ecc9c0bc
D
dragonwell8_langtools
项目概览
openanolis
/
dragonwell8_langtools
通知
0
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_langtools
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
ecc9c0bc
编写于
11月 14, 2010
作者:
D
darcy
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
6991528: Support making Throwable.suppressedExceptions immutable
Reviewed-by: mcimadamore
上级
5937f9f2
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
35 addition
and
33 deletion
+35
-33
src/share/classes/com/sun/tools/javac/comp/Lower.java
src/share/classes/com/sun/tools/javac/comp/Lower.java
+4
-4
src/share/classes/com/sun/tools/javac/util/Names.java
src/share/classes/com/sun/tools/javac/util/Names.java
+3
-1
test/tools/javac/TryWithResources/TwrSuppression.java
test/tools/javac/TryWithResources/TwrSuppression.java
+1
-1
test/tools/javac/TryWithResources/TwrTests.java
test/tools/javac/TryWithResources/TwrTests.java
+27
-27
未找到文件。
src/share/classes/com/sun/tools/javac/comp/Lower.java
浏览文件 @
ecc9c0bc
/*
* Copyright (c) 1999, 20
09
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 20
10
, 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
...
...
@@ -1509,17 +1509,17 @@ public class Lower extends TreeTranslator {
}
private
JCBlock
makeArmFinallyClause
(
Symbol
primaryException
,
JCExpression
resource
)
{
// primaryException.addSuppressed
Exception
(catchException);
// primaryException.addSuppressed(catchException);
VarSymbol
catchException
=
new
VarSymbol
(
0
,
make
.
paramName
(
2
),
syms
.
throwableType
,
currentMethodSym
);
JCStatement
addSuppressionStatement
=
make
.
Exec
(
makeCall
(
make
.
Ident
(
primaryException
),
names
.
fromString
(
"addSuppressedException"
)
,
names
.
addSuppressed
,
List
.<
JCExpression
>
of
(
make
.
Ident
(
catchException
))));
// try { resource.close(); } catch (e) { primaryException.addSuppressed
Exception
(e); }
// try { resource.close(); } catch (e) { primaryException.addSuppressed(e); }
JCBlock
tryBlock
=
make
.
Block
(
0L
,
List
.<
JCStatement
>
of
(
makeResourceCloseInvocation
(
resource
)));
JCVariableDecl
catchExceptionDecl
=
make
.
VarDef
(
catchException
,
null
);
...
...
src/share/classes/com/sun/tools/javac/util/Names.java
浏览文件 @
ecc9c0bc
/*
* Copyright (c) 1999, 20
08
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 20
10
, 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
...
...
@@ -150,6 +150,7 @@ public class Names {
public
final
Name
finalize
;
public
final
Name
java_lang_AutoCloseable
;
public
final
Name
close
;
public
final
Name
addSuppressed
;
public
final
Name
.
Table
table
;
...
...
@@ -268,6 +269,7 @@ public class Names {
java_lang_AutoCloseable
=
fromString
(
"java.lang.AutoCloseable"
);
close
=
fromString
(
"close"
);
addSuppressed
=
fromString
(
"addSuppressed"
);
}
protected
Name
.
Table
createTable
(
Options
options
)
{
...
...
test/tools/javac/TryWithResources/TwrSuppression.java
浏览文件 @
ecc9c0bc
...
...
@@ -36,7 +36,7 @@ public class TwrSuppression implements AutoCloseable {
throw
new
RuntimeException
();
}
}
catch
(
RuntimeException
e
)
{
Throwable
[]
suppressedExceptions
=
e
.
getSuppressed
Exceptions
();
Throwable
[]
suppressedExceptions
=
e
.
getSuppressed
();
int
length
=
suppressedExceptions
.
length
;
if
(
length
!=
2
)
throw
new
RuntimeException
(
"Unexpected length "
+
length
);
...
...
test/tools/javac/TryWithResources/TwrTests.java
浏览文件 @
ecc9c0bc
...
...
@@ -90,7 +90,7 @@ public class TwrTests {
}
catch
(
Resource
.
CreateFailException
e
)
{
creationFailuresDetected
++;
checkCreateFailureId
(
e
.
resourceId
(),
createFailureId
);
checkSuppressedExceptions
(
e
.
getSuppressed
Exceptions
(),
bitMap
);
checkSuppressedExceptions
(
e
.
getSuppressed
(),
bitMap
);
}
catch
(
Resource
.
CloseFailException
e
)
{
throw
new
AssertionError
(
"Secondary exception suppression failed"
);
}
...
...
@@ -112,7 +112,7 @@ public class TwrTests {
}
catch
(
Resource
.
CreateFailException
e
)
{
creationFailuresDetected
++;
checkCreateFailureId
(
e
.
resourceId
(),
createFailureId
);
checkSuppressedExceptions
(
e
.
getSuppressed
Exceptions
(),
bitMap
);
checkSuppressedExceptions
(
e
.
getSuppressed
(),
bitMap
);
}
catch
(
Resource
.
CloseFailException
e
)
{
throw
new
AssertionError
(
"Secondary exception suppression failed"
);
}
...
...
@@ -134,7 +134,7 @@ public class TwrTests {
}
catch
(
Resource
.
CreateFailException
e
)
{
creationFailuresDetected
++;
checkCreateFailureId
(
e
.
resourceId
(),
createFailureId
);
checkSuppressedExceptions
(
e
.
getSuppressed
Exceptions
(),
bitMap
);
checkSuppressedExceptions
(
e
.
getSuppressed
(),
bitMap
);
}
catch
(
Resource
.
CloseFailException
e
)
{
throw
new
AssertionError
(
"Secondary exception suppression failed:"
+
e
);
}
...
...
@@ -158,7 +158,7 @@ public class TwrTests {
}
catch
(
Resource
.
CreateFailException
e
)
{
creationFailuresDetected
++;
checkCreateFailureId
(
e
.
resourceId
(),
createFailureId
);
checkSuppressedExceptions
(
e
.
getSuppressed
Exceptions
(),
bitMap
);
checkSuppressedExceptions
(
e
.
getSuppressed
(),
bitMap
);
}
catch
(
Resource
.
CloseFailException
e
)
{
throw
new
AssertionError
(
"Secondary exception suppression failed:"
+
e
);
}
...
...
@@ -181,7 +181,7 @@ public class TwrTests {
}
catch
(
Resource
.
CreateFailException
e
)
{
creationFailuresDetected
++;
checkCreateFailureId
(
e
.
resourceId
(),
createFailureId
);
checkSuppressedExceptions
(
e
.
getSuppressed
Exceptions
(),
bitMap
);
checkSuppressedExceptions
(
e
.
getSuppressed
(),
bitMap
);
}
catch
(
Resource
.
CloseFailException
e
)
{
throw
new
AssertionError
(
"Secondary exception suppression failed:"
+
e
);
}
...
...
@@ -207,7 +207,7 @@ public class TwrTests {
}
catch
(
Resource
.
CreateFailException
e
)
{
creationFailuresDetected
++;
checkCreateFailureId
(
e
.
resourceId
(),
createFailureId
);
checkSuppressedExceptions
(
e
.
getSuppressed
Exceptions
(),
bitMap
);
checkSuppressedExceptions
(
e
.
getSuppressed
(),
bitMap
);
}
catch
(
Resource
.
CloseFailException
e
)
{
throw
new
AssertionError
(
"Secondary exception suppression failed:"
+
e
);
}
...
...
@@ -231,7 +231,7 @@ public class TwrTests {
}
catch
(
Resource
.
CreateFailException
e
)
{
creationFailuresDetected
++;
checkCreateFailureId
(
e
.
resourceId
(),
createFailureId
);
checkSuppressedExceptions
(
e
.
getSuppressed
Exceptions
(),
bitMap
);
checkSuppressedExceptions
(
e
.
getSuppressed
(),
bitMap
);
}
catch
(
Resource
.
CloseFailException
e
)
{
throw
new
AssertionError
(
"Secondary exception suppression failed:"
+
e
);
}
...
...
@@ -259,7 +259,7 @@ public class TwrTests {
}
catch
(
Resource
.
CreateFailException
e
)
{
creationFailuresDetected
++;
checkCreateFailureId
(
e
.
resourceId
(),
createFailureId
);
checkSuppressedExceptions
(
e
.
getSuppressed
Exceptions
(),
bitMap
);
checkSuppressedExceptions
(
e
.
getSuppressed
(),
bitMap
);
}
catch
(
Resource
.
CloseFailException
e
)
{
throw
new
AssertionError
(
"Secondary exception suppression failed:"
+
e
);
}
...
...
@@ -310,7 +310,7 @@ public class TwrTests {
* Check for proper suppressed exceptions in proper order.
*
* @param suppressedExceptions the suppressed exceptions array returned by
* getSuppressed
Exceptions
()
* getSuppressed()
* @bitmap a bitmap indicating which suppressed exceptions are expected.
* Bit i is set iff id should throw a CloseFailException.
*/
...
...
@@ -376,7 +376,7 @@ public class TwrTests {
}
catch
(
MyKindOfException
e
)
{
if
(
failure
==
0
)
throw
new
AssertionError
(
"Unexpected MyKindOfException"
);
checkSuppressedExceptions
(
e
.
getSuppressed
Exceptions
(),
bitMap
);
checkSuppressedExceptions
(
e
.
getSuppressed
(),
bitMap
);
}
catch
(
Resource
.
CloseFailException
e
)
{
if
(
failure
==
1
)
throw
new
AssertionError
(
"Secondary exception suppression failed"
);
...
...
@@ -388,7 +388,7 @@ public class TwrTests {
throw
new
AssertionError
(
"CloseFailException: got id "
+
id
+
", expected lg("
+
highestCloseFailBit
+
")"
);
}
checkSuppressedExceptions
(
e
.
getSuppressed
Exceptions
(),
bitMap
&
~
highestCloseFailBit
);
checkSuppressedExceptions
(
e
.
getSuppressed
(),
bitMap
&
~
highestCloseFailBit
);
}
checkClosedList
(
closedList
,
1
);
}
...
...
@@ -409,7 +409,7 @@ public class TwrTests {
}
catch
(
MyKindOfException
e
)
{
if
(
failure
==
0
)
throw
new
AssertionError
(
"Unexpected MyKindOfException"
);
checkSuppressedExceptions
(
e
.
getSuppressed
Exceptions
(),
bitMap
);
checkSuppressedExceptions
(
e
.
getSuppressed
(),
bitMap
);
}
catch
(
Resource
.
CloseFailException
e
)
{
if
(
failure
==
1
)
throw
new
AssertionError
(
"Secondary exception suppression failed"
);
...
...
@@ -421,7 +421,7 @@ public class TwrTests {
throw
new
AssertionError
(
"CloseFailException: got id "
+
id
+
", expected lg("
+
highestCloseFailBit
+
")"
);
}
checkSuppressedExceptions
(
e
.
getSuppressed
Exceptions
(),
bitMap
&
~
highestCloseFailBit
);
checkSuppressedExceptions
(
e
.
getSuppressed
(),
bitMap
&
~
highestCloseFailBit
);
}
checkClosedList
(
closedList
,
2
);
}
...
...
@@ -443,7 +443,7 @@ public class TwrTests {
}
catch
(
MyKindOfException
e
)
{
if
(
failure
==
0
)
throw
new
AssertionError
(
"Unexpected MyKindOfException"
);
checkSuppressedExceptions
(
e
.
getSuppressed
Exceptions
(),
bitMap
);
checkSuppressedExceptions
(
e
.
getSuppressed
(),
bitMap
);
}
catch
(
Resource
.
CloseFailException
e
)
{
if
(
failure
==
1
)
throw
new
AssertionError
(
"Secondary exception suppression failed"
);
...
...
@@ -455,7 +455,7 @@ public class TwrTests {
throw
new
AssertionError
(
"CloseFailException: got id "
+
id
+
", expected lg("
+
highestCloseFailBit
+
")"
);
}
checkSuppressedExceptions
(
e
.
getSuppressed
Exceptions
(),
bitMap
&
~
highestCloseFailBit
);
checkSuppressedExceptions
(
e
.
getSuppressed
(),
bitMap
&
~
highestCloseFailBit
);
}
checkClosedList
(
closedList
,
2
);
}
...
...
@@ -477,7 +477,7 @@ public class TwrTests {
}
catch
(
MyKindOfException
e
)
{
if
(
failure
==
0
)
throw
new
AssertionError
(
"Unexpected MyKindOfException"
);
checkSuppressedExceptions
(
e
.
getSuppressed
Exceptions
(),
bitMap
);
checkSuppressedExceptions
(
e
.
getSuppressed
(),
bitMap
);
}
catch
(
Resource
.
CloseFailException
e
)
{
if
(
failure
==
1
)
throw
new
AssertionError
(
"Secondary exception suppression failed"
);
...
...
@@ -489,7 +489,7 @@ public class TwrTests {
throw
new
AssertionError
(
"CloseFailException: got id "
+
id
+
", expected lg("
+
highestCloseFailBit
+
")"
);
}
checkSuppressedExceptions
(
e
.
getSuppressed
Exceptions
(),
bitMap
&
~
highestCloseFailBit
);
checkSuppressedExceptions
(
e
.
getSuppressed
(),
bitMap
&
~
highestCloseFailBit
);
}
checkClosedList
(
closedList
,
3
);
}
...
...
@@ -513,7 +513,7 @@ public class TwrTests {
}
catch
(
MyKindOfException
e
)
{
if
(
failure
==
0
)
throw
new
AssertionError
(
"Unexpected MyKindOfException"
);
checkSuppressedExceptions
(
e
.
getSuppressed
Exceptions
(),
bitMap
);
checkSuppressedExceptions
(
e
.
getSuppressed
(),
bitMap
);
}
catch
(
Resource
.
CloseFailException
e
)
{
if
(
failure
==
1
)
throw
new
AssertionError
(
"Secondary exception suppression failed"
);
...
...
@@ -525,7 +525,7 @@ public class TwrTests {
throw
new
AssertionError
(
"CloseFailException: got id "
+
id
+
", expected lg("
+
highestCloseFailBit
+
")"
);
}
checkSuppressedExceptions
(
e
.
getSuppressed
Exceptions
(),
bitMap
&
~
highestCloseFailBit
);
checkSuppressedExceptions
(
e
.
getSuppressed
(),
bitMap
&
~
highestCloseFailBit
);
}
checkClosedList
(
closedList
,
3
);
}
...
...
@@ -548,7 +548,7 @@ public class TwrTests {
}
catch
(
MyKindOfException
e
)
{
if
(
failure
==
0
)
throw
new
AssertionError
(
"Unexpected MyKindOfException"
);
checkSuppressedExceptions
(
e
.
getSuppressed
Exceptions
(),
bitMap
);
checkSuppressedExceptions
(
e
.
getSuppressed
(),
bitMap
);
}
catch
(
Resource
.
CloseFailException
e
)
{
if
(
failure
==
1
)
throw
new
AssertionError
(
"Secondary exception suppression failed"
);
...
...
@@ -560,7 +560,7 @@ public class TwrTests {
throw
new
AssertionError
(
"CloseFailException: got id "
+
id
+
", expected lg("
+
highestCloseFailBit
+
")"
);
}
checkSuppressedExceptions
(
e
.
getSuppressed
Exceptions
(),
bitMap
&
~
highestCloseFailBit
);
checkSuppressedExceptions
(
e
.
getSuppressed
(),
bitMap
&
~
highestCloseFailBit
);
}
checkClosedList
(
closedList
,
4
);
}
...
...
@@ -586,7 +586,7 @@ public class TwrTests {
}
catch
(
MyKindOfException
e
)
{
if
(
failure
==
0
)
throw
new
AssertionError
(
"Unexpected MyKindOfException"
);
checkSuppressedExceptions
(
e
.
getSuppressed
Exceptions
(),
bitMap
);
checkSuppressedExceptions
(
e
.
getSuppressed
(),
bitMap
);
}
catch
(
Resource
.
CloseFailException
e
)
{
if
(
failure
==
1
)
throw
new
AssertionError
(
"Secondary exception suppression failed"
);
...
...
@@ -598,7 +598,7 @@ public class TwrTests {
throw
new
AssertionError
(
"CloseFailException: got id "
+
id
+
", expected lg("
+
highestCloseFailBit
+
")"
);
}
checkSuppressedExceptions
(
e
.
getSuppressed
Exceptions
(),
bitMap
&
~
highestCloseFailBit
);
checkSuppressedExceptions
(
e
.
getSuppressed
(),
bitMap
&
~
highestCloseFailBit
);
}
checkClosedList
(
closedList
,
4
);
}
...
...
@@ -621,7 +621,7 @@ public class TwrTests {
}
catch
(
MyKindOfException
e
)
{
if
(
failure
==
0
)
throw
new
AssertionError
(
"Unexpected MyKindOfException"
);
checkSuppressedExceptions
(
e
.
getSuppressed
Exceptions
(),
bitMap
);
checkSuppressedExceptions
(
e
.
getSuppressed
(),
bitMap
);
}
catch
(
Resource
.
CloseFailException
e
)
{
if
(
failure
==
1
)
throw
new
AssertionError
(
"Secondary exception suppression failed"
);
...
...
@@ -633,7 +633,7 @@ public class TwrTests {
throw
new
AssertionError
(
"CloseFailException: got id "
+
id
+
", expected lg("
+
highestCloseFailBit
+
")"
);
}
checkSuppressedExceptions
(
e
.
getSuppressed
Exceptions
(),
bitMap
&
~
highestCloseFailBit
);
checkSuppressedExceptions
(
e
.
getSuppressed
(),
bitMap
&
~
highestCloseFailBit
);
}
checkClosedList
(
closedList
,
5
);
}
...
...
@@ -660,7 +660,7 @@ public class TwrTests {
}
catch
(
MyKindOfException
e
)
{
if
(
failure
==
0
)
throw
new
AssertionError
(
"Unexpected MyKindOfException"
);
checkSuppressedExceptions
(
e
.
getSuppressed
Exceptions
(),
bitMap
);
checkSuppressedExceptions
(
e
.
getSuppressed
(),
bitMap
);
}
catch
(
Resource
.
CloseFailException
e
)
{
if
(
failure
==
1
)
throw
new
AssertionError
(
"Secondary exception suppression failed"
);
...
...
@@ -672,7 +672,7 @@ public class TwrTests {
throw
new
AssertionError
(
"CloseFailException: got id "
+
id
+
", expected lg("
+
highestCloseFailBit
+
")"
);
}
checkSuppressedExceptions
(
e
.
getSuppressed
Exceptions
(),
bitMap
&
~
highestCloseFailBit
);
checkSuppressedExceptions
(
e
.
getSuppressed
(),
bitMap
&
~
highestCloseFailBit
);
}
checkClosedList
(
closedList
,
5
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录