Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_langtools
提交
94c7cff1
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看板
提交
94c7cff1
编写于
8月 22, 2013
作者:
V
vromero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8022316: Generic throws, overriding and method reference
Reviewed-by: jjg, mcimadamore
上级
2024118a
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
99 addition
and
4 deletion
+99
-4
src/share/classes/com/sun/tools/javac/code/Types.java
src/share/classes/com/sun/tools/javac/code/Types.java
+19
-4
test/tools/javac/T8022316/CompilerErrorGenericThrowPlusMethodRefTest.java
.../T8022316/CompilerErrorGenericThrowPlusMethodRefTest.java
+78
-0
test/tools/javac/T8022316/CompilerErrorGenericThrowPlusMethodRefTest.out
...c/T8022316/CompilerErrorGenericThrowPlusMethodRefTest.out
+2
-0
未找到文件。
src/share/classes/com/sun/tools/javac/code/Types.java
浏览文件 @
94c7cff1
...
...
@@ -505,12 +505,27 @@ public class Types {
//merge thrown types - form the intersection of all the thrown types in
//all the signatures in the list
boolean
toErase
=
!
bestSoFar
.
type
.
hasTag
(
FORALL
);
List
<
Type
>
thrown
=
null
;
for
(
Symbol
msym1
:
methodSyms
)
{
Type
mt1
=
memberType
(
origin
.
type
,
msym1
);
Type
mt1
=
memberType
(
origin
.
type
,
bestSoFar
);
for
(
Symbol
msym2
:
methodSyms
)
{
Type
mt2
=
memberType
(
origin
.
type
,
msym2
);
List
<
Type
>
thrown_mt2
=
mt2
.
getThrownTypes
();
if
(
toErase
)
{
thrown_mt2
=
erasure
(
thrown_mt2
);
}
else
{
/* If bestSoFar is generic then all the methods are generic.
* The opposite is not true: a non generic method can override
* a generic method (raw override) so it's safe to cast mt1 and
* mt2 to ForAll.
*/
ForAll
fa1
=
(
ForAll
)
mt1
;
ForAll
fa2
=
(
ForAll
)
mt2
;
thrown_mt2
=
subst
(
thrown_mt2
,
fa2
.
tvars
,
fa1
.
tvars
);
}
thrown
=
(
thrown
==
null
)
?
mt1
.
getThrownTypes
()
:
chk
.
intersect
(
mt1
.
getThrownTypes
()
,
thrown
);
thrown_mt2
:
chk
.
intersect
(
thrown_mt2
,
thrown
);
}
final
List
<
Type
>
thrown1
=
thrown
;
...
...
test/tools/javac/T8022316/CompilerErrorGenericThrowPlusMethodRefTest.java
0 → 100644
浏览文件 @
94c7cff1
/*
* 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.
*/
/*
* @test
* @bug 8022316
* @summary Generic throws, overriding and method reference
* @compile/fail/ref=CompilerErrorGenericThrowPlusMethodRefTest.out -XDrawDiagnostics CompilerErrorGenericThrowPlusMethodRefTest.java
*/
@SuppressWarnings
(
"unchecked"
)
public
class
CompilerErrorGenericThrowPlusMethodRefTest
{
interface
SAM11
{
public
<
E
extends
Throwable
>
void
foo
()
throws
E
;
}
interface
SAM12
extends
SAM11
{
@Override
public
void
foo
()
throws
Throwable
;
}
public
void
boo
()
throws
RuntimeException
{}
static
void
test1
()
{
try
{
SAM12
s2
=
new
CompilerErrorGenericThrowPlusMethodRefTest
()::
boo
;
s2
.
foo
();
}
catch
(
Throwable
ex
)
{}
}
static
void
test2
()
{
SAM11
s1
=
null
;
s1
.<
Exception
>
foo
();
s1
.<
RuntimeException
>
foo
();
}
interface
SAM21
{
<
E
extends
Exception
>
void
m
(
E
arg
)
throws
E
;
}
interface
SAM22
{
<
F
extends
Exception
>
void
m
(
F
arg
)
throws
F
;
}
interface
SAM23
extends
SAM21
,
SAM22
{}
public
<
E
extends
Exception
>
void
bar
(
E
e
)
throws
E
{}
static
<
E
extends
Exception
>
void
test3
(
E
e
)
{
try
{
SAM23
s2
=
new
CompilerErrorGenericThrowPlusMethodRefTest
()::
bar
;
s2
.
m
(
e
);
}
catch
(
Exception
ex
)
{}
}
}
test/tools/javac/T8022316/CompilerErrorGenericThrowPlusMethodRefTest.out
0 → 100644
浏览文件 @
94c7cff1
CompilerErrorGenericThrowPlusMethodRefTest.java:55:26: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Exception
1 error
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录