Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
5780b5a8
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
4
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_jdk
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
5780b5a8
编写于
2月 13, 2013
作者:
J
jfranck
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8007278: Rename j.l.r.AnnotatedElement.getAnnotations(Class) to getAnnotationsByType(Class)
Reviewed-by: darcy, abuckley
上级
f2141189
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
120 addition
and
72 deletion
+120
-72
src/share/classes/java/lang/Class.java
src/share/classes/java/lang/Class.java
+5
-2
src/share/classes/java/lang/Package.java
src/share/classes/java/lang/Package.java
+7
-4
src/share/classes/java/lang/reflect/AccessibleObject.java
src/share/classes/java/lang/reflect/AccessibleObject.java
+9
-6
src/share/classes/java/lang/reflect/AnnotatedElement.java
src/share/classes/java/lang/reflect/AnnotatedElement.java
+60
-27
src/share/classes/java/lang/reflect/Executable.java
src/share/classes/java/lang/reflect/Executable.java
+2
-1
src/share/classes/java/lang/reflect/Field.java
src/share/classes/java/lang/reflect/Field.java
+2
-1
src/share/classes/java/lang/reflect/Parameter.java
src/share/classes/java/lang/reflect/Parameter.java
+5
-3
src/share/classes/sun/reflect/annotation/AnnotatedTypeFactory.java
.../classes/sun/reflect/annotation/AnnotatedTypeFactory.java
+3
-3
src/share/classes/sun/reflect/generics/reflectiveObjects/TypeVariableImpl.java
.../reflect/generics/reflectiveObjects/TypeVariableImpl.java
+5
-3
test/java/lang/annotation/TypeParamAnnotation.java
test/java/lang/annotation/TypeParamAnnotation.java
+2
-2
test/java/lang/annotation/repeatingAnnotations/RepeatedUnitTest.java
...ang/annotation/repeatingAnnotations/RepeatedUnitTest.java
+20
-20
未找到文件。
src/share/classes/java/lang/Class.java
浏览文件 @
5780b5a8
...
...
@@ -3087,7 +3087,8 @@ public final
* @throws NullPointerException {@inheritDoc}
* @since 1.8
*/
public
<
A
extends
Annotation
>
A
[]
getAnnotations
(
Class
<
A
>
annotationClass
)
{
@Override
public
<
A
extends
Annotation
>
A
[]
getAnnotationsByType
(
Class
<
A
>
annotationClass
)
{
Objects
.
requireNonNull
(
annotationClass
);
initAnnotationsIfNecessary
();
...
...
@@ -3106,6 +3107,7 @@ public final
* @throws NullPointerException {@inheritDoc}
* @since 1.8
*/
@Override
@SuppressWarnings
(
"unchecked"
)
public
<
A
extends
Annotation
>
A
getDeclaredAnnotation
(
Class
<
A
>
annotationClass
)
{
Objects
.
requireNonNull
(
annotationClass
);
...
...
@@ -3118,7 +3120,8 @@ public final
* @throws NullPointerException {@inheritDoc}
* @since 1.8
*/
public
<
A
extends
Annotation
>
A
[]
getDeclaredAnnotations
(
Class
<
A
>
annotationClass
)
{
@Override
public
<
A
extends
Annotation
>
A
[]
getDeclaredAnnotationsByType
(
Class
<
A
>
annotationClass
)
{
Objects
.
requireNonNull
(
annotationClass
);
initAnnotationsIfNecessary
();
...
...
src/share/classes/java/lang/Package.java
浏览文件 @
5780b5a8
...
...
@@ -389,8 +389,9 @@ public class Package implements java.lang.reflect.AnnotatedElement {
* @throws NullPointerException {@inheritDoc}
* @since 1.8
*/
public
<
A
extends
Annotation
>
A
[]
getAnnotations
(
Class
<
A
>
annotationClass
)
{
return
getPackageInfo
().
getAnnotations
(
annotationClass
);
@Override
public
<
A
extends
Annotation
>
A
[]
getAnnotationsByType
(
Class
<
A
>
annotationClass
)
{
return
getPackageInfo
().
getAnnotationsByType
(
annotationClass
);
}
/**
...
...
@@ -404,6 +405,7 @@ public class Package implements java.lang.reflect.AnnotatedElement {
* @throws NullPointerException {@inheritDoc}
* @since 1.8
*/
@Override
public
<
A
extends
Annotation
>
A
getDeclaredAnnotation
(
Class
<
A
>
annotationClass
)
{
return
getPackageInfo
().
getDeclaredAnnotation
(
annotationClass
);
}
...
...
@@ -412,8 +414,9 @@ public class Package implements java.lang.reflect.AnnotatedElement {
* @throws NullPointerException {@inheritDoc}
* @since 1.8
*/
public
<
A
extends
Annotation
>
A
[]
getDeclaredAnnotations
(
Class
<
A
>
annotationClass
)
{
return
getPackageInfo
().
getDeclaredAnnotations
(
annotationClass
);
@Override
public
<
A
extends
Annotation
>
A
[]
getDeclaredAnnotationsByType
(
Class
<
A
>
annotationClass
)
{
return
getPackageInfo
().
getDeclaredAnnotationsByType
(
annotationClass
);
}
/**
...
...
src/share/classes/java/lang/reflect/AccessibleObject.java
浏览文件 @
5780b5a8
/*
* Copyright (c) 1997, 201
2
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 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
...
...
@@ -184,7 +184,8 @@ public class AccessibleObject implements AnnotatedElement {
* @throws NullPointerException {@inheritDoc}
* @since 1.8
*/
public
<
T
extends
Annotation
>
T
[]
getAnnotations
(
Class
<
T
>
annotationClass
)
{
@Override
public
<
T
extends
Annotation
>
T
[]
getAnnotationsByType
(
Class
<
T
>
annotationClass
)
{
throw
new
AssertionError
(
"All subclasses should override this method"
);
}
...
...
@@ -199,6 +200,7 @@ public class AccessibleObject implements AnnotatedElement {
* @throws NullPointerException {@inheritDoc}
* @since 1.8
*/
@Override
public
<
T
extends
Annotation
>
T
getDeclaredAnnotation
(
Class
<
T
>
annotationClass
)
{
// Only annotations on classes are inherited, for all other
// objects getDeclaredAnnotation is the same as
...
...
@@ -210,11 +212,12 @@ public class AccessibleObject implements AnnotatedElement {
* @throws NullPointerException {@inheritDoc}
* @since 1.8
*/
public
<
T
extends
Annotation
>
T
[]
getDeclaredAnnotations
(
Class
<
T
>
annotationClass
)
{
@Override
public
<
T
extends
Annotation
>
T
[]
getDeclaredAnnotationsByType
(
Class
<
T
>
annotationClass
)
{
// Only annotations on classes are inherited, for all other
// objects getDeclaredAnnotations is the same as
// getAnnotations.
return
getAnnotations
(
annotationClass
);
// objects getDeclaredAnnotations
ByType
is the same as
// getAnnotations
ByType
.
return
getAnnotations
ByType
(
annotationClass
);
}
/**
...
...
src/share/classes/java/lang/reflect/AnnotatedElement.java
浏览文件 @
5780b5a8
...
...
@@ -35,22 +35,43 @@ import java.lang.annotation.Annotation;
* arrays returned by accessors for array-valued enum members; it will
* have no affect on the arrays returned to other callers.
*
* <p>An annotation A is <em>directly present</em> on an element E if the
* RuntimeVisibleAnnotations or RuntimeVisibleParameterAnnotations attribute
* associated with E either:
* <p>The {@link #getAnnotationsByType(Class)} and {@link
* #getDeclaredAnnotationsByType(Class)} methods support multiple
* annotations of the same type on an element. If the argument to either method
* is a repeatable annotation type (JLS 9.6), then the method will "look
* through" a container annotation (JLS 9.7) which was generated at
* compile-time to wrap multiple annotations of the argument type.
*
* <p>The terms <em>directly present</em> and <em>present</em> are used
* throughout this interface to describe precisely which annotations are
* returned by methods:
*
* <ul>
* <li>An annotation A is <em>directly present</em> on an element E if E is
* associated with a RuntimeVisibleAnnotations or
* RuntimeVisibleParameterAnnotations attribute, and:
*
* <ul>
* <li>contains A; or
* <li>for invocations of get[Declared]Annotations(Class<T>),
* contains A or exactly one annotation C whose type is the containing
* annotation type of A's type (JLS 9.6) and whose value element contains A
* <li>for an invocation of {@code get[Declared]Annotation(Class<T>)} or
* {@code get[Declared]Annotations()}, the attribute contains A.
*
* <li>for an invocation of {@code get[Declared]AnnotationsByType(Class<T>)}, the
* attribute either contains A or, if the type of A is repeatable, contains
* exactly one annotation whose value element contains A and whose type is the
* containing annotation type of A's type (JLS 9.6).
* </ul>
*
* <p>An annotation A is <em>present</em> on an element E if either:
* <p>
* <li>An annotation A is <em>present</em> on an element E if either:
*
* <ul>
* <li>A is <em>directly present</em> on E; or
* <li>There are no annotations of A's type which are <em>directly present</em>
* on E, and E is a class, and A's type is inheritable (JLS 9.6.3.3), and A is
* present on the superclass of E
*
* <li>A is not <em>directly present</em> on E, and E is a class, and A's type
* is inheritable (JLS 9.6.3.3), and A is <em>present</em> on the superclass of
* E.
* </ul>
*
* </ul>
*
* <p>If an annotation returned by a method in this interface contains
...
...
@@ -119,12 +140,19 @@ public interface AnnotatedElement {
<
T
extends
Annotation
>
T
getAnnotation
(
Class
<
T
>
annotationClass
);
/**
* Returns an array of all this element's annotations for the
* specified type if one or more of such annotation is present,
* else an array of length zero.
* Returns annotations that are <em>present</em> on this element.
*
* If there are no annotations <em>present</em> on this element, the return
* value is an array of length 0.
*
* The caller of this method is free to modify the returned array;
* it will have no effect on the arrays returned to other callers.
* The difference between this method and {@link #getAnnotation(Class)}
* is that this method detects if its argument is a <em>repeatable
* annotation type</em> (JLS 9.6), and if so, attempts to find one or
* more annotations of that type by "looking through" a container
* annotation.
*
* The caller of this method is free to modify the returned array; it will
* have no effect on the arrays returned to other callers.
*
* @param annotationClass the Class object corresponding to the
* annotation type
...
...
@@ -133,7 +161,7 @@ public interface AnnotatedElement {
* @throws NullPointerException if the given annotation class is null
* @since 1.8
*/
<
T
extends
Annotation
>
T
[]
getAnnotations
(
Class
<
T
>
annotationClass
);
<
T
extends
Annotation
>
T
[]
getAnnotations
ByType
(
Class
<
T
>
annotationClass
);
/**
* Returns annotations that are <em>present</em> on this element.
...
...
@@ -165,16 +193,21 @@ public interface AnnotatedElement {
*/
<
T
extends
Annotation
>
T
getDeclaredAnnotation
(
Class
<
T
>
annotationClass
);
/**
* Returns an array of all this element's annotations for the
* specified type if one or more of such annotation is directly
* present, else an array of length zero.
/**
* Returns annotations that are <em>directly present</em> on this element.
* This method ignores inherited annotations.
*
* This method ignores inherited annotations. (Returns
* an array of length zero if no annotations are directly present
* on this element.) The caller of this method is free to modify
* the returned array; it will have no effect on the arrays
* returned to other callers.
* If there are no annotations <em>directly present</em> on this element,
* the return value is an array of length 0.
*
* The difference between this method and {@link
* #getDeclaredAnnotation(Class)} is that this method detects if its
* argument is a <em>repeatable annotation type</em> (JLS 9.6), and if so,
* attempts to find one or more annotations of that type by "looking
* through" a container annotation.
*
* The caller of this method is free to modify the returned array; it will
* have no effect on the arrays returned to other callers.
*
* @param annotationClass the Class object corresponding to the
* annotation type
...
...
@@ -183,7 +216,7 @@ public interface AnnotatedElement {
* @throws NullPointerException if the given annotation class is null
* @since 1.8
*/
<
T
extends
Annotation
>
T
[]
getDeclaredAnnotations
(
Class
<
T
>
annotationClass
);
<
T
extends
Annotation
>
T
[]
getDeclaredAnnotations
ByType
(
Class
<
T
>
annotationClass
);
/**
* Returns annotations that are <em>directly present</em> on this element.
...
...
src/share/classes/java/lang/reflect/Executable.java
浏览文件 @
5780b5a8
...
...
@@ -449,7 +449,8 @@ public abstract class Executable extends AccessibleObject
* @throws NullPointerException {@inheritDoc}
* @since 1.8
*/
public
<
T
extends
Annotation
>
T
[]
getAnnotations
(
Class
<
T
>
annotationClass
)
{
@Override
public
<
T
extends
Annotation
>
T
[]
getAnnotationsByType
(
Class
<
T
>
annotationClass
)
{
Objects
.
requireNonNull
(
annotationClass
);
return
AnnotationSupport
.
getMultipleAnnotations
(
declaredAnnotations
(),
annotationClass
);
...
...
src/share/classes/java/lang/reflect/Field.java
浏览文件 @
5780b5a8
...
...
@@ -1029,7 +1029,8 @@ class Field extends AccessibleObject implements Member {
* @throws NullPointerException {@inheritDoc}
* @since 1.8
*/
public
<
T
extends
Annotation
>
T
[]
getAnnotations
(
Class
<
T
>
annotationClass
)
{
@Override
public
<
T
extends
Annotation
>
T
[]
getAnnotationsByType
(
Class
<
T
>
annotationClass
)
{
Objects
.
requireNonNull
(
annotationClass
);
return
AnnotationSupport
.
getMultipleAnnotations
(
declaredAnnotations
(),
annotationClass
);
...
...
src/share/classes/java/lang/reflect/Parameter.java
浏览文件 @
5780b5a8
...
...
@@ -258,7 +258,8 @@ public final class Parameter implements AnnotatedElement {
* {@inheritDoc}
* @throws NullPointerException {@inheritDoc}
*/
public
<
T
extends
Annotation
>
T
[]
getAnnotations
(
Class
<
T
>
annotationClass
)
{
@Override
public
<
T
extends
Annotation
>
T
[]
getAnnotationsByType
(
Class
<
T
>
annotationClass
)
{
Objects
.
requireNonNull
(
annotationClass
);
return
AnnotationSupport
.
getMultipleAnnotations
(
declaredAnnotations
(),
annotationClass
);
...
...
@@ -284,11 +285,12 @@ public final class Parameter implements AnnotatedElement {
/**
* @throws NullPointerException {@inheritDoc}
*/
public
<
T
extends
Annotation
>
T
[]
getDeclaredAnnotations
(
Class
<
T
>
annotationClass
)
{
@Override
public
<
T
extends
Annotation
>
T
[]
getDeclaredAnnotationsByType
(
Class
<
T
>
annotationClass
)
{
// Only annotations on classes are inherited, for all other
// objects getDeclaredAnnotations is the same as
// getAnnotations.
return
getAnnotations
(
annotationClass
);
return
getAnnotations
ByType
(
annotationClass
);
}
/**
...
...
src/share/classes/sun/reflect/annotation/AnnotatedTypeFactory.java
浏览文件 @
5780b5a8
...
...
@@ -148,8 +148,8 @@ public class AnnotatedTypeFactory {
}
@Override
public
final
<
T
extends
Annotation
>
T
[]
getAnnotations
(
Class
<
T
>
annotation
)
{
return
getDeclaredAnnotations
(
annotation
);
public
final
<
T
extends
Annotation
>
T
[]
getAnnotations
ByType
(
Class
<
T
>
annotation
)
{
return
getDeclaredAnnotations
ByType
(
annotation
);
}
@Override
...
...
@@ -164,7 +164,7 @@ public class AnnotatedTypeFactory {
}
@Override
public
<
T
extends
Annotation
>
T
[]
getDeclaredAnnotations
(
Class
<
T
>
annotation
)
{
public
<
T
extends
Annotation
>
T
[]
getDeclaredAnnotations
ByType
(
Class
<
T
>
annotation
)
{
return
AnnotationSupport
.
getMultipleAnnotations
(
annotations
,
annotation
);
}
...
...
src/share/classes/sun/reflect/generics/reflectiveObjects/TypeVariableImpl.java
浏览文件 @
5780b5a8
...
...
@@ -200,14 +200,16 @@ public class TypeVariableImpl<D extends GenericDeclaration>
return
getAnnotation
(
annotationClass
);
}
public
<
T
extends
Annotation
>
T
[]
getAnnotations
(
Class
<
T
>
annotationClass
)
{
@Override
public
<
T
extends
Annotation
>
T
[]
getAnnotationsByType
(
Class
<
T
>
annotationClass
)
{
Objects
.
requireNonNull
(
annotationClass
);
return
AnnotationSupport
.
getMultipleAnnotations
(
mapAnnotations
(
getAnnotations
()),
annotationClass
);
}
public
<
T
extends
Annotation
>
T
[]
getDeclaredAnnotations
(
Class
<
T
>
annotationClass
)
{
@Override
public
<
T
extends
Annotation
>
T
[]
getDeclaredAnnotationsByType
(
Class
<
T
>
annotationClass
)
{
Objects
.
requireNonNull
(
annotationClass
);
return
getAnnotations
(
annotationClass
);
return
getAnnotations
ByType
(
annotationClass
);
}
public
Annotation
[]
getAnnotations
()
{
...
...
test/java/lang/annotation/TypeParamAnnotation.java
浏览文件 @
5780b5a8
...
...
@@ -23,7 +23,7 @@
/*
* @test
* @bug 8004698
* @bug 8004698
8007278
* @summary Unit test for annotations on TypeVariables
*/
...
...
@@ -93,7 +93,7 @@ public class TypeParamAnnotation {
private
static
void
testGetAnnos
()
throws
Exception
{
TypeVariable
<?>[]
ts
=
TypeParam
.
class
.
getDeclaredMethod
(
"foo"
).
getTypeParameters
();
ParamAnno2
[]
as
;
as
=
ts
[
0
].
getAnnotations
(
ParamAnno2
.
class
);
as
=
ts
[
0
].
getAnnotations
ByType
(
ParamAnno2
.
class
);
check
(
as
.
length
==
1
);
check
(
as
[
0
].
value
()
==
3
);
}
...
...
test/java/lang/annotation/repeatingAnnotations/RepeatedUnitTest.java
浏览文件 @
5780b5a8
...
...
@@ -23,7 +23,7 @@
/*
* @test
* @bug 7154390 8005712
* @bug 7154390 8005712
8007278
* @summary Unit test for repeated annotation reflection
*
* @compile RepeatedUnitTest.java subpackage/package-info.java subpackage/Container.java subpackage/Containee.java subpackage/NonRepeated.java subpackage/InheritedContainee.java subpackage/InheritedContainer.java subpackage/InheritedNonRepeated.java
...
...
@@ -76,7 +76,7 @@ public class RepeatedUnitTest {
check
(
1
==
countAnnotation
(
e
,
NonRepeated
.
class
));
nr
=
e
.
getAnnotations
(
NonRepeated
.
class
)[
0
];
nr
=
e
.
getAnnotations
ByType
(
NonRepeated
.
class
)[
0
];
check
(
nr
.
value
()
==
10
);
check
(
1
==
containsAnnotationOfType
(
e
.
getAnnotations
(),
NonRepeated
.
class
));
...
...
@@ -87,9 +87,9 @@ public class RepeatedUnitTest {
check
(
c
==
null
);
check
(
2
==
countAnnotation
(
e
,
Containee
.
class
));
c
=
e
.
getAnnotations
(
Containee
.
class
)[
0
];
c
=
e
.
getAnnotations
ByType
(
Containee
.
class
)[
0
];
check
(
c
.
value
()
==
1
);
c
=
e
.
getAnnotations
(
Containee
.
class
)[
1
];
c
=
e
.
getAnnotations
ByType
(
Containee
.
class
)[
1
];
check
(
c
.
value
()
==
2
);
check
(
0
==
containsAnnotationOfType
(
e
.
getAnnotations
(),
Containee
.
class
));
...
...
@@ -98,7 +98,7 @@ public class RepeatedUnitTest {
static
void
packageContainer
(
AnnotatedElement
e
)
{
Container
cr
=
e
.
getAnnotation
(
Container
.
class
);
check
(
null
!=
cr
);
check
(
1
==
containsAnnotationOfType
(
e
.
getAnnotations
(
Container
.
class
),
Container
.
class
));
check
(
1
==
containsAnnotationOfType
(
e
.
getAnnotations
ByType
(
Container
.
class
),
Container
.
class
));
check
(
1
==
countAnnotation
(
e
,
Container
.
class
));
}
...
...
@@ -123,10 +123,10 @@ public class RepeatedUnitTest {
check
(
1
==
countAnnotation
(
e
,
NonRepeated
.
class
));
check
(
1
==
countAnnotation
(
e
,
InheritedNonRepeated
.
class
));
check
(
e
.
getAnnotations
(
Containee
.
class
)[
2
].
value
()
==
300
);
check
(
e
.
getAnnotations
(
InheritedContainee
.
class
)[
2
].
value
()
==
300
);
check
(
e
.
getAnnotations
(
InheritedNonRepeated
.
class
)[
0
].
value
()
==
200
);
check
(
e
.
getAnnotations
(
NonRepeated
.
class
)[
0
].
value
()
==
100
);
check
(
e
.
getAnnotations
ByType
(
Containee
.
class
)[
2
].
value
()
==
300
);
check
(
e
.
getAnnotations
ByType
(
InheritedContainee
.
class
)[
2
].
value
()
==
300
);
check
(
e
.
getAnnotations
ByType
(
InheritedNonRepeated
.
class
)[
0
].
value
()
==
200
);
check
(
e
.
getAnnotations
ByType
(
NonRepeated
.
class
)[
0
].
value
()
==
100
);
}
static
void
inheritedMe3
()
{
...
...
@@ -138,8 +138,8 @@ public class RepeatedUnitTest {
check
(
0
==
countAnnotation
(
e
,
Container
.
class
));
check
(
1
==
countAnnotation
(
e
,
InheritedContainer
.
class
));
check
(
e
.
getAnnotations
(
InheritedContainee
.
class
)[
2
].
value
()
==
350
);
check
(
e
.
getAnnotations
(
InheritedNonRepeated
.
class
)[
0
].
value
()
==
15
);
check
(
e
.
getAnnotations
ByType
(
InheritedContainee
.
class
)[
2
].
value
()
==
350
);
check
(
e
.
getAnnotations
ByType
(
InheritedNonRepeated
.
class
)[
0
].
value
()
==
15
);
}
static
void
inheritedMe4
()
{
...
...
@@ -153,24 +153,24 @@ public class RepeatedUnitTest {
check
(
1
==
countAnnotation
(
e
,
NonRepeated
.
class
));
check
(
1
==
countAnnotation
(
e
,
InheritedNonRepeated
.
class
));
check
(
e
.
getAnnotations
(
Containee
.
class
)[
2
].
value
()
==
3000
);
check
(
e
.
getAnnotations
(
InheritedContainee
.
class
)[
2
].
value
()
==
3000
);
check
(
e
.
getAnnotations
(
InheritedNonRepeated
.
class
)[
0
].
value
()
==
2000
);
check
(
e
.
getAnnotations
(
NonRepeated
.
class
)[
0
].
value
()
==
1000
);
check
(
e
.
getAnnotations
ByType
(
Containee
.
class
)[
2
].
value
()
==
3000
);
check
(
e
.
getAnnotations
ByType
(
InheritedContainee
.
class
)[
2
].
value
()
==
3000
);
check
(
e
.
getAnnotations
ByType
(
InheritedNonRepeated
.
class
)[
0
].
value
()
==
2000
);
check
(
e
.
getAnnotations
ByType
(
NonRepeated
.
class
)[
0
].
value
()
==
1000
);
}
static
void
checkMultiplier
(
AnnotatedElement
e
,
int
m
)
{
// Basic sanity of non-repeating getAnnotation(Class)
check
(
e
.
getAnnotation
(
NonRepeated
.
class
).
value
()
==
5
*
m
);
// Check count of annotations returned from getAnnotations(Class)
// Check count of annotations returned from getAnnotations
ByType
(Class)
check
(
4
==
countAnnotation
(
e
,
Containee
.
class
));
check
(
1
==
countAnnotation
(
e
,
Container
.
class
));
check
(
1
==
countAnnotation
(
e
,
NonRepeated
.
class
));
// Check contents of array returned from getAnnotations(Class)
check
(
e
.
getAnnotations
(
Containee
.
class
)[
2
].
value
()
==
3
*
m
);
check
(
e
.
getAnnotations
(
NonRepeated
.
class
)[
0
].
value
()
==
5
*
m
);
// Check contents of array returned from getAnnotations
ByType
(Class)
check
(
e
.
getAnnotations
ByType
(
Containee
.
class
)[
2
].
value
()
==
3
*
m
);
check
(
e
.
getAnnotations
ByType
(
NonRepeated
.
class
)[
0
].
value
()
==
5
*
m
);
// Check getAnnotation(Class)
check
(
e
.
getAnnotation
(
Containee
.
class
)
==
null
);
...
...
@@ -187,7 +187,7 @@ public class RepeatedUnitTest {
}
static
int
countAnnotation
(
AnnotatedElement
e
,
Class
<?
extends
Annotation
>
c
)
{
return
containsAnnotationOfType
(
e
.
getAnnotations
(
c
),
c
);
return
containsAnnotationOfType
(
e
.
getAnnotations
ByType
(
c
),
c
);
}
static
<
A
extends
Annotation
>
int
containsAnnotationOfType
(
A
[]
l
,
Class
<?
extends
Annotation
>
a
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录