Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_langtools
提交
d2f83671
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看板
提交
d2f83671
编写于
1月 14, 2013
作者:
J
jjg
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8006119: update javac to follow latest spec for repeatable annotations
Reviewed-by: darcy
上级
a9b3c8d3
变更
71
隐藏空白更改
内联
并排
Showing
71 changed file
with
242 addition
and
674 deletion
+242
-674
src/share/classes/com/sun/tools/javac/code/Annotations.java
src/share/classes/com/sun/tools/javac/code/Annotations.java
+4
-4
src/share/classes/com/sun/tools/javac/code/Symtab.java
src/share/classes/com/sun/tools/javac/code/Symtab.java
+3
-5
src/share/classes/com/sun/tools/javac/comp/Annotate.java
src/share/classes/com/sun/tools/javac/comp/Annotate.java
+16
-19
src/share/classes/com/sun/tools/javac/comp/Attr.java
src/share/classes/com/sun/tools/javac/comp/Attr.java
+7
-17
src/share/classes/com/sun/tools/javac/comp/Check.java
src/share/classes/com/sun/tools/javac/comp/Check.java
+26
-87
src/share/classes/com/sun/tools/javac/model/JavacElements.java
...hare/classes/com/sun/tools/javac/model/JavacElements.java
+13
-13
src/share/classes/com/sun/tools/javac/resources/compiler.properties
...classes/com/sun/tools/javac/resources/compiler.properties
+16
-32
test/com/sun/javadoc/testRepeatedAnnotations/pkg/ContaineeSynthDoc.java
...avadoc/testRepeatedAnnotations/pkg/ContaineeSynthDoc.java
+2
-2
test/com/sun/javadoc/testRepeatedAnnotations/pkg/ContainerSynthDoc.java
...avadoc/testRepeatedAnnotations/pkg/ContainerSynthDoc.java
+1
-2
test/com/sun/javadoc/testRepeatedAnnotations/pkg1/ContaineeSynthDoc.java
...vadoc/testRepeatedAnnotations/pkg1/ContaineeSynthDoc.java
+2
-2
test/com/sun/javadoc/testRepeatedAnnotations/pkg1/ContainerSynthNotDoc.java
...oc/testRepeatedAnnotations/pkg1/ContainerSynthNotDoc.java
+1
-2
test/tools/javac/annotations/repeatingAnnotations/BaseAnnoAsContainerAnno.java
...tations/repeatingAnnotations/BaseAnnoAsContainerAnno.java
+2
-4
test/tools/javac/annotations/repeatingAnnotations/BaseAnnoAsContainerAnno.out
...otations/repeatingAnnotations/BaseAnnoAsContainerAnno.out
+1
-1
test/tools/javac/annotations/repeatingAnnotations/BasicRepeatingAnnotations.java
...tions/repeatingAnnotations/BasicRepeatingAnnotations.java
+2
-3
test/tools/javac/annotations/repeatingAnnotations/CheckTargets.java
.../javac/annotations/repeatingAnnotations/CheckTargets.java
+4
-7
test/tools/javac/annotations/repeatingAnnotations/ClassReaderDefault.java
.../annotations/repeatingAnnotations/ClassReaderDefault.java
+3
-5
test/tools/javac/annotations/repeatingAnnotations/ContainerHasRepeatedContained.java
...s/repeatingAnnotations/ContainerHasRepeatedContained.java
+3
-5
test/tools/javac/annotations/repeatingAnnotations/CyclicAnnotation.java
...ac/annotations/repeatingAnnotations/CyclicAnnotation.java
+3
-6
test/tools/javac/annotations/repeatingAnnotations/CyclicAnnotation.out
...vac/annotations/repeatingAnnotations/CyclicAnnotation.out
+2
-6
test/tools/javac/annotations/repeatingAnnotations/DefaultCasePresent.java
.../annotations/repeatingAnnotations/DefaultCasePresent.java
+3
-5
test/tools/javac/annotations/repeatingAnnotations/DelayRepeatedContainer.java
...otations/repeatingAnnotations/DelayRepeatedContainer.java
+2
-3
test/tools/javac/annotations/repeatingAnnotations/DocumentedContainerAnno.java
...tations/repeatingAnnotations/DocumentedContainerAnno.java
+2
-4
test/tools/javac/annotations/repeatingAnnotations/DocumentedContainerAnno.out
...otations/repeatingAnnotations/DocumentedContainerAnno.out
+1
-1
test/tools/javac/annotations/repeatingAnnotations/InheritedContainerAnno.java
...otations/repeatingAnnotations/InheritedContainerAnno.java
+2
-4
test/tools/javac/annotations/repeatingAnnotations/InheritedContainerAnno.out
...notations/repeatingAnnotations/InheritedContainerAnno.out
+1
-1
test/tools/javac/annotations/repeatingAnnotations/InvalidTarget.java
...javac/annotations/repeatingAnnotations/InvalidTarget.java
+2
-3
test/tools/javac/annotations/repeatingAnnotations/MissingContainer.java
...ac/annotations/repeatingAnnotations/MissingContainer.java
+2
-4
test/tools/javac/annotations/repeatingAnnotations/MissingContainer.out
...vac/annotations/repeatingAnnotations/MissingContainer.out
+4
-5
test/tools/javac/annotations/repeatingAnnotations/MissingContainerFor.java
...annotations/repeatingAnnotations/MissingContainerFor.java
+0
-38
test/tools/javac/annotations/repeatingAnnotations/MissingDefaultCase1.java
...annotations/repeatingAnnotations/MissingDefaultCase1.java
+2
-4
test/tools/javac/annotations/repeatingAnnotations/MissingDefaultCase1.out
.../annotations/repeatingAnnotations/MissingDefaultCase1.out
+2
-2
test/tools/javac/annotations/repeatingAnnotations/MissingDefaultCase2.java
...annotations/repeatingAnnotations/MissingDefaultCase2.java
+2
-4
test/tools/javac/annotations/repeatingAnnotations/MissingDefaultCase2.out
.../annotations/repeatingAnnotations/MissingDefaultCase2.out
+2
-2
test/tools/javac/annotations/repeatingAnnotations/MissingValueMethod.java
.../annotations/repeatingAnnotations/MissingValueMethod.java
+2
-4
test/tools/javac/annotations/repeatingAnnotations/MissingValueMethod.out
...c/annotations/repeatingAnnotations/MissingValueMethod.out
+3
-3
test/tools/javac/annotations/repeatingAnnotations/MultiLevelRepeatableAnno.java
...ations/repeatingAnnotations/MultiLevelRepeatableAnno.java
+4
-7
test/tools/javac/annotations/repeatingAnnotations/MultipleAnnoMixedOrder.java
...otations/repeatingAnnotations/MultipleAnnoMixedOrder.java
+4
-7
test/tools/javac/annotations/repeatingAnnotations/NestedContainers.java
...ac/annotations/repeatingAnnotations/NestedContainers.java
+3
-5
test/tools/javac/annotations/repeatingAnnotations/NoRepeatableAnno.out
...vac/annotations/repeatingAnnotations/NoRepeatableAnno.out
+2
-2
test/tools/javac/annotations/repeatingAnnotations/RepMemberAnno.java
...javac/annotations/repeatingAnnotations/RepMemberAnno.java
+3
-5
test/tools/javac/annotations/repeatingAnnotations/RepSelfMemberAnno.java
...c/annotations/repeatingAnnotations/RepSelfMemberAnno.java
+3
-5
test/tools/javac/annotations/repeatingAnnotations/RepeatingAndContainerPresent.java
...ns/repeatingAnnotations/RepeatingAndContainerPresent.java
+2
-2
test/tools/javac/annotations/repeatingAnnotations/RepeatingTargetNotAllowed.java
...tions/repeatingAnnotations/RepeatingTargetNotAllowed.java
+2
-3
test/tools/javac/annotations/repeatingAnnotations/RepeatingTargetNotAllowed.out
...ations/repeatingAnnotations/RepeatingTargetNotAllowed.out
+1
-1
test/tools/javac/annotations/repeatingAnnotations/SelfRepeatingAnnotations.java
...ations/repeatingAnnotations/SelfRepeatingAnnotations.java
+2
-3
test/tools/javac/annotations/repeatingAnnotations/SingleRepeatingAndContainer.java
...ons/repeatingAnnotations/SingleRepeatingAndContainer.java
+2
-3
test/tools/javac/annotations/repeatingAnnotations/UseWrongContainedBy.java
...annotations/repeatingAnnotations/UseWrongContainedBy.java
+0
-42
test/tools/javac/annotations/repeatingAnnotations/UseWrongContainerFor.java
...nnotations/repeatingAnnotations/UseWrongContainerFor.java
+0
-42
test/tools/javac/annotations/repeatingAnnotations/UseWrongRepeatable.java
.../annotations/repeatingAnnotations/UseWrongRepeatable.java
+8
-6
test/tools/javac/annotations/repeatingAnnotations/WrongContainedBy.java
...ac/annotations/repeatingAnnotations/WrongContainedBy.java
+0
-39
test/tools/javac/annotations/repeatingAnnotations/WrongContainerFor.java
...c/annotations/repeatingAnnotations/WrongContainerFor.java
+0
-39
test/tools/javac/annotations/repeatingAnnotations/WrongReturnTypeForValue.java
...tations/repeatingAnnotations/WrongReturnTypeForValue.java
+2
-4
test/tools/javac/annotations/repeatingAnnotations/WrongReturnTypeForValue.out
...otations/repeatingAnnotations/WrongReturnTypeForValue.out
+4
-3
test/tools/javac/annotations/repeatingAnnotations/combo/BasicSyntaxCombo.java
...otations/repeatingAnnotations/combo/BasicSyntaxCombo.java
+2
-3
test/tools/javac/annotations/repeatingAnnotations/combo/DeprecatedAnnoCombo.java
...tions/repeatingAnnotations/combo/DeprecatedAnnoCombo.java
+5
-8
test/tools/javac/annotations/repeatingAnnotations/combo/DocumentedAnnoCombo.java
...tions/repeatingAnnotations/combo/DocumentedAnnoCombo.java
+3
-5
test/tools/javac/annotations/repeatingAnnotations/combo/Helper.java
.../javac/annotations/repeatingAnnotations/combo/Helper.java
+3
-5
test/tools/javac/annotations/repeatingAnnotations/combo/InheritedAnnoCombo.java
...ations/repeatingAnnotations/combo/InheritedAnnoCombo.java
+3
-5
test/tools/javac/annotations/repeatingAnnotations/combo/RetentionAnnoCombo.java
...ations/repeatingAnnotations/combo/RetentionAnnoCombo.java
+3
-4
test/tools/javac/diags/examples.not-yet.txt
test/tools/javac/diags/examples.not-yet.txt
+3
-3
test/tools/javac/diags/examples/InvalidDuplicateAnnotation.java
...ools/javac/diags/examples/InvalidDuplicateAnnotation.java
+4
-5
test/tools/javac/diags/examples/RepeatableDocumentedMismatch.java
...ls/javac/diags/examples/RepeatableDocumentedMismatch.java
+4
-5
test/tools/javac/diags/examples/RepeatableInheritedMismatch.java
...ols/javac/diags/examples/RepeatableInheritedMismatch.java
+4
-5
test/tools/javac/diags/examples/RepeatableNoValue.java
test/tools/javac/diags/examples/RepeatableNoValue.java
+4
-5
test/tools/javac/diags/examples/RepeatableNonDefault.java
test/tools/javac/diags/examples/RepeatableNonDefault.java
+4
-5
test/tools/javac/diags/examples/RepeatableRetentionMismatch.java
...ols/javac/diags/examples/RepeatableRetentionMismatch.java
+4
-5
test/tools/javac/diags/examples/RepeatableTargetMismatch.java
.../tools/javac/diags/examples/RepeatableTargetMismatch.java
+4
-5
test/tools/javac/diags/examples/RepeatableWrongValueType.java
.../tools/javac/diags/examples/RepeatableWrongValueType.java
+4
-5
test/tools/javac/diags/examples/RepeatingAnnotationAndContainer.java
...javac/diags/examples/RepeatingAnnotationAndContainer.java
+3
-4
test/tools/javac/diags/examples/WrongContainedBy.java
test/tools/javac/diags/examples/WrongContainedBy.java
+0
-35
test/tools/javac/diags/examples/WrongContainerFor.java
test/tools/javac/diags/examples/WrongContainerFor.java
+0
-35
未找到文件。
src/share/classes/com/sun/tools/javac/code/Annotations.java
浏览文件 @
d2f83671
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012,
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
...
...
@@ -126,12 +126,12 @@ public class Annotations {
//
// We need to do this in two passes because when creating
// a container for a repeating annotation we must
// guarantee that the @
ContainedBy
on the
// guarantee that the @
Repeatable
on the
// contained annotation is fully annotated
//
// The way we force this order is to do all repeating
// annotations in a pass after all non-repeating are
// finished. This will work because @
ContainedBy
// finished. This will work because @
Repeatable
// is non-repeating and therefore will be annotated in the
// fist pass.
...
...
@@ -261,7 +261,7 @@ public class Annotations {
// its contained annotation.
ListBuffer
<
Attribute
.
Compound
>
manualContainer
=
ctx
.
annotated
.
get
(
validRepeated
.
type
.
tsym
);
if
(
manualContainer
!=
null
)
{
log
.
error
(
ctx
.
pos
.
get
(
manualContainer
.
first
()),
"invalid.
containedby
.annotation.repeated.and.container.present"
,
log
.
error
(
ctx
.
pos
.
get
(
manualContainer
.
first
()),
"invalid.
repeatable
.annotation.repeated.and.container.present"
,
manualContainer
.
first
().
type
.
tsym
);
}
}
...
...
src/share/classes/com/sun/tools/javac/code/Symtab.java
浏览文件 @
d2f83671
/*
* Copyright (c) 1999, 201
2
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 201
3
, 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
...
...
@@ -161,8 +161,7 @@ public class Symtab {
public
final
Type
autoCloseableType
;
public
final
Type
trustMeType
;
public
final
Type
lambdaMetafactory
;
public
final
Type
containedByType
;
public
final
Type
containerForType
;
public
final
Type
repeatableType
;
public
final
Type
documentedType
;
public
final
Type
elementTypeType
;
...
...
@@ -494,8 +493,7 @@ public class Symtab {
deprecatedType
=
enterClass
(
"java.lang.Deprecated"
);
suppressWarningsType
=
enterClass
(
"java.lang.SuppressWarnings"
);
inheritedType
=
enterClass
(
"java.lang.annotation.Inherited"
);
containedByType
=
enterClass
(
"java.lang.annotation.ContainedBy"
);
containerForType
=
enterClass
(
"java.lang.annotation.ContainerFor"
);
repeatableType
=
enterClass
(
"java.lang.annotation.Repeatable"
);
documentedType
=
enterClass
(
"java.lang.annotation.Documented"
);
elementTypeType
=
enterClass
(
"java.lang.annotation.ElementType"
);
systemType
=
enterClass
(
"java.lang.System"
);
...
...
src/share/classes/com/sun/tools/javac/comp/Annotate.java
浏览文件 @
d2f83671
/*
* Copyright (c) 2003, 201
2
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 201
3
, 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
...
...
@@ -392,7 +392,7 @@ public class Annotate {
List
.
of
(
p
)));
if
(!
chk
.
annotationApplicable
(
annoTree
,
on
))
log
.
error
(
annoTree
.
pos
(),
"invalid.
containedby
.annotation.incompatible.target"
,
targetContainerType
,
origAnnoType
);
log
.
error
(
annoTree
.
pos
(),
"invalid.
repeatable
.annotation.incompatible.target"
,
targetContainerType
,
origAnnoType
);
if
(!
chk
.
validateAnnotationDeferErrors
(
annoTree
))
log
.
error
(
annoTree
.
pos
(),
"duplicate.annotation.invalid.repeated"
,
origAnnoType
);
...
...
@@ -414,11 +414,11 @@ public class Annotate {
Type
origAnnoType
=
currentAnno
.
type
;
TypeSymbol
origAnnoDecl
=
origAnnoType
.
tsym
;
// Fetch the
ContainedBy
annotation from the current
// Fetch the
Repeatable
annotation from the current
// annotation's declaration, or null if it has none
Attribute
.
Compound
ca
=
origAnnoDecl
.
attribute
(
syms
.
containedBy
Type
.
tsym
);
if
(
ca
==
null
)
{
// has no
ContainedBy
annotation
log
.
error
(
pos
,
"duplicate.annotation.missing.container"
,
origAnnoType
,
syms
.
containedBy
Type
);
Attribute
.
Compound
ca
=
origAnnoDecl
.
attribute
(
syms
.
repeatable
Type
.
tsym
);
if
(
ca
==
null
)
{
// has no
Repeatable
annotation
log
.
error
(
pos
,
"duplicate.annotation.missing.container"
,
origAnnoType
,
syms
.
repeatable
Type
);
return
null
;
}
...
...
@@ -440,23 +440,23 @@ public class Annotate {
DiagnosticPosition
pos
,
TypeSymbol
annoDecl
)
{
// The next three checks check that the
ContainedBy
annotation
// The next three checks check that the
Repeatable
annotation
// on the declaration of the annotation type that is repeating is
// valid.
//
ContainedBy
must have at least one element
//
Repeatable
must have at least one element
if
(
ca
.
values
.
isEmpty
())
{
log
.
error
(
pos
,
"invalid.
containedby
.annotation"
,
annoDecl
);
log
.
error
(
pos
,
"invalid.
repeatable
.annotation"
,
annoDecl
);
return
null
;
}
Pair
<
MethodSymbol
,
Attribute
>
p
=
ca
.
values
.
head
;
Name
name
=
p
.
fst
.
name
;
if
(
name
!=
names
.
value
)
{
// should contain only one element, named "value"
log
.
error
(
pos
,
"invalid.
containedby
.annotation"
,
annoDecl
);
log
.
error
(
pos
,
"invalid.
repeatable
.annotation"
,
annoDecl
);
return
null
;
}
if
(!(
p
.
snd
instanceof
Attribute
.
Class
))
{
// check that the value of "value" is an Attribute.Class
log
.
error
(
pos
,
"invalid.
containedby
.annotation"
,
annoDecl
);
log
.
error
(
pos
,
"invalid.
repeatable
.annotation"
,
annoDecl
);
return
null
;
}
...
...
@@ -491,13 +491,13 @@ public class Annotate {
}
if
(
error
)
{
log
.
error
(
pos
,
"invalid.
containedby
.annotation.multiple.values"
,
"invalid.
repeatable
.annotation.multiple.values"
,
targetContainerType
,
nr_value_elems
);
return
null
;
}
else
if
(
nr_value_elems
==
0
)
{
log
.
error
(
pos
,
"invalid.
containedby
.annotation.no.value"
,
"invalid.
repeatable
.annotation.no.value"
,
targetContainerType
);
return
null
;
}
...
...
@@ -506,7 +506,7 @@ public class Annotate {
// probably "impossible" to fail this
if
(
containerValueSymbol
.
kind
!=
Kinds
.
MTH
)
{
log
.
error
(
pos
,
"invalid.
containedby
.annotation.invalid.value"
,
"invalid.
repeatable
.annotation.invalid.value"
,
targetContainerType
);
fatalError
=
true
;
}
...
...
@@ -518,7 +518,7 @@ public class Annotate {
if
(!(
types
.
isArray
(
valueRetType
)
&&
types
.
isSameType
(
expectedType
,
valueRetType
)))
{
log
.
error
(
pos
,
"invalid.
containedby
.annotation.value.return"
,
"invalid.
repeatable
.annotation.value.return"
,
targetContainerType
,
valueRetType
,
expectedType
);
...
...
@@ -528,10 +528,7 @@ public class Annotate {
fatalError
=
true
;
}
// Explicitly no check for/validity of @ContainerFor. That is
// done on declaration of the container, and at reflect time.
// The rest of the conditions for a valid containing annotation are made
// The conditions for a valid containing annotation are made
// in Check.validateRepeatedAnnotaton();
return
fatalError
?
null
:
containerValueSymbol
;
...
...
src/share/classes/com/sun/tools/javac/comp/Attr.java
浏览文件 @
d2f83671
/*
* Copyright (c) 1999, 201
2
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 201
3
, 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
...
...
@@ -3844,24 +3844,14 @@ public class Attr extends JCTree.Visitor {
log
.
error
(
tree
.
typarams
.
head
.
pos
(),
"intf.annotation.cant.have.type.params"
);
// If this annotation has a @
ContainedBy
, validate
Attribute
.
Compound
containedBy
=
c
.
attribute
(
syms
.
containedBy
Type
.
tsym
);
if
(
containedBy
!=
null
)
{
// get diagnos
it
c position for error reporting
DiagnosticPosition
cbPos
=
getDiagnosticPosition
(
tree
,
containedBy
.
type
);
// If this annotation has a @
Repeatable
, validate
Attribute
.
Compound
repeatable
=
c
.
attribute
(
syms
.
repeatable
Type
.
tsym
);
if
(
repeatable
!=
null
)
{
// get diagnos
ti
c position for error reporting
DiagnosticPosition
cbPos
=
getDiagnosticPosition
(
tree
,
repeatable
.
type
);
Assert
.
checkNonNull
(
cbPos
);
chk
.
validateContainedBy
(
c
,
containedBy
,
cbPos
);
}
// If this annotation has a @ContainerFor, validate
Attribute
.
Compound
containerFor
=
c
.
attribute
(
syms
.
containerForType
.
tsym
);
if
(
containerFor
!=
null
)
{
// get diagnositc position for error reporting
DiagnosticPosition
cfPos
=
getDiagnosticPosition
(
tree
,
containerFor
.
type
);
Assert
.
checkNonNull
(
cfPos
);
chk
.
validateContainerFor
(
c
,
containerFor
,
cfPos
);
chk
.
validateRepeatable
(
c
,
repeatable
,
cbPos
);
}
}
else
{
// Check that all extended classes and interfaces
...
...
src/share/classes/com/sun/tools/javac/comp/Check.java
浏览文件 @
d2f83671
/*
* Copyright (c) 1999, 201
2
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 201
3
, 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
...
...
@@ -2592,30 +2592,30 @@ public class Check {
}
/**
* Validate the proposed container '
containedBy
' on the
* Validate the proposed container '
repeatable
' on the
* annotation type symbol 's'. Report errors at position
* 'pos'.
*
* @param s The (annotation)type declaration annotated with a @
ContainedBy
* @param
containedBy the @ContainedBy
on 's'
* @param s The (annotation)type declaration annotated with a @
Repeatable
* @param
repeatable the @Repeatable
on 's'
* @param pos where to report errors
*/
public
void
validate
ContainedBy
(
TypeSymbol
s
,
Attribute
.
Compound
containedBy
,
DiagnosticPosition
pos
)
{
Assert
.
check
(
types
.
isSameType
(
containedBy
.
type
,
syms
.
containedBy
Type
));
public
void
validate
Repeatable
(
TypeSymbol
s
,
Attribute
.
Compound
repeatable
,
DiagnosticPosition
pos
)
{
Assert
.
check
(
types
.
isSameType
(
repeatable
.
type
,
syms
.
repeatable
Type
));
Type
t
=
null
;
List
<
Pair
<
MethodSymbol
,
Attribute
>>
l
=
containedBy
.
values
;
List
<
Pair
<
MethodSymbol
,
Attribute
>>
l
=
repeatable
.
values
;
if
(!
l
.
isEmpty
())
{
Assert
.
check
(
l
.
head
.
fst
.
name
==
names
.
value
);
t
=
((
Attribute
.
Class
)
l
.
head
.
snd
).
getValue
();
}
if
(
t
==
null
)
{
log
.
error
(
pos
,
"invalid.container.wrong.containedby"
,
s
,
containedBy
);
// errors should already have been reported during Annotate
return
;
}
validate
HasContainerFor
(
t
.
tsym
,
s
,
pos
);
validate
Value
(
t
.
tsym
,
s
,
pos
);
validateRetention
(
t
.
tsym
,
s
,
pos
);
validateDocumented
(
t
.
tsym
,
s
,
pos
);
validateInherited
(
t
.
tsym
,
s
,
pos
);
...
...
@@ -2623,79 +2623,18 @@ public class Check {
validateDefault
(
t
.
tsym
,
s
,
pos
);
}
/**
* Validate the proposed container 'containerFor' on the
* annotation type symbol 's'. Report errors at position
* 'pos'.
*
* @param s The (annotation)type declaration annotated with a @ContainerFor
* @param containerFor the @ContainedFor on 's'
* @param pos where to report errors
*/
public
void
validateContainerFor
(
TypeSymbol
s
,
Attribute
.
Compound
containerFor
,
DiagnosticPosition
pos
)
{
Assert
.
check
(
types
.
isSameType
(
containerFor
.
type
,
syms
.
containerForType
));
Type
t
=
null
;
List
<
Pair
<
MethodSymbol
,
Attribute
>>
l
=
containerFor
.
values
;
if
(!
l
.
isEmpty
())
{
Assert
.
check
(
l
.
head
.
fst
.
name
==
names
.
value
);
t
=
((
Attribute
.
Class
)
l
.
head
.
snd
).
getValue
();
}
if
(
t
==
null
)
{
log
.
error
(
pos
,
"invalid.container.wrong.containerfor"
,
s
,
containerFor
);
return
;
}
validateHasContainedBy
(
t
.
tsym
,
s
,
pos
);
}
private
void
validateHasContainedBy
(
TypeSymbol
container
,
TypeSymbol
contained
,
DiagnosticPosition
pos
)
{
Attribute
.
Compound
containedBy
=
container
.
attribute
(
syms
.
containedByType
.
tsym
);
if
(
containedBy
==
null
)
{
log
.
error
(
pos
,
"invalid.container.no.containedby"
,
container
,
syms
.
containedByType
.
tsym
);
return
;
}
Type
t
=
null
;
List
<
Pair
<
MethodSymbol
,
Attribute
>>
l
=
containedBy
.
values
;
if
(!
l
.
isEmpty
())
{
Assert
.
check
(
l
.
head
.
fst
.
name
==
names
.
value
);
t
=
((
Attribute
.
Class
)
l
.
head
.
snd
).
getValue
();
}
if
(
t
==
null
)
{
log
.
error
(
pos
,
"invalid.container.wrong.containedby"
,
container
,
contained
);
return
;
}
if
(!
types
.
isSameType
(
t
,
contained
.
type
))
log
.
error
(
pos
,
"invalid.container.wrong.containedby"
,
t
.
tsym
,
contained
);
}
private
void
validateHasContainerFor
(
TypeSymbol
container
,
TypeSymbol
contained
,
DiagnosticPosition
pos
)
{
Attribute
.
Compound
containerFor
=
container
.
attribute
(
syms
.
containerForType
.
tsym
);
if
(
containerFor
==
null
)
{
log
.
error
(
pos
,
"invalid.container.no.containerfor"
,
container
,
syms
.
containerForType
.
tsym
);
return
;
}
Type
t
=
null
;
List
<
Pair
<
MethodSymbol
,
Attribute
>>
l
=
containerFor
.
values
;
if
(!
l
.
isEmpty
())
{
Assert
.
check
(
l
.
head
.
fst
.
name
==
names
.
value
);
t
=
((
Attribute
.
Class
)
l
.
head
.
snd
).
getValue
();
}
if
(
t
==
null
)
{
log
.
error
(
pos
,
"invalid.container.wrong.containerfor"
,
container
,
contained
);
return
;
private
void
validateValue
(
TypeSymbol
container
,
TypeSymbol
contained
,
DiagnosticPosition
pos
)
{
Scope
.
Entry
e
=
container
.
members
().
lookup
(
names
.
value
);
if
(
e
.
scope
!=
null
&&
e
.
sym
.
kind
==
MTH
)
{
MethodSymbol
m
=
(
MethodSymbol
)
e
.
sym
;
Type
ret
=
m
.
getReturnType
();
if
(!(
ret
.
hasTag
(
ARRAY
)
&&
types
.
isSameType
(((
ArrayType
)
ret
).
elemtype
,
contained
.
type
)))
{
log
.
error
(
pos
,
"invalid.repeatable.annotation.value.return"
,
container
,
ret
,
types
.
makeArrayType
(
contained
.
type
));
}
}
else
{
log
.
error
(
pos
,
"invalid.repeatable.annotation.no.value"
,
container
);
}
if
(!
types
.
isSameType
(
t
,
contained
.
type
))
log
.
error
(
pos
,
"invalid.container.wrong.containerfor"
,
t
.
tsym
,
contained
);
}
private
void
validateRetention
(
Symbol
container
,
Symbol
contained
,
DiagnosticPosition
pos
)
{
...
...
@@ -2715,7 +2654,7 @@ public class Check {
}
}
if
(
error
)
{
log
.
error
(
pos
,
"invalid.
containedby
.annotation.retention"
,
log
.
error
(
pos
,
"invalid.
repeatable
.annotation.retention"
,
container
,
containerRetention
,
contained
,
containedRetention
);
}
...
...
@@ -2724,7 +2663,7 @@ public class Check {
private
void
validateDocumented
(
Symbol
container
,
Symbol
contained
,
DiagnosticPosition
pos
)
{
if
(
contained
.
attribute
(
syms
.
documentedType
.
tsym
)
!=
null
)
{
if
(
container
.
attribute
(
syms
.
documentedType
.
tsym
)
==
null
)
{
log
.
error
(
pos
,
"invalid.
containedby
.annotation.not.documented"
,
container
,
contained
);
log
.
error
(
pos
,
"invalid.
repeatable
.annotation.not.documented"
,
container
,
contained
);
}
}
}
...
...
@@ -2732,7 +2671,7 @@ public class Check {
private
void
validateInherited
(
Symbol
container
,
Symbol
contained
,
DiagnosticPosition
pos
)
{
if
(
contained
.
attribute
(
syms
.
inheritedType
.
tsym
)
!=
null
)
{
if
(
container
.
attribute
(
syms
.
inheritedType
.
tsym
)
==
null
)
{
log
.
error
(
pos
,
"invalid.
containedby
.annotation.not.inherited"
,
container
,
contained
);
log
.
error
(
pos
,
"invalid.
repeatable
.annotation.not.inherited"
,
container
,
contained
);
}
}
}
...
...
@@ -2752,7 +2691,7 @@ public class Check {
// contained has target, but container has not, error
Attribute
.
Array
containerTarget
=
getAttributeTargetAttribute
(
container
);
if
(
containerTarget
==
null
)
{
log
.
error
(
pos
,
"invalid.
containedby
.annotation.incompatible.target"
,
container
,
contained
);
log
.
error
(
pos
,
"invalid.
repeatable
.annotation.incompatible.target"
,
container
,
contained
);
return
;
}
...
...
@@ -2775,7 +2714,7 @@ public class Check {
}
if
(!
isTargetSubset
(
containedTargets
,
containerTargets
))
{
log
.
error
(
pos
,
"invalid.
containedby
.annotation.incompatible.target"
,
container
,
contained
);
log
.
error
(
pos
,
"invalid.
repeatable
.annotation.incompatible.target"
,
container
,
contained
);
}
}
...
...
@@ -2809,7 +2748,7 @@ public class Check {
elm
.
kind
==
Kinds
.
MTH
&&
((
MethodSymbol
)
elm
).
defaultValue
==
null
)
{
log
.
error
(
pos
,
"invalid.
containedby
.annotation.elem.nondefault"
,
"invalid.
repeatable
.annotation.elem.nondefault"
,
container
,
elm
);
}
...
...
src/share/classes/com/sun/tools/javac/model/JavacElements.java
浏览文件 @
d2f83671
...
...
@@ -261,13 +261,13 @@ public class JavacElements implements Elements {
}
// Needed to unpack the runtime view of containing annotations
private
static
final
Class
<?
extends
Annotation
>
CONTAINED_BY_CLASS
=
initContainedBy
();
private
static
final
Class
<?
extends
Annotation
>
REPEATABLE_CLASS
=
initRepeatable
();
private
static
final
Method
VALUE_ELEMENT_METHOD
=
initValueElementMethod
();
private
static
Class
<?
extends
Annotation
>
init
ContainedBy
()
{
private
static
Class
<?
extends
Annotation
>
init
Repeatable
()
{
try
{
@SuppressWarnings
(
"unchecked"
)
// java.lang.annotation.
ContainedBy
extends Annotation by being an annotation type
Class
<?
extends
Annotation
>
c
=
(
Class
)
Class
.
forName
(
"java.lang.annotation.
ContainedBy
"
);
@SuppressWarnings
(
"unchecked"
)
// java.lang.annotation.
Repeatable
extends Annotation by being an annotation type
Class
<?
extends
Annotation
>
c
=
(
Class
)
Class
.
forName
(
"java.lang.annotation.
Repeatable
"
);
return
c
;
}
catch
(
ClassNotFoundException
e
)
{
return
null
;
...
...
@@ -276,12 +276,12 @@ public class JavacElements implements Elements {
}
}
private
static
Method
initValueElementMethod
()
{
if
(
CONTAINED_BY
_CLASS
==
null
)
if
(
REPEATABLE
_CLASS
==
null
)
return
null
;
Method
m
=
null
;
try
{
m
=
CONTAINED_BY
_CLASS
.
getMethod
(
"value"
);
m
=
REPEATABLE
_CLASS
.
getMethod
(
"value"
);
if
(
m
!=
null
)
m
.
setAccessible
(
true
);
return
m
;
...
...
@@ -292,19 +292,19 @@ public class JavacElements implements Elements {
// Helper to getAnnotations
private
static
Class
<?
extends
Annotation
>
getContainer
(
Class
<?
extends
Annotation
>
annoType
)
{
// Since we can not refer to java.lang.annotation.
ContainedBy
until we are
// bootstrapping with java 8 we need to get the
ContainedBy
annotation using
// Since we can not refer to java.lang.annotation.
Repeatable
until we are
// bootstrapping with java 8 we need to get the
Repeatable
annotation using
// reflective invocations instead of just using its type and element method.
if
(
CONTAINED_BY
_CLASS
!=
null
&&
if
(
REPEATABLE
_CLASS
!=
null
&&
VALUE_ELEMENT_METHOD
!=
null
)
{
// Get the
ContainedBy
instance on the annotations declaration
Annotation
containedBy
=
(
Annotation
)
annoType
.
getAnnotation
(
CONTAINED_BY
_CLASS
);
if
(
containedBy
!=
null
)
{
// Get the
Repeatable
instance on the annotations declaration
Annotation
repeatable
=
(
Annotation
)
annoType
.
getAnnotation
(
REPEATABLE
_CLASS
);
if
(
repeatable
!=
null
)
{
try
{
// Get the value element, it should be a class
// indicating the containing annotation type
@SuppressWarnings
(
"unchecked"
)
Class
<?
extends
Annotation
>
containerType
=
(
Class
)
VALUE_ELEMENT_METHOD
.
invoke
(
containedBy
);
Class
<?
extends
Annotation
>
containerType
=
(
Class
)
VALUE_ELEMENT_METHOD
.
invoke
(
repeatable
);
if
(
containerType
==
null
)
return
null
;
...
...
src/share/classes/com/sun/tools/javac/resources/compiler.properties
浏览文件 @
d2f83671
#
# Copyright (c) 1999, 201
2
, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 1999, 201
3
, 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
...
...
@@ -319,64 +319,48 @@ compiler.err.duplicate.annotation.member.value=\
compiler.err.duplicate.annotation.missing.container
=
\
duplicate annotation, the declaration of {0} does not have a valid {1} annotation
# 0: type, 1: type
compiler.err.invalid.container.no.containedby
=
\
invalid contained repeatable annotation, {0} is not annotated with {1}
# 0: type, 1: type
compiler.err.invalid.container.wrong.containedby
=
\
invalid contained repeatable annotation, {0} does not match {1}
# 0: type, 1: type
compiler.err.invalid.container.no.containerfor
=
\
invalid container for repeating annotations, {0} is not annotated with {1}
# 0: type, 1: type
compiler.err.invalid.container.wrong.containerfor
=
\
invalid container for repeating annotations, {0} does not match {1}
# 0: type
compiler.err.invalid.
containedby
.annotation
=
\
duplicate annotation, {0} is annotated with an invalid
ContainedBy
annotation
compiler.err.invalid.
repeatable
.annotation
=
\
duplicate annotation, {0} is annotated with an invalid
Repeatable
annotation
# 0: type
compiler.err.invalid.
containedby
.annotation.no.value
=
\
duplicate annotation, {0} is not a valid
ContainedBy
, no value element method declared
compiler.err.invalid.
repeatable
.annotation.no.value
=
\
duplicate annotation, {0} is not a valid
Repeatable
, no value element method declared
# 0: type, 1: number
compiler.err.invalid.
containedby
.annotation.multiple.values
=
\
duplicate annotation, {0} is not a valid
ContainedBy
, {1} value element methods declared
compiler.err.invalid.
repeatable
.annotation.multiple.values
=
\
duplicate annotation, {0} is not a valid
Repeatable
, {1} value element methods declared
# 0: type
compiler.err.invalid.
containedby
.annotation.invalid.value
=
\
duplicate annotation, {0} is not a valid
ContainedBy
, invalid value element, need a method
compiler.err.invalid.
repeatable
.annotation.invalid.value
=
\
duplicate annotation, {0} is not a valid
Repeatable
, invalid value element, need a method
# 0: type, 1: type, 2: type
compiler.err.invalid.
containedby
.annotation.value.return
=
\
compiler.err.invalid.
repeatable
.annotation.value.return
=
\
duplicate annotation, value element of containing annotation {0} should have type {2}, found {1}
# 0: type, 1: symbol
compiler.err.invalid.
containedby
.annotation.elem.nondefault
=
\
compiler.err.invalid.
repeatable
.annotation.elem.nondefault
=
\
containing annotation {0} does not have a default value for element {1}
# 0: symbol, 1: type, 2: symbol, 3: type
compiler.err.invalid.
containedby
.annotation.retention
=
\
compiler.err.invalid.
repeatable
.annotation.retention
=
\
containing annotation {0} has shorter retention ({1}) than the contained annotation {2} with retention {3}
# 0: symbol, 1: symbol
compiler.err.invalid.
containedby
.annotation.not.documented
=
\
compiler.err.invalid.
repeatable
.annotation.not.documented
=
\
containing annotation type, {0}, is not @Documented while repeated annotation type, {1}, is
# 0: symbol, 1: symbol
compiler.err.invalid.
containedby
.annotation.not.inherited
=
\
compiler.err.invalid.
repeatable
.annotation.not.inherited
=
\
containing annotation type, {0}, is not @Inherited while repeated annotation type, {1}, is
# 0: symbol, 1: symbol
compiler.err.invalid.
containedby
.annotation.incompatible.target
=
\
compiler.err.invalid.
repeatable
.annotation.incompatible.target
=
\
target of container annotation {0} is not a subset of target of repeated annotation {1}
# 0: symbol
compiler.err.invalid.
containedby
.annotation.repeated.and.container.present
=
\
compiler.err.invalid.
repeatable
.annotation.repeated.and.container.present
=
\
container {0} must not be present at the same time as the element it contains
# 0: name
...
...
test/com/sun/javadoc/testRepeatedAnnotations/pkg/ContaineeSynthDoc.java
浏览文件 @
d2f83671
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012,
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
...
...
@@ -32,6 +32,6 @@ import java.lang.annotation.*;
* @author Bhavesh Patel
*/
@Documented
@
ContainedBy
(
ContainerSynthDoc
.
class
)
@
Repeatable
(
ContainerSynthDoc
.
class
)
public
@interface
ContaineeSynthDoc
{
}
test/com/sun/javadoc/testRepeatedAnnotations/pkg/ContainerSynthDoc.java
浏览文件 @
d2f83671
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012,
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
...
...
@@ -32,7 +32,6 @@ import java.lang.annotation.*;
* @author Bhavesh Patel
*/
@Documented
@ContainerFor
(
ContaineeSynthDoc
.
class
)
public
@interface
ContainerSynthDoc
{
ContaineeSynthDoc
[]
value
();
...
...
test/com/sun/javadoc/testRepeatedAnnotations/pkg1/ContaineeSynthDoc.java
浏览文件 @
d2f83671
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012,
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
...
...
@@ -32,6 +32,6 @@ import java.lang.annotation.*;
* @author Bhavesh Patel
*/
@Documented
@
ContainedBy
(
ContainerSynthNotDoc
.
class
)
@
Repeatable
(
ContainerSynthNotDoc
.
class
)
public
@interface
ContaineeSynthDoc
{
}
test/com/sun/javadoc/testRepeatedAnnotations/pkg1/ContainerSynthNotDoc.java
浏览文件 @
d2f83671
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012,
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
...
...
@@ -31,7 +31,6 @@ import java.lang.annotation.*;
*
* @author Bhavesh Patel
*/
@ContainerFor
(
ContaineeSynthDoc
.
class
)
public
@interface
ContainerSynthNotDoc
{
ContaineeSynthDoc
[]
value
();
...
...
test/tools/javac/annotations/repeatingAnnotations/BaseAnnoAsContainerAnno.java
浏览文件 @
d2f83671
...
...
@@ -6,11 +6,9 @@
* @compile/fail/ref=BaseAnnoAsContainerAnno.out -XDrawDiagnostics BaseAnnoAsContainerAnno.java
*/
import
java.lang.annotation.ContainedBy
;
import
java.lang.annotation.ContainerFor
;
import
java.lang.annotation.Repeatable
;
@ContainedBy
(
Foo
.
class
)
@ContainerFor
(
Foo
.
class
)
@Repeatable
(
Foo
.
class
)
@interface
Foo
{
Foo
[]
value
()
default
{};
}
...
...
test/tools/javac/annotations/repeatingAnnotations/BaseAnnoAsContainerAnno.out
浏览文件 @
d2f83671
BaseAnnoAsContainerAnno.java:1
5
:11: compiler.err.cyclic.annotation.element
BaseAnnoAsContainerAnno.java:1
3
:11: compiler.err.cyclic.annotation.element
1 error
test/tools/javac/annotations/repeatingAnnotations/BasicRepeatingAnnotations.java
浏览文件 @
d2f83671
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012,
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
...
...
@@ -34,10 +34,9 @@
import
java.lang.annotation.*
;
@Retention
(
RetentionPolicy
.
RUNTIME
)
@
ContainedBy
(
Foos
.
class
)
@
Repeatable
(
Foos
.
class
)
@interface
Foo
{}
@ContainerFor
(
Foo
.
class
)
@Retention
(
RetentionPolicy
.
RUNTIME
)
@interface
Foos
{
Foo
[]
value
();
...
...
test/tools/javac/annotations/repeatingAnnotations/CheckTargets.java
浏览文件 @
d2f83671
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012,
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
...
...
@@ -32,32 +32,29 @@
import
java.lang.annotation.*
;
@
ContainedBy
(
Foos
.
class
)
@
Repeatable
(
Foos
.
class
)
@Target
(
ElementType
.
TYPE
)
@interface
Foo
{}
@ContainerFor
(
Foo
.
class
)
@Target
(
ElementType
.
ANNOTATION_TYPE
)
@interface
Foos
{
Foo
[]
value
();
}
@
ContainedBy
(
Bars
.
class
)
@
Repeatable
(
Bars
.
class
)
@Target
(
ElementType
.
TYPE
)
@interface
Bar
{}
@ContainerFor
(
Bar
.
class
)
@Target
({
ElementType
.
ANNOTATION_TYPE
,
ElementType
.
TYPE
})
@interface
Bars
{
Bar
[]
value
();
}
@
ContainedBy
(
Bazs
.
class
)
@
Repeatable
(
Bazs
.
class
)
@Target
({
ElementType
.
TYPE
,
ElementType
.
ANNOTATION_TYPE
})
@interface
Baz
{}
@ContainerFor
(
Baz
.
class
)
@Target
({
ElementType
.
ANNOTATION_TYPE
,
ElementType
.
TYPE
})
@interface
Bazs
{
Baz
[]
value
();
...
...
test/tools/javac/annotations/repeatingAnnotations/ClassReaderDefault.java
浏览文件 @
d2f83671
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012,
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
...
...
@@ -30,17 +30,15 @@
* @compile ClassReaderDefault.java
* @compile SeparateCompile.java
*/
import
java.lang.annotation.ContainedBy
;
import
java.lang.annotation.ContainerFor
;
import
java.lang.annotation.Repeatable
;
public
class
ClassReaderDefault
{
}
@ContainerFor
(
Foo
.
class
)
@interface
FooContainer
{
Foo
[]
value
();
int
f
()
default
0
;
}
@
ContainedBy
(
FooContainer
.
class
)
@
Repeatable
(
FooContainer
.
class
)
@interface
Foo
{}
test/tools/javac/annotations/repeatingAnnotations/ContainerHasRepeatedContained.java
浏览文件 @
d2f83671
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012,
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
...
...
@@ -30,15 +30,13 @@
* @run compile ContainerHasRepeatedContained.java
*/
import
java.lang.annotation.ContainedBy
;
import
java.lang.annotation.ContainerFor
;
import
java.lang.annotation.Repeatable
;
@
ContainedBy
(
BarContainer
.
class
)
@
Repeatable
(
BarContainer
.
class
)
@interface
Bar
{}
@Bar
@Bar
@ContainerFor
(
Bar
.
class
)
@interface
BarContainer
{
Bar
[]
value
();
}
...
...
test/tools/javac/annotations/repeatingAnnotations/CyclicAnnotation.java
浏览文件 @
d2f83671
...
...
@@ -6,17 +6,14 @@
* @compile/fail/ref=CyclicAnnotation.out -XDrawDiagnostics CyclicAnnotation.java
*/
import
java.lang.annotation.ContainedBy
;
import
java.lang.annotation.ContainerFor
;
import
java.lang.annotation.Repeatable
;
@ContainedBy
(
Foo
.
class
)
@ContainerFor
(
Baz
.
class
)
@Repeatable
(
Foo
.
class
)
@interface
Baz
{
Foo
[]
value
()
default
{};
}
@ContainedBy
(
Baz
.
class
)
@ContainerFor
(
Foo
.
class
)
@Repeatable
(
Baz
.
class
)
@interface
Foo
{
Baz
[]
value
()
default
{};
}
...
...
test/tools/javac/annotations/repeatingAnnotations/CyclicAnnotation.out
浏览文件 @
d2f83671
CyclicAnnotation.java:12:1: compiler.err.invalid.container.wrong.containerfor: Foo, Baz
CyclicAnnotation.java:13:1: compiler.err.invalid.container.wrong.containedby: Foo, Baz
CyclicAnnotation.java:15:11: compiler.err.cyclic.annotation.element
CyclicAnnotation.java:18:1: compiler.err.invalid.container.wrong.containerfor: Baz, Foo
CyclicAnnotation.java:19:1: compiler.err.invalid.container.wrong.containedby: Baz, Foo
5 errors
CyclicAnnotation.java:13:11: compiler.err.cyclic.annotation.element
1 error
test/tools/javac/annotations/repeatingAnnotations/DefaultCasePresent.java
浏览文件 @
d2f83671
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012,
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
...
...
@@ -29,13 +29,11 @@
* @compile DefaultCasePresent.java
*/
import
java.lang.annotation.ContainedBy
;
import
java.lang.annotation.ContainerFor
;
import
java.lang.annotation.Repeatable
;
@
ContainedBy
(
FooContainer
.
class
)
@
Repeatable
(
FooContainer
.
class
)
@interface
Foo
{}
@ContainerFor
(
Foo
.
class
)
@interface
FooContainer
{
Foo
[]
value
();
String
other
()
default
"other-method"
;
...
...
test/tools/javac/annotations/repeatingAnnotations/DelayRepeatedContainer.java
浏览文件 @
d2f83671
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012,
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
...
...
@@ -39,12 +39,11 @@ public class DelayRepeatedContainer {
@Bar
(
"katt"
)
@Bar
(
"lol"
)
@
ContainedBy
(
BarContainer
.
class
)
@
Repeatable
(
BarContainer
.
class
)
@interface
Bar
{
String
value
();
}
@ContainerFor
(
Bar
.
class
)
@interface
BarContainer
{
Bar
[]
value
();
}
test/tools/javac/annotations/repeatingAnnotations/DocumentedContainerAnno.java
浏览文件 @
d2f83671
...
...
@@ -6,15 +6,13 @@
* @compile/fail/ref=DocumentedContainerAnno.out -XDrawDiagnostics DocumentedContainerAnno.java
*/
import
java.lang.annotation.ContainedBy
;
import
java.lang.annotation.ContainerFor
;
import
java.lang.annotation.Repeatable
;
import
java.lang.annotation.Documented
;
@Documented
@
ContainedBy
(
FooContainer
.
class
)
@
Repeatable
(
FooContainer
.
class
)
@interface
Foo
{}
@ContainerFor
(
Foo
.
class
)
@interface
FooContainer
{
Foo
[]
value
();
}
...
...
test/tools/javac/annotations/repeatingAnnotations/DocumentedContainerAnno.out
浏览文件 @
d2f83671
DocumentedContainerAnno.java:1
4:1: compiler.err.invalid.containedby
.annotation.not.documented: FooContainer, Foo
DocumentedContainerAnno.java:1
3:1: compiler.err.invalid.repeatable
.annotation.not.documented: FooContainer, Foo
1 error
test/tools/javac/annotations/repeatingAnnotations/InheritedContainerAnno.java
浏览文件 @
d2f83671
...
...
@@ -6,15 +6,13 @@
* @compile/fail/ref=InheritedContainerAnno.out -XDrawDiagnostics InheritedContainerAnno.java
*/
import
java.lang.annotation.ContainedBy
;
import
java.lang.annotation.ContainerFor
;
import
java.lang.annotation.Repeatable
;
import
java.lang.annotation.Inherited
;
@Inherited
@
ContainedBy
(
FooContainer
.
class
)
@
Repeatable
(
FooContainer
.
class
)
@interface
Foo
{}
@ContainerFor
(
Foo
.
class
)
@interface
FooContainer
{
Foo
[]
value
();
}
...
...
test/tools/javac/annotations/repeatingAnnotations/InheritedContainerAnno.out
浏览文件 @
d2f83671
InheritedContainerAnno.java:1
4:1: compiler.err.invalid.containedby
.annotation.not.inherited: FooContainer, Foo
InheritedContainerAnno.java:1
3:1: compiler.err.invalid.repeatable
.annotation.not.inherited: FooContainer, Foo
1 error
test/tools/javac/annotations/repeatingAnnotations/InvalidTarget.java
浏览文件 @
d2f83671
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012,
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
...
...
@@ -32,11 +32,10 @@
import
java.lang.annotation.*
;
@
ContainedBy
(
Foos
.
class
)
@
Repeatable
(
Foos
.
class
)
@Target
(
ElementType
.
ANNOTATION_TYPE
)
@interface
Foo
{}
@ContainerFor
(
Foo
.
class
)
@Target
(
ElementType
.
TYPE
)
@interface
Foos
{
Foo
[]
value
();
...
...
test/tools/javac/annotations/repeatingAnnotations/MissingContainer.java
浏览文件 @
d2f83671
...
...
@@ -6,13 +6,11 @@
* @compile/fail/ref=MissingContainer.out -XDrawDiagnostics MissingContainer.java
*/
import
java.lang.annotation.ContainedBy
;
import
java.lang.annotation.ContainerFor
;
import
java.lang.annotation.Repeatable
;
@
ContainedBy
()
@
Repeatable
()
@interface
Foo
{}
@ContainerFor
(
Foo
.
class
)
@interface
FooContainer
{
Foo
[]
value
();
}
...
...
test/tools/javac/annotations/repeatingAnnotations/MissingContainer.out
浏览文件 @
d2f83671
MissingContainer.java:20:1: compiler.err.invalid.containedby.annotation: Foo
MissingContainer.java:20:6: compiler.err.invalid.containedby.annotation: Foo
MissingContainer.java:12:1: compiler.err.annotation.missing.default.value: java.lang.annotation.ContainedBy, value
MissingContainer.java:15:1: compiler.err.invalid.container.wrong.containedby: Foo, FooContainer
4 errors
MissingContainer.java:18:1: compiler.err.invalid.repeatable.annotation: Foo
MissingContainer.java:18:6: compiler.err.invalid.repeatable.annotation: Foo
MissingContainer.java:11:1: compiler.err.annotation.missing.default.value: java.lang.annotation.Repeatable, value
3 errors
test/tools/javac/annotations/repeatingAnnotations/MissingContainerFor.java
已删除
100644 → 0
浏览文件 @
a9b3c8d3
/*
* Copyright (c) 2012, 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
* @summary Smoke test for repeating annotations
* @compile/fail MissingContainerFor.java
* @bug 7151010
*/
import
java.lang.annotation.*
;
@interface
Foos
{
MissingContainerFor
[]
value
();
}
@ContainedBy
(
Foos
.
class
)
public
@interface
MissingContainerFor
{}
test/tools/javac/annotations/repeatingAnnotations/MissingDefaultCase1.java
浏览文件 @
d2f83671
...
...
@@ -6,13 +6,11 @@
* @compile/fail/ref=MissingDefaultCase1.out -XDrawDiagnostics MissingDefaultCase1.java
*/
import
java.lang.annotation.ContainedBy
;
import
java.lang.annotation.ContainerFor
;
import
java.lang.annotation.Repeatable
;
@
ContainedBy
(
FooContainer
.
class
)
@
Repeatable
(
FooContainer
.
class
)
@interface
Foo
{}
@ContainerFor
(
Foo
.
class
)
@interface
FooContainer
{
Foo
[]
value
();
String
other
();
// missing default clause
...
...
test/tools/javac/annotations/repeatingAnnotations/MissingDefaultCase1.out
浏览文件 @
d2f83671
MissingDefaultCase1.java:
21
:1: compiler.err.duplicate.annotation.invalid.repeated: Foo
MissingDefaultCase1.java:1
2:1: compiler.err.invalid.containedby
.annotation.elem.nondefault: FooContainer, other()
MissingDefaultCase1.java:
19
:1: compiler.err.duplicate.annotation.invalid.repeated: Foo
MissingDefaultCase1.java:1
1:1: compiler.err.invalid.repeatable
.annotation.elem.nondefault: FooContainer, other()
2 errors
test/tools/javac/annotations/repeatingAnnotations/MissingDefaultCase2.java
浏览文件 @
d2f83671
...
...
@@ -6,13 +6,11 @@
* @compile/fail/ref=MissingDefaultCase2.out -XDrawDiagnostics MissingDefaultCase2.java
*/
import
java.lang.annotation.ContainedBy
;
import
java.lang.annotation.ContainerFor
;
import
java.lang.annotation.Repeatable
;
@
ContainedBy
(
FooContainer
.
class
)
@
Repeatable
(
FooContainer
.
class
)
@interface
Foo
{}
@ContainerFor
(
Foo
.
class
)
@interface
FooContainer
{
Foo
[]
value
();
Foo
other
();
// missing default clause and return type is an annotation
...
...
test/tools/javac/annotations/repeatingAnnotations/MissingDefaultCase2.out
浏览文件 @
d2f83671
MissingDefaultCase2.java:
21
:1: compiler.err.duplicate.annotation.invalid.repeated: Foo
MissingDefaultCase2.java:1
2:1: compiler.err.invalid.containedby
.annotation.elem.nondefault: FooContainer, other()
MissingDefaultCase2.java:
19
:1: compiler.err.duplicate.annotation.invalid.repeated: Foo
MissingDefaultCase2.java:1
1:1: compiler.err.invalid.repeatable
.annotation.elem.nondefault: FooContainer, other()
2 errors
test/tools/javac/annotations/repeatingAnnotations/MissingValueMethod.java
浏览文件 @
d2f83671
...
...
@@ -6,13 +6,11 @@
* @compile/fail/ref=MissingValueMethod.out -XDrawDiagnostics MissingValueMethod.java
*/
import
java.lang.annotation.ContainedBy
;
import
java.lang.annotation.ContainerFor
;
import
java.lang.annotation.Repeatable
;
@
ContainedBy
(
FooContainer
.
class
)
@
Repeatable
(
FooContainer
.
class
)
@interface
Foo
{}
@ContainerFor
(
Foo
.
class
)
@interface
FooContainer
{
Foo
[]
values
();
// wrong method name
}
...
...
test/tools/javac/annotations/repeatingAnnotations/MissingValueMethod.out
浏览文件 @
d2f83671
MissingValueMethod.java:
20:1: compiler.err.invalid.containedby
.annotation.no.value: FooContainer
MissingValueMethod.java:
20:6: compiler.err.invalid.containedby
.annotation.no.value: FooContainer
MissingValueMethod.java:1
2:1: compiler.err.invalid.containedby.annotation.elem.nondefault: FooContainer, values()
MissingValueMethod.java:
18:1: compiler.err.invalid.repeatable
.annotation.no.value: FooContainer
MissingValueMethod.java:
18:6: compiler.err.invalid.repeatable
.annotation.no.value: FooContainer
MissingValueMethod.java:1
1:1: compiler.err.invalid.repeatable.annotation.no.value: FooContainer
3 errors
test/tools/javac/annotations/repeatingAnnotations/MultiLevelRepeatableAnno.java
浏览文件 @
d2f83671
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012,
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
...
...
@@ -29,19 +29,16 @@
* @compile MultiLevelRepeatableAnno.java
*/
import
java.lang.annotation.ContainedBy
;
import
java.lang.annotation.ContainerFor
;
import
java.lang.annotation.Repeatable
;
@
ContainedBy
(
FooContainer
.
class
)
@
Repeatable
(
FooContainer
.
class
)
@interface
Foo
{}
@ContainedBy
(
FooContainerContainer
.
class
)
@ContainerFor
(
Foo
.
class
)
@Repeatable
(
FooContainerContainer
.
class
)
@interface
FooContainer
{
Foo
[]
value
();
}
@ContainerFor
(
FooContainer
.
class
)
@interface
FooContainerContainer
{
FooContainer
[]
value
();
}
...
...
test/tools/javac/annotations/repeatingAnnotations/MultipleAnnoMixedOrder.java
浏览文件 @
d2f83671
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012,
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
...
...
@@ -29,25 +29,22 @@
* @compile MultipleAnnoMixedOrder.java
*/
import
java.lang.annotation.ContainedBy
;
import
java.lang.annotation.ContainerFor
;
import
java.lang.annotation.Repeatable
;
@
ContainedBy
(
FooContainer
.
class
)
@
Repeatable
(
FooContainer
.
class
)
@interface
Foo
{
int
getNumbers
();
}
@ContainerFor
(
Foo
.
class
)
@interface
FooContainer
{
Foo
[]
value
();
}
@
ContainedBy
(
BazContainer
.
class
)
@
Repeatable
(
BazContainer
.
class
)
@interface
Baz
{
String
getStr
();
}
@ContainerFor
(
Baz
.
class
)
@interface
BazContainer
{
Baz
[]
value
();
}
...
...
test/tools/javac/annotations/repeatingAnnotations/NestedContainers.java
浏览文件 @
d2f83671
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012,
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
...
...
@@ -34,17 +34,15 @@
import
java.lang.annotation.*
;
@Retention
(
RetentionPolicy
.
RUNTIME
)
@
ContainedBy
(
Foos
.
class
)
@
Repeatable
(
Foos
.
class
)
@interface
Foo
{}
@Retention
(
RetentionPolicy
.
RUNTIME
)
@ContainedBy
(
FoosFoos
.
class
)
@ContainerFor
(
Foo
.
class
)
@Repeatable
(
FoosFoos
.
class
)
@interface
Foos
{
Foo
[]
value
();
}
@ContainerFor
(
Foos
.
class
)
@Retention
(
RetentionPolicy
.
RUNTIME
)
@interface
FoosFoos
{
Foos
[]
value
();
...
...
test/tools/javac/annotations/repeatingAnnotations/NoRepeatableAnno.out
浏览文件 @
d2f83671
NoRepeatableAnno.java:11:1: compiler.err.duplicate.annotation.missing.container: Foo, java.lang.annotation.
ContainedBy
NoRepeatableAnno.java:11:6: compiler.err.duplicate.annotation.missing.container: Foo, java.lang.annotation.
ContainedBy
NoRepeatableAnno.java:11:1: compiler.err.duplicate.annotation.missing.container: Foo, java.lang.annotation.
Repeatable
NoRepeatableAnno.java:11:6: compiler.err.duplicate.annotation.missing.container: Foo, java.lang.annotation.
Repeatable
2 errors
test/tools/javac/annotations/repeatingAnnotations/RepMemberAnno.java
浏览文件 @
d2f83671
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012,
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
...
...
@@ -30,20 +30,18 @@
* @run compile RepMemberAnno.java
*/
import
java.lang.annotation.ContainedBy
;
import
java.lang.annotation.ContainerFor
;
import
java.lang.annotation.Repeatable
;
public
class
RepMemberAnno
{
@Bar
(
"Apa"
)
@Bar
(
"Banan"
)
public
void
meh
()
{}
}
@
ContainedBy
(
BarContainer
.
class
)
@
Repeatable
(
BarContainer
.
class
)
@interface
Bar
{
String
value
();
}
@ContainerFor
(
Bar
.
class
)
@interface
BarContainer
{
Bar
[]
value
();
}
test/tools/javac/annotations/repeatingAnnotations/RepSelfMemberAnno.java
浏览文件 @
d2f83671
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012,
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
...
...
@@ -34,21 +34,19 @@ import java.lang.annotation.*;
@Retention
(
RetentionPolicy
.
RUNTIME
)
@
ContainedBy
(
BarContainer
.
class
)
@
Repeatable
(
BarContainer
.
class
)
public
@interface
RepSelfMemberAnno
{
@RepSelfMemberAnno
@RepSelfMemberAnno
String
meh
()
default
"banan"
;
}
@
ContainedBy
(
BarContainerContainer
.
class
)
@
Repeatable
(
BarContainerContainer
.
class
)
@Retention
(
RetentionPolicy
.
RUNTIME
)
@ContainerFor
(
RepSelfMemberAnno
.
class
)
@interface
BarContainer
{
RepSelfMemberAnno
[]
value
();
}
@ContainerFor
(
BarContainer
.
class
)
@Retention
(
RetentionPolicy
.
RUNTIME
)
@interface
BarContainerContainer
{
BarContainer
[]
value
();
...
...
test/tools/javac/annotations/repeatingAnnotations/RepeatingAndContainerPresent.java
浏览文件 @
d2f83671
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012,
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
...
...
@@ -30,7 +30,7 @@
import
java.lang.annotation.*
;
@
ContainedBy
(
Foos
.
class
)
@
Repeatable
(
Foos
.
class
)
@interface
Foo
{}
@interface
Foos
{
...
...
test/tools/javac/annotations/repeatingAnnotations/RepeatingTargetNotAllowed.java
浏览文件 @
d2f83671
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012,
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
...
...
@@ -31,10 +31,9 @@
import
java.lang.annotation.*
;
@
ContainedBy
(
Foos
.
class
)
@
Repeatable
(
Foos
.
class
)
@interface
Foo
{}
@ContainerFor
(
Foo
.
class
)
@Target
(
ElementType
.
ANNOTATION_TYPE
)
@interface
Foos
{
Foo
[]
value
();
...
...
test/tools/javac/annotations/repeatingAnnotations/RepeatingTargetNotAllowed.out
浏览文件 @
d2f83671
RepeatingTargetNotAllowed.java:4
4:5: compiler.err.invalid.containedby
.annotation.incompatible.target: Foos, Foo
RepeatingTargetNotAllowed.java:4
3:5: compiler.err.invalid.repeatable
.annotation.incompatible.target: Foos, Foo
1 error
test/tools/javac/annotations/repeatingAnnotations/SelfRepeatingAnnotations.java
浏览文件 @
d2f83671
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012,
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
...
...
@@ -33,7 +33,6 @@
import
java.lang.annotation.*
;
@ContainerFor
(
SelfRepeatingAnno
.
class
)
@Retention
(
RetentionPolicy
.
RUNTIME
)
@interface
Foos
{
SelfRepeatingAnno
[]
value
();
...
...
@@ -42,7 +41,7 @@ import java.lang.annotation.*;
@SelfRepeatingAnno
@Retention
(
RetentionPolicy
.
RUNTIME
)
@SelfRepeatingAnno
@
ContainedBy
(
Foos
.
class
)
@
Repeatable
(
Foos
.
class
)
@interface
SelfRepeatingAnno
{}
public
class
SelfRepeatingAnnotations
{
...
...
test/tools/javac/annotations/repeatingAnnotations/SingleRepeatingAndContainer.java
浏览文件 @
d2f83671
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012,
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
...
...
@@ -30,10 +30,9 @@
import
java.lang.annotation.*
;
@
ContainedBy
(
Foos
.
class
)
@
Repeatable
(
Foos
.
class
)
@interface
Foo
{}
@ContainerFor
(
Foo
.
class
)
@interface
Foos
{
Foo
[]
value
();
}
...
...
test/tools/javac/annotations/repeatingAnnotations/UseWrongContainedBy.java
已删除
100644 → 0
浏览文件 @
a9b3c8d3
/*
* Copyright (c) 2012, 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
* @summary Smoke test for repeating annotations
* @compile/fail UseWrongContainedBy.java
* @bug 7151010
*/
import
java.lang.annotation.*
;
@ContainerFor
(
UseWrongContainedBy
.
class
)
@interface
Foos
{
UseWrongContainedBy
[]
value
();
}
@ContainedBy
(
Target
.
class
)
public
@interface
UseWrongContainedBy
{}
@UseWrongContainedBy
@UseWrongContainedBy
@interface
Foo
{}
test/tools/javac/annotations/repeatingAnnotations/UseWrongContainerFor.java
已删除
100644 → 0
浏览文件 @
a9b3c8d3
/*
* Copyright (c) 2012, 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
* @summary Smoke test for repeating annotations
* @compile/fail UseWrongContainerFor.java
* @bug 7151010
*/
import
java.lang.annotation.*
;
@ContainerFor
(
Retention
.
class
)
@interface
Foos
{
UseWrongContainerFor
[]
value
();
}
@ContainedBy
(
Foos
.
class
)
public
@interface
UseWrongContainerFor
{}
@UseWrongContainerFor
@UseWrongContainerFor
@interface
Foo
{}
test/tools/javac/annotations/repeatingAnnotations/
MissingContainedBy
.java
→
test/tools/javac/annotations/repeatingAnnotations/
UseWrongRepeatable
.java
浏览文件 @
d2f83671
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012,
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
...
...
@@ -24,16 +24,18 @@
/**
* @test
* @summary Smoke test for repeating annotations
* @compile/fail
MissingContainedBy
.java
* @compile/fail
UseWrongRepeatable
.java
* @bug 7151010
*/
import
java.lang.annotation.*
;
@ContainerFor
(
MissingContainedBy
.
class
)
@interface
Foos
{
MissingContainedBy
[]
value
();
UseWrongRepeatable
[]
value
();
}
public
@interface
MissingContainedBy
{}
@Repeatable
(
Target
.
class
)
public
@interface
UseWrongRepeatable
{}
@UseWrongRepeatable
@UseWrongRepeatable
@interface
Foo
{}
test/tools/javac/annotations/repeatingAnnotations/WrongContainedBy.java
已删除
100644 → 0
浏览文件 @
a9b3c8d3
/*
* Copyright (c) 2012, 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
* @summary Smoke test for repeating annotations
* @compile/fail WrongContainedBy.java
* @bug 7151010
*/
import
java.lang.annotation.*
;
@ContainerFor
(
WrongContainedBy
.
class
)
@interface
Foos
{
WrongContainedBy
[]
value
();
}
@ContainedBy
(
Target
.
class
)
public
@interface
WrongContainedBy
{}
test/tools/javac/annotations/repeatingAnnotations/WrongContainerFor.java
已删除
100644 → 0
浏览文件 @
a9b3c8d3
/*
* Copyright (c) 2012, 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
* @summary Smoke test for repeating annotations
* @compile/fail WrongContainerFor.java
* @bug 7151010
*/
import
java.lang.annotation.*
;
@ContainerFor
(
Retention
.
class
)
@interface
Foos
{
WrongContainerFor
[]
value
();
}
@ContainedBy
(
Foos
.
class
)
public
@interface
WrongContainerFor
{}
test/tools/javac/annotations/repeatingAnnotations/WrongReturnTypeForValue.java
浏览文件 @
d2f83671
...
...
@@ -6,15 +6,13 @@
* @compile/fail/ref=WrongReturnTypeForValue.out -XDrawDiagnostics WrongReturnTypeForValue.java
*/
import
java.lang.annotation.ContainedBy
;
import
java.lang.annotation.ContainerFor
;
import
java.lang.annotation.Repeatable
;
@
ContainedBy
(
FooContainer
.
class
)
@
Repeatable
(
FooContainer
.
class
)
@interface
Foo
{
int
getNumbers
();
}
@ContainerFor
(
Foo
.
class
)
@interface
FooContainer
{
Foo
value
();
// wrong return type
}
...
...
test/tools/javac/annotations/repeatingAnnotations/WrongReturnTypeForValue.out
浏览文件 @
d2f83671
WrongReturnTypeForValue.java:22:1: compiler.err.invalid.containedby.annotation.value.return: FooContainer, Foo, Foo[]
WrongReturnTypeForValue.java:22:6: compiler.err.invalid.containedby.annotation.value.return: FooContainer, Foo, Foo[]
2 errors
WrongReturnTypeForValue.java:20:1: compiler.err.invalid.repeatable.annotation.value.return: FooContainer, Foo, Foo[]
WrongReturnTypeForValue.java:20:6: compiler.err.invalid.repeatable.annotation.value.return: FooContainer, Foo, Foo[]
WrongReturnTypeForValue.java:11:1: compiler.err.invalid.repeatable.annotation.value.return: FooContainer, Foo, Foo[]
3 errors
test/tools/javac/annotations/repeatingAnnotations/combo/BasicSyntaxCombo.java
浏览文件 @
d2f83671
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012,
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
...
...
@@ -163,9 +163,8 @@ public class BasicSyntaxCombo extends Helper{
String
replaceStr
=
"/*"
+
type
+
"*/"
;
StringBuilder
annoData
=
new
StringBuilder
();
annoData
.
append
(
Helper
.
ContentVars
.
IMPORTCONTAINERSTMTS
.
getVal
())
.
append
(
Helper
.
ContentVars
.
CONTAINERFOR
.
getVal
())
.
append
(
Helper
.
ContentVars
.
CONTAINER
.
getVal
())
.
append
(
Helper
.
ContentVars
.
CONTAINEDBY
.
getVal
())
.
append
(
Helper
.
ContentVars
.
REPEATABLE
.
getVal
())
.
append
(
Helper
.
ContentVars
.
BASE
.
getVal
());
JavaFileObject
pkgInfoFile
=
null
;
...
...
test/tools/javac/annotations/repeatingAnnotations/combo/DeprecatedAnnoCombo.java
浏览文件 @
d2f83671
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012,
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
...
...
@@ -115,24 +115,21 @@ public class DeprecatedAnnoCombo extends Helper {
switch
(
className
)
{
case
"DeprecatedonBoth"
:
annoData
.
append
(
Helper
.
ContentVars
.
DEPRECATED
.
getVal
())
.
append
(
Helper
.
ContentVars
.
CONTAINERFOR
.
getVal
())
.
append
(
Helper
.
ContentVars
.
CONTAINER
.
getVal
())
.
append
(
Helper
.
ContentVars
.
DEPRECATED
.
getVal
())
.
append
(
Helper
.
ContentVars
.
CONTAINEDBY
.
getVal
())
.
append
(
Helper
.
ContentVars
.
REPEATABLE
.
getVal
())
.
append
(
Helper
.
ContentVars
.
BASE
.
getVal
());
break
;
case
"DeprecatedonBase"
:
annoData
.
append
(
Helper
.
ContentVars
.
CONTAINERFOR
.
getVal
())
.
append
(
Helper
.
ContentVars
.
CONTAINER
.
getVal
())
annoData
.
append
(
Helper
.
ContentVars
.
CONTAINER
.
getVal
())
.
append
(
Helper
.
ContentVars
.
DEPRECATED
.
getVal
())
.
append
(
Helper
.
ContentVars
.
CONTAINEDBY
.
getVal
())
.
append
(
Helper
.
ContentVars
.
REPEATABLE
.
getVal
())
.
append
(
Helper
.
ContentVars
.
BASE
.
getVal
());
break
;
case
"DeprecatedonContainer"
:
annoData
.
append
(
Helper
.
ContentVars
.
DEPRECATED
.
getVal
())
.
append
(
Helper
.
ContentVars
.
CONTAINERFOR
.
getVal
())
.
append
(
Helper
.
ContentVars
.
CONTAINER
.
getVal
())
.
append
(
Helper
.
ContentVars
.
CONTAINEDBY
.
getVal
())
.
append
(
Helper
.
ContentVars
.
REPEATABLE
.
getVal
())
.
append
(
Helper
.
ContentVars
.
BASE
.
getVal
());
break
;
}
...
...
test/tools/javac/annotations/repeatingAnnotations/combo/DocumentedAnnoCombo.java
浏览文件 @
d2f83671
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012,
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
...
...
@@ -93,17 +93,15 @@ public class DocumentedAnnoCombo extends Helper {
switch
(
className
)
{
case
"DocumentedonBothAnno"
:
annoData
.
append
(
Helper
.
ContentVars
.
DOCUMENTED
.
getVal
())
.
append
(
Helper
.
ContentVars
.
CONTAINERFOR
.
getVal
())
.
append
(
Helper
.
ContentVars
.
CONTAINER
.
getVal
())
.
append
(
Helper
.
ContentVars
.
DOCUMENTED
.
getVal
())
.
append
(
Helper
.
ContentVars
.
CONTAINEDBY
.
getVal
())
.
append
(
Helper
.
ContentVars
.
REPEATABLE
.
getVal
())
.
append
(
Helper
.
ContentVars
.
BASE
.
getVal
());
break
;
case
"DocumentedonContainer"
:
annoData
.
append
(
Helper
.
ContentVars
.
DOCUMENTED
.
getVal
())
.
append
(
Helper
.
ContentVars
.
CONTAINERFOR
.
getVal
())
.
append
(
Helper
.
ContentVars
.
CONTAINER
.
getVal
())
.
append
(
Helper
.
ContentVars
.
CONTAINEDBY
.
getVal
())
.
append
(
Helper
.
ContentVars
.
REPEATABLE
.
getVal
())
.
append
(
Helper
.
ContentVars
.
BASE
.
getVal
());
break
;
}
...
...
test/tools/javac/annotations/repeatingAnnotations/combo/Helper.java
浏览文件 @
d2f83671
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012,
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
...
...
@@ -34,15 +34,13 @@ import javax.tools.JavaCompiler.CompilationTask;
public
class
Helper
{
enum
ContentVars
{
IMPORTCONTAINERSTMTS
(
"\nimport java.lang.annotation.ContainedBy;\n"
+
"\nimport java.lang.annotation.ContainerFor;\n"
),
IMPORTCONTAINERSTMTS
(
"\nimport java.lang.annotation.Repeatable;\n"
),
IMPORTDEPRECATED
(
"import java.lang.Deprecated;\n"
),
IMPORTDOCUMENTED
(
"import java.lang.annotation.Documented;\n"
),
IMPORTINHERITED
(
"import java.lang.annotation.Inherited;\n"
),
IMPORTRETENTION
(
"import java.lang.annotation.Retention;\n"
+
"\nimport java.lang.annotation.RetentionPolicy;\n"
),
CONTAINEDBY
(
"\n@ContainedBy(FooContainer.class)\n"
),
CONTAINERFOR
(
"@ContainerFor(Foo.class)\n"
),
REPEATABLE
(
"\n@Repeatable(FooContainer.class)\n"
),
CONTAINER
(
"@interface FooContainer {\n"
+
" Foo[] value();\n}\n"
),
BASE
(
"@interface Foo {}\n"
),
REPEATABLEANNO
(
"\n@Foo() @Foo()"
),
...
...
test/tools/javac/annotations/repeatingAnnotations/combo/InheritedAnnoCombo.java
浏览文件 @
d2f83671
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012,
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
...
...
@@ -94,17 +94,15 @@ public class InheritedAnnoCombo extends Helper {
switch
(
className
)
{
case
"InheritedonBothAnno"
:
annoData
.
append
(
Helper
.
ContentVars
.
INHERITED
.
getVal
())
.
append
(
Helper
.
ContentVars
.
CONTAINERFOR
.
getVal
())
.
append
(
Helper
.
ContentVars
.
CONTAINER
.
getVal
())
.
append
(
Helper
.
ContentVars
.
INHERITED
.
getVal
())
.
append
(
Helper
.
ContentVars
.
CONTAINEDBY
.
getVal
())
.
append
(
Helper
.
ContentVars
.
REPEATABLE
.
getVal
())
.
append
(
Helper
.
ContentVars
.
BASE
.
getVal
());
break
;
case
"InheritedonBase"
:
annoData
.
append
(
Helper
.
ContentVars
.
INHERITED
.
getVal
())
.
append
(
Helper
.
ContentVars
.
CONTAINERFOR
.
getVal
())
.
append
(
Helper
.
ContentVars
.
CONTAINER
.
getVal
())
.
append
(
Helper
.
ContentVars
.
CONTAINEDBY
.
getVal
())
.
append
(
Helper
.
ContentVars
.
REPEATABLE
.
getVal
())
.
append
(
Helper
.
ContentVars
.
BASE
.
getVal
());
break
;
}
...
...
test/tools/javac/annotations/repeatingAnnotations/combo/RetentionAnnoCombo.java
浏览文件 @
d2f83671
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012,
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
...
...
@@ -120,7 +120,7 @@ public class RetentionAnnoCombo extends Helper {
new
DiagnosticCollector
<
JavaFileObject
>();
boolean
ok
=
compileCode
(
className
,
contents
,
diagnostics
);
String
expectedErrKey
=
"compiler.err.invalid.
containedby
"
+
String
expectedErrKey
=
"compiler.err.invalid.
repeatable
"
+
".annotation.retention"
;
if
(!
shouldCompile
&&
!
ok
)
{
for
(
Diagnostic
<?>
d
:
diagnostics
.
getDiagnostics
())
{
...
...
@@ -175,10 +175,9 @@ public class RetentionAnnoCombo extends Helper {
StringBuilder
annoData
=
new
StringBuilder
();
annoData
.
append
(
Helper
.
ContentVars
.
IMPORTCONTAINERSTMTS
.
getVal
())
.
append
(
Helper
.
ContentVars
.
IMPORTRETENTION
.
getVal
())
.
append
(
Helper
.
ContentVars
.
CONTAINERFOR
.
getVal
())
.
append
(
replacedRetCAVal
)
.
append
(
Helper
.
ContentVars
.
CONTAINER
.
getVal
())
.
append
(
Helper
.
ContentVars
.
CONTAINEDBY
.
getVal
())
.
append
(
Helper
.
ContentVars
.
REPEATABLE
.
getVal
())
.
append
(
replacedRetBaseVal
)
.
append
(
Helper
.
ContentVars
.
BASE
.
getVal
());
...
...
test/tools/javac/diags/examples.not-yet.txt
浏览文件 @
d2f83671
...
...
@@ -5,9 +5,9 @@ compiler.err.cant.read.file # (apt.JavaCompiler?)
compiler.err.cant.select.static.class.from.param.type
compiler.err.dc.unterminated.string # cannot happen
compiler.err.illegal.char.for.encoding
compiler.err.invalid.
containedby.annotation
# should not happen
compiler.err.invalid.
containedby
.annotation.invalid.value # "can't" happen
compiler.err.invalid.
containedby
.annotation.multiple.values # can't happen
compiler.err.invalid.
repeatable.annotation
# should not happen
compiler.err.invalid.
repeatable
.annotation.invalid.value # "can't" happen
compiler.err.invalid.
repeatable
.annotation.multiple.values # can't happen
compiler.err.io.exception # (javah.JavahTask?)
compiler.err.limit.code # Code
compiler.err.limit.code.too.large.for.try.stmt # Gen
...
...
test/tools/javac/diags/examples/InvalidDuplicateAnnotation.java
浏览文件 @
d2f83671
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012,
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
...
...
@@ -22,17 +22,16 @@
*/
// key: compiler.err.duplicate.annotation.invalid.repeated
// key: compiler.err.invalid.
containedby
.annotation.elem.nondefault
//
// key: compiler.err.invalid.
repeatable
.annotation.elem.nondefault
// We need an almost valid containing annotation. The easiest way to get
// one close enough to valid is by forgetting a default.
import
java.lang.annotation.*
;
@
ContainedBy
(
Annos
.
class
)
@
Repeatable
(
Annos
.
class
)
@interface
Anno
{
}
@ContainerFor
(
Anno
.
class
)
@interface
Annos
{
Anno
[]
value
();
String
foo
();
}
@Anno
...
...
test/tools/javac/diags/examples/
ContainedBy
DocumentedMismatch.java
→
test/tools/javac/diags/examples/
Repeatable
DocumentedMismatch.java
浏览文件 @
d2f83671
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012,
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
...
...
@@ -21,17 +21,16 @@
* questions.
*/
// key: compiler.err.invalid.
containedby
.annotation.not.documented
// key: compiler.err.invalid.
repeatable
.annotation.not.documented
import
java.lang.annotation.*
;
@Documented
@
ContainedBy
(
Annos
.
class
)
@
Repeatable
(
Annos
.
class
)
@interface
Anno
{
}
@ContainerFor
(
Anno
.
class
)
@interface
Annos
{
Anno
[]
value
();
}
@Anno
@Anno
class
ContainedBy
DocumentedMismatch
{
}
class
Repeatable
DocumentedMismatch
{
}
test/tools/javac/diags/examples/
ContainedBy
InheritedMismatch.java
→
test/tools/javac/diags/examples/
Repeatable
InheritedMismatch.java
浏览文件 @
d2f83671
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012,
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
...
...
@@ -21,17 +21,16 @@
* questions.
*/
// key: compiler.err.invalid.
containedby
.annotation.not.inherited
// key: compiler.err.invalid.
repeatable
.annotation.not.inherited
import
java.lang.annotation.*
;
@Inherited
@
ContainedBy
(
Annos
.
class
)
@
Repeatable
(
Annos
.
class
)
@interface
Anno
{
}
@ContainerFor
(
Anno
.
class
)
@interface
Annos
{
Anno
[]
value
();
}
@Anno
@Anno
class
ContainedBy
InheritedMismatch
{
}
class
Repeatable
InheritedMismatch
{
}
test/tools/javac/diags/examples/
ContainedBy
NoValue.java
→
test/tools/javac/diags/examples/
Repeatable
NoValue.java
浏览文件 @
d2f83671
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012,
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
...
...
@@ -21,16 +21,15 @@
* questions.
*/
// key: compiler.err.invalid.
containedby
.annotation.no.value
// key: compiler.err.invalid.
repeatable
.annotation.no.value
import
java.lang.annotation.*
;
@
ContainedBy
(
Annos
.
class
)
@
Repeatable
(
Annos
.
class
)
@interface
Anno
{
}
@ContainerFor
(
Anno
.
class
)
@interface
Annos
{}
@Anno
@Anno
class
ContainedBy
NoValue
{
}
class
Repeatable
NoValue
{
}
test/tools/javac/diags/examples/
ContainedBy
NonDefault.java
→
test/tools/javac/diags/examples/
Repeatable
NonDefault.java
浏览文件 @
d2f83671
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012,
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
...
...
@@ -21,14 +21,13 @@
* questions.
*/
// key: compiler.err.invalid.
containedby
.annotation.elem.nondefault
// key: compiler.err.invalid.
repeatable
.annotation.elem.nondefault
import
java.lang.annotation.*
;
@
ContainedBy
(
Annos
.
class
)
@
Repeatable
(
Annos
.
class
)
@interface
Anno
{
}
@ContainerFor
(
Anno
.
class
)
@interface
Annos
{
Anno
[]
value
();
String
foo
();
}
class
ContainedBy
NonDefault
{
}
class
Repeatable
NonDefault
{
}
test/tools/javac/diags/examples/
ContainedBy
RetentionMismatch.java
→
test/tools/javac/diags/examples/
Repeatable
RetentionMismatch.java
浏览文件 @
d2f83671
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012,
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
...
...
@@ -21,17 +21,16 @@
* questions.
*/
// key: compiler.err.invalid.
containedby
.annotation.retention
// key: compiler.err.invalid.
repeatable
.annotation.retention
import
java.lang.annotation.*
;
@Retention
(
RetentionPolicy
.
RUNTIME
)
@
ContainedBy
(
Annos
.
class
)
@
Repeatable
(
Annos
.
class
)
@interface
Anno
{
}
@ContainerFor
(
Anno
.
class
)
@interface
Annos
{
Anno
[]
value
();
}
@Anno
@Anno
class
ContainedBy
RetentionMismatch
{
}
class
Repeatable
RetentionMismatch
{
}
test/tools/javac/diags/examples/
ContainedBy
TargetMismatch.java
→
test/tools/javac/diags/examples/
Repeatable
TargetMismatch.java
浏览文件 @
d2f83671
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012,
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
...
...
@@ -21,15 +21,14 @@
* questions.
*/
// key: compiler.err.invalid.
containedby
.annotation.incompatible.target
// key: compiler.err.invalid.
repeatable
.annotation.incompatible.target
import
java.lang.annotation.*
;
@
ContainedBy
(
Annos
.
class
)
@
Repeatable
(
Annos
.
class
)
@Target
(
ElementType
.
METHOD
)
@interface
Anno
{
}
@ContainerFor
(
Anno
.
class
)
@interface
Annos
{
Anno
[]
value
();
}
class
ContainedBy
TargetMismatch
{
}
class
Repeatable
TargetMismatch
{
}
test/tools/javac/diags/examples/
ContainedBy
WrongValueType.java
→
test/tools/javac/diags/examples/
Repeatable
WrongValueType.java
浏览文件 @
d2f83671
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012,
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
...
...
@@ -21,16 +21,15 @@
* questions.
*/
// key: compiler.err.invalid.
containedby
.annotation.value.return
// key: compiler.err.invalid.
repeatable
.annotation.value.return
import
java.lang.annotation.*
;
@
ContainedBy
(
Annos
.
class
)
@
Repeatable
(
Annos
.
class
)
@interface
Anno
{
}
@ContainerFor
(
Anno
.
class
)
@interface
Annos
{
String
value
();
}
@Anno
@Anno
class
ContainedBy
WrongValueType
{
}
class
Repeatable
WrongValueType
{
}
test/tools/javac/diags/examples/RepeatingAnnotationAndContainer.java
浏览文件 @
d2f83671
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012,
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
...
...
@@ -21,14 +21,13 @@
* questions.
*/
// key: compiler.err.invalid.
containedby
.annotation.repeated.and.container.present
// key: compiler.err.invalid.
repeatable
.annotation.repeated.and.container.present
import
java.lang.annotation.*
;
@
ContainedBy
(
Annos
.
class
)
@
Repeatable
(
Annos
.
class
)
@interface
Anno
{
}
@ContainerFor
(
Anno
.
class
)
@interface
Annos
{
Anno
[]
value
();
}
@Anno
...
...
test/tools/javac/diags/examples/WrongContainedBy.java
已删除
100644 → 0
浏览文件 @
a9b3c8d3
/*
* Copyright (c) 2012, 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.
*/
// key: compiler.err.invalid.container.no.containerfor
// key: compiler.err.invalid.container.wrong.containedby
import
java.lang.annotation.*
;
@ContainerFor
(
WrongContainedBy
.
class
)
@interface
Foos
{
WrongContainedBy
[]
value
();
}
@ContainedBy
(
Target
.
class
)
public
@interface
WrongContainedBy
{}
test/tools/javac/diags/examples/WrongContainerFor.java
已删除
100644 → 0
浏览文件 @
a9b3c8d3
/*
* Copyright (c) 2012, 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.
*/
// key: compiler.err.invalid.container.wrong.containerfor
// key: compiler.err.invalid.container.no.containedby
import
java.lang.annotation.*
;
@ContainerFor
(
Retention
.
class
)
@interface
Foos
{
WrongContainerFor
[]
value
();
}
@ContainedBy
(
Foos
.
class
)
public
@interface
WrongContainerFor
{}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录