Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_langtools
提交
bb002ca5
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看板
提交
bb002ca5
编写于
1月 23, 2014
作者:
J
jfranck
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8029017: ElementType.TYPE_USE should be a logical superset of ElementType.TYPE and ANNOTATION_TYPE
Reviewed-by: abuckley, jlahoda, vromero
上级
f8d420eb
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
258 addition
and
6 deletion
+258
-6
src/share/classes/com/sun/tools/javac/comp/Check.java
src/share/classes/com/sun/tools/javac/comp/Check.java
+12
-4
test/tools/javac/annotations/repeatingAnnotations/8029017/TypeUseTarget.java
...notations/repeatingAnnotations/8029017/TypeUseTarget.java
+129
-0
test/tools/javac/annotations/repeatingAnnotations/8029017/TypeUseTargetNeg.java
...ations/repeatingAnnotations/8029017/TypeUseTargetNeg.java
+100
-0
test/tools/javac/annotations/repeatingAnnotations/8029017/TypeUseTargetNeg.out
...tations/repeatingAnnotations/8029017/TypeUseTargetNeg.out
+7
-0
test/tools/javac/annotations/repeatingAnnotations/combo/TargetAnnoCombo.java
...notations/repeatingAnnotations/combo/TargetAnnoCombo.java
+10
-2
未找到文件。
src/share/classes/com/sun/tools/javac/comp/Check.java
浏览文件 @
bb002ca5
/*
* Copyright (c) 1999, 201
3
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 201
4
, 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
...
...
@@ -2779,7 +2779,7 @@ public class Check {
validateDocumented
(
t
.
tsym
,
s
,
pos
);
validateInherited
(
t
.
tsym
,
s
,
pos
);
validateTarget
(
t
.
tsym
,
s
,
pos
);
validateDefault
(
t
.
tsym
,
s
,
pos
);
validateDefault
(
t
.
tsym
,
pos
);
}
private
void
validateValue
(
TypeSymbol
container
,
TypeSymbol
contained
,
DiagnosticPosition
pos
)
{
...
...
@@ -2898,7 +2898,9 @@ public class Check {
/** Checks that s is a subset of t, with respect to ElementType
* semantics, specifically {ANNOTATION_TYPE} is a subset of {TYPE}
* semantics, specifically {ANNOTATION_TYPE} is a subset of {TYPE},
* and {TYPE_USE} covers the set {ANNOTATION_TYPE, TYPE, TYPE_USE,
* TYPE_PARAMETER}.
*/
private
boolean
isTargetSubsetOf
(
Set
<
Name
>
s
,
Set
<
Name
>
t
)
{
// Check that all elements in s are present in t
...
...
@@ -2911,6 +2913,12 @@ public class Check {
}
else
if
(
n1
==
names
.
TYPE
&&
n2
==
names
.
ANNOTATION_TYPE
)
{
currentElementOk
=
true
;
break
;
}
else
if
(
n1
==
names
.
TYPE_USE
&&
(
n2
==
names
.
TYPE
||
n2
==
names
.
ANNOTATION_TYPE
||
n2
==
names
.
TYPE_PARAMETER
))
{
currentElementOk
=
true
;
break
;
}
}
if
(!
currentElementOk
)
...
...
@@ -2919,7 +2927,7 @@ public class Check {
return
true
;
}
private
void
validateDefault
(
Symbol
container
,
Symbol
contained
,
DiagnosticPosition
pos
)
{
private
void
validateDefault
(
Symbol
container
,
DiagnosticPosition
pos
)
{
// validate that all other elements of containing type has defaults
Scope
scope
=
container
.
members
();
for
(
Symbol
elm
:
scope
.
getElements
())
{
...
...
test/tools/javac/annotations/repeatingAnnotations/8029017/TypeUseTarget.java
0 → 100644
浏览文件 @
bb002ca5
/*
* Copyright (c) 2014, 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.
*/
/**
* @test
* @bug 8029017
* @summary sanity testing of ElementType validation for repeating annotations
* @compile TypeUseTarget.java
*/
import
java.lang.annotation.*
;
public
class
TypeUseTarget
{}
// Case 1:
@Target
({
ElementType
.
TYPE_USE
,
})
@Repeatable
(
Case1Container
.
class
)
@interface
Case1
{}
@Target
({
ElementType
.
ANNOTATION_TYPE
,
ElementType
.
TYPE
,
ElementType
.
TYPE_USE
,
ElementType
.
TYPE_PARAMETER
,
})
@interface
Case1Container
{
Case1
[]
value
();
}
// Case 2:
@Target
({
ElementType
.
TYPE_USE
,
})
@Repeatable
(
Case2Container
.
class
)
@interface
Case2
{}
@Target
({
ElementType
.
ANNOTATION_TYPE
,
ElementType
.
TYPE
,
ElementType
.
TYPE_USE
,
})
@interface
Case2Container
{
Case2
[]
value
();
}
// Case 3:
@Target
({
ElementType
.
TYPE_USE
,
})
@Repeatable
(
Case3Container
.
class
)
@interface
Case3
{}
@Target
({
ElementType
.
ANNOTATION_TYPE
,
ElementType
.
TYPE
,
})
@interface
Case3Container
{
Case3
[]
value
();
}
// Case 4:
@Target
({
ElementType
.
TYPE_USE
,
})
@Repeatable
(
Case4Container
.
class
)
@interface
Case4
{}
@Target
({
ElementType
.
ANNOTATION_TYPE
,
})
@interface
Case4Container
{
Case4
[]
value
();
}
// Case 5:
@Target
({
ElementType
.
TYPE_USE
,
})
@Repeatable
(
Case5Container
.
class
)
@interface
Case5
{}
@Target
({
ElementType
.
TYPE
,
})
@interface
Case5Container
{
Case5
[]
value
();
}
// Case 6:
@Target
({
ElementType
.
TYPE_USE
,
})
@Repeatable
(
Case6Container
.
class
)
@interface
Case6
{}
@Target
({
ElementType
.
TYPE_PARAMETER
,
})
@interface
Case6Container
{
Case6
[]
value
();
}
test/tools/javac/annotations/repeatingAnnotations/8029017/TypeUseTargetNeg.java
0 → 100644
浏览文件 @
bb002ca5
/**
* @test /nodynamiccopyright/
* @bug 8029017
* @summary sanity testing of ElementType validation for repeating annotations
* @compile/fail/ref=TypeUseTargetNeg.out -XDrawDiagnostics TypeUseTargetNeg.java
*/
import
java.lang.annotation.*
;
public
class
TypeUseTargetNeg
{}
// Case 1:
@Target
({
ElementType
.
TYPE_USE
,
})
@Repeatable
(
FooContainer
.
class
)
@interface
Foo
{}
@Target
({
ElementType
.
ANNOTATION_TYPE
,
ElementType
.
TYPE
,
ElementType
.
TYPE_USE
,
ElementType
.
TYPE_PARAMETER
,
ElementType
.
FIELD
,
})
@interface
FooContainer
{
Foo
[]
value
();
}
// Case 2:
@Target
({
ElementType
.
TYPE_USE
,
})
@Repeatable
(
BarContainer
.
class
)
@interface
Bar
{}
@Target
({
ElementType
.
ANNOTATION_TYPE
,
ElementType
.
TYPE
,
ElementType
.
TYPE_USE
,
ElementType
.
METHOD
,
})
@interface
BarContainer
{
Bar
[]
value
();
}
// Case 3:
@Target
({
ElementType
.
TYPE_USE
,
})
@Repeatable
(
BazContainer
.
class
)
@interface
Baz
{}
@Target
({
ElementType
.
ANNOTATION_TYPE
,
ElementType
.
TYPE
,
ElementType
.
PARAMETER
,
})
@interface
BazContainer
{
Baz
[]
value
();
}
// Case 4:
@Target
({
ElementType
.
TYPE_USE
,
})
@Repeatable
(
QuxContainer
.
class
)
@interface
Qux
{}
@interface
QuxContainer
{
Qux
[]
value
();
}
// Case 5:
@Target
({})
@Repeatable
(
QuuxContainer
.
class
)
@interface
Quux
{}
@Target
({
ElementType
.
TYPE_PARAMETER
,
})
@interface
QuuxContainer
{
Quux
[]
value
();
}
// Case 6:
@Repeatable
(
QuuuxContainer
.
class
)
@interface
Quuux
{}
@Target
({
ElementType
.
TYPE_USE
,
})
@interface
QuuuxContainer
{
Quuux
[]
value
();
}
test/tools/javac/annotations/repeatingAnnotations/8029017/TypeUseTargetNeg.out
0 → 100644
浏览文件 @
bb002ca5
TypeUseTargetNeg.java:16:1: compiler.err.invalid.repeatable.annotation.incompatible.target: FooContainer, Foo
TypeUseTargetNeg.java:36:1: compiler.err.invalid.repeatable.annotation.incompatible.target: BarContainer, Bar
TypeUseTargetNeg.java:54:1: compiler.err.invalid.repeatable.annotation.incompatible.target: BazContainer, Baz
TypeUseTargetNeg.java:71:1: compiler.err.invalid.repeatable.annotation.incompatible.target: QuxContainer, Qux
TypeUseTargetNeg.java:81:1: compiler.err.invalid.repeatable.annotation.incompatible.target: QuuxContainer, Quux
TypeUseTargetNeg.java:92:1: compiler.err.invalid.repeatable.annotation.incompatible.target: QuuuxContainer, Quuux
6 errors
test/tools/javac/annotations/repeatingAnnotations/combo/TargetAnnoCombo.java
浏览文件 @
bb002ca5
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013,
2014,
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
...
...
@@ -23,7 +23,7 @@
/*
* @test
* @bug 7151010 8006547 8007766
* @bug 7151010 8006547 8007766
8029017
* @summary Default test cases for running combinations for Target values
* @build Helper
* @run main TargetAnnoCombo
...
...
@@ -145,11 +145,19 @@ public class TargetAnnoCombo {
Set
<
ElementType
>
tempBaseSet
=
EnumSet
.
noneOf
(
ElementType
.
class
);
tempBaseSet
.
addAll
(
baseAnnotations
);
// If BaseAnno has TYPE, then ANNOTATION_TYPE is allowed by default.
if
(
baseAnnotations
.
contains
(
TYPE
))
{
tempBaseSet
.
add
(
ANNOTATION_TYPE
);
}
// If BaseAnno has TYPE_USE, then add the extra allowed types
if
(
baseAnnotations
.
contains
(
TYPE_USE
))
{
tempBaseSet
.
add
(
ANNOTATION_TYPE
);
tempBaseSet
.
add
(
TYPE
);
tempBaseSet
.
add
(
TYPE_PARAMETER
);
}
// If containerAnno has no @Target, only valid case if baseAnnoTarget has
// all targets defined else invalid set.
if
(
containerAnnotations
==
null
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录