Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
b37390b8
S
spring-framework
项目概览
爱吃血肠
/
spring-framework
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
spring-framework
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
b37390b8
编写于
6月 11, 2019
作者:
J
Juergen Hoeller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Restore javax meta-annotation lookup behavior
Closes gh-22957
上级
fd159ad0
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
64 addition
and
6 deletion
+64
-6
spring-core/spring-core.gradle
spring-core/spring-core.gradle
+1
-0
spring-core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java
.../org/springframework/core/annotation/AnnotationUtils.java
+1
-1
spring-core/src/test/java/org/springframework/core/annotation/AnnotatedElementUtilsTests.java
...framework/core/annotation/AnnotatedElementUtilsTests.java
+62
-5
未找到文件。
spring-core/spring-core.gradle
浏览文件 @
b37390b8
...
...
@@ -80,6 +80,7 @@ dependencies {
optional
(
"io.netty:netty-buffer"
)
testCompile
(
"io.projectreactor:reactor-test"
)
testCompile
(
"org.apache.tomcat.embed:tomcat-embed-core:${tomcatVersion}"
)
testCompile
(
"com.google.code.findbugs:jsr305:3.0.2"
)
testCompile
(
"org.xmlunit:xmlunit-matchers:2.6.2"
)
testCompile
(
"javax.xml.bind:jaxb-api:2.3.1"
)
testCompile
(
"com.fasterxml.woodstox:woodstox-core:5.2.0"
)
{
...
...
spring-core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java
浏览文件 @
b37390b8
...
...
@@ -956,7 +956,7 @@ public abstract class AnnotationUtils {
return
false
;
}
String
name
=
clazz
.
getName
();
return
(
name
.
startsWith
(
"java"
)
||
name
.
startsWith
(
"org.springframework.lang."
));
return
(
name
.
startsWith
(
"java
.
"
)
||
name
.
startsWith
(
"org.springframework.lang."
));
}
/**
...
...
spring-core/src/test/java/org/springframework/core/annotation/AnnotatedElementUtilsTests.java
浏览文件 @
b37390b8
/*
* Copyright 2002-201
8
the original author or authors.
* Copyright 2002-201
9
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -17,6 +17,7 @@
package
org.springframework.core.annotation
;
import
java.lang.annotation.Annotation
;
import
java.lang.annotation.Documented
;
import
java.lang.annotation.ElementType
;
import
java.lang.annotation.Inherited
;
import
java.lang.annotation.Retention
;
...
...
@@ -28,7 +29,10 @@ import java.lang.reflect.Method;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Set
;
import
javax.annotation.Nonnull
;
import
javax.annotation.ParametersAreNonnullByDefault
;
import
javax.annotation.Resource
;
import
javax.annotation.meta.When
;
import
org.junit.Ignore
;
import
org.junit.Rule
;
...
...
@@ -36,6 +40,7 @@ import org.junit.Test;
import
org.junit.internal.ArrayComparisonFailure
;
import
org.junit.rules.ExpectedException
;
import
org.springframework.lang.NonNullApi
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Indexed
;
import
org.springframework.util.Assert
;
...
...
@@ -118,6 +123,14 @@ public class AnnotatedElementUtilsTests {
assertFalse
(
hasMetaAnnotationTypes
(
ComposedTransactionalComponentClass
.
class
,
ComposedTransactionalComponent
.
class
.
getName
()));
}
@Test
public
void
isAnnotatedForPlainTypes
()
{
assertTrue
(
isAnnotated
(
Order
.
class
,
Documented
.
class
));
assertTrue
(
isAnnotated
(
NonNullApi
.
class
,
Documented
.
class
));
assertTrue
(
isAnnotated
(
NonNullApi
.
class
,
Nonnull
.
class
));
assertTrue
(
isAnnotated
(
ParametersAreNonnullByDefault
.
class
,
Nonnull
.
class
));
}
@Test
public
void
isAnnotatedOnNonAnnotatedClass
()
{
assertFalse
(
isAnnotated
(
NonAnnotatedClass
.
class
,
TX_NAME
));
...
...
@@ -147,6 +160,14 @@ public class AnnotatedElementUtilsTests {
assertTrue
(
isAnnotated
(
ComposedTransactionalComponentClass
.
class
,
ComposedTransactionalComponent
.
class
.
getName
()));
}
@Test
public
void
hasAnnotationForPlainTypes
()
{
assertTrue
(
hasAnnotation
(
Order
.
class
,
Documented
.
class
));
assertTrue
(
hasAnnotation
(
NonNullApi
.
class
,
Documented
.
class
));
assertTrue
(
hasAnnotation
(
NonNullApi
.
class
,
Nonnull
.
class
));
assertTrue
(
hasAnnotation
(
ParametersAreNonnullByDefault
.
class
,
Nonnull
.
class
));
}
@Test
public
void
getAllAnnotationAttributesOnNonAnnotatedClass
()
{
assertNull
(
getAllAnnotationAttributes
(
NonAnnotatedClass
.
class
,
TX_NAME
));
...
...
@@ -207,6 +228,22 @@ public class AnnotatedElementUtilsTests {
attributes
.
get
(
"value"
));
}
@Test
public
void
getAllAnnotationAttributesOnLangType
()
{
MultiValueMap
<
String
,
Object
>
attributes
=
getAllAnnotationAttributes
(
NonNullApi
.
class
,
Nonnull
.
class
.
getName
());
assertNotNull
(
attributes
);
assertEquals
(
asList
(
When
.
ALWAYS
),
attributes
.
get
(
"when"
));
}
@Test
public
void
getAllAnnotationAttributesOnJavaxType
()
{
MultiValueMap
<
String
,
Object
>
attributes
=
getAllAnnotationAttributes
(
ParametersAreNonnullByDefault
.
class
,
Nonnull
.
class
.
getName
());
assertNotNull
(
attributes
);
assertEquals
(
asList
(
When
.
ALWAYS
),
attributes
.
get
(
"when"
));
}
@Test
public
void
getMergedAnnotationAttributesOnClassWithLocalAnnotation
()
{
Class
<?>
element
=
TxConfig
.
class
;
...
...
@@ -701,14 +738,33 @@ public class AnnotatedElementUtilsTests {
@Test
public
void
javaLangAnnotationTypeViaFindMergedAnnotation
()
throws
Exception
{
Constructor
<?>
deprecatedCtor
=
Date
.
class
.
getConstructor
(
String
.
class
);
assertEquals
(
deprecatedCtor
.
getAnnotation
(
Deprecated
.
class
),
findMergedAnnotation
(
deprecatedCtor
,
Deprecated
.
class
));
assertEquals
(
Date
.
class
.
getAnnotation
(
Deprecated
.
class
),
findMergedAnnotation
(
Date
.
class
,
Deprecated
.
class
));
assertEquals
(
deprecatedCtor
.
getAnnotation
(
Deprecated
.
class
),
findMergedAnnotation
(
deprecatedCtor
,
Deprecated
.
class
));
assertEquals
(
Date
.
class
.
getAnnotation
(
Deprecated
.
class
),
findMergedAnnotation
(
Date
.
class
,
Deprecated
.
class
));
}
@Test
public
void
javaxAnnotationTypeViaFindMergedAnnotation
()
throws
Exception
{
assertEquals
(
ResourceHolder
.
class
.
getAnnotation
(
Resource
.
class
),
findMergedAnnotation
(
ResourceHolder
.
class
,
Resource
.
class
));
assertEquals
(
SpringAppConfigClass
.
class
.
getAnnotation
(
Resource
.
class
),
findMergedAnnotation
(
SpringAppConfigClass
.
class
,
Resource
.
class
));
assertEquals
(
ResourceHolder
.
class
.
getAnnotation
(
Resource
.
class
),
findMergedAnnotation
(
ResourceHolder
.
class
,
Resource
.
class
));
assertEquals
(
SpringAppConfigClass
.
class
.
getAnnotation
(
Resource
.
class
),
findMergedAnnotation
(
SpringAppConfigClass
.
class
,
Resource
.
class
));
}
@Test
public
void
javaxMetaAnnotationTypeViaFindMergedAnnotation
()
throws
Exception
{
assertEquals
(
ParametersAreNonnullByDefault
.
class
.
getAnnotation
(
Nonnull
.
class
),
findMergedAnnotation
(
ParametersAreNonnullByDefault
.
class
,
Nonnull
.
class
));
assertEquals
(
ParametersAreNonnullByDefault
.
class
.
getAnnotation
(
Nonnull
.
class
),
findMergedAnnotation
(
ResourceHolder
.
class
,
Nonnull
.
class
));
}
@Test
public
void
nullableAnnotationTypeViaFindMergedAnnotation
()
throws
Exception
{
Method
method
=
TransactionalServiceImpl
.
class
.
getMethod
(
"doIt"
);
assertEquals
(
method
.
getAnnotation
(
Resource
.
class
),
findMergedAnnotation
(
method
,
Resource
.
class
));
assertEquals
(
method
.
getAnnotation
(
Resource
.
class
),
findMergedAnnotation
(
method
,
Resource
.
class
));
}
@Test
...
...
@@ -1288,6 +1344,7 @@ public class AnnotatedElementUtilsTests {
}
@Resource
(
name
=
"x"
)
@ParametersAreNonnullByDefault
static
class
ResourceHolder
{
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录