Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
57d98013
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,体验更适合开发者的 AI 搜索 >>
提交
57d98013
编写于
12月 03, 2015
作者:
J
Juergen Hoeller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Avoid mismatch between cached top-level versus nested parameter type
Issue: SPR-13755 (cherry picked from commit
c909789e
)
上级
ff8bbc93
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
36 addition
and
25 deletion
+36
-25
spring-core/src/main/java/org/springframework/core/GenericTypeResolver.java
...in/java/org/springframework/core/GenericTypeResolver.java
+13
-13
spring-core/src/main/java/org/springframework/core/ResolvableType.java
...rc/main/java/org/springframework/core/ResolvableType.java
+23
-12
未找到文件。
spring-core/src/main/java/org/springframework/core/GenericTypeResolver.java
浏览文件 @
57d98013
/*
* Copyright 2002-201
3
the original author or authors.
* Copyright 2002-201
5
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.
...
...
@@ -51,28 +51,28 @@ public abstract class GenericTypeResolver {
/**
* Determine the target type for the given parameter specification.
* @param methodParam the method parameter specification
* @param methodParam
eter
the method parameter specification
* @return the corresponding generic parameter type
* @deprecated as of Spring 4.0, use {@link MethodParameter#getGenericParameterType()}
*/
@Deprecated
public
static
Type
getTargetType
(
MethodParameter
methodParam
)
{
Assert
.
notNull
(
methodParam
,
"MethodParameter must not be null"
);
return
methodParam
.
getGenericParameterType
();
public
static
Type
getTargetType
(
MethodParameter
methodParam
eter
)
{
Assert
.
notNull
(
methodParam
eter
,
"MethodParameter must not be null"
);
return
methodParam
eter
.
getGenericParameterType
();
}
/**
* Determine the target type for the given generic parameter type.
* @param methodParam the method parameter specification
* @param
clazz
the class to resolve type variables against
* @param methodParam
eter
the method parameter specification
* @param
implementationClass
the class to resolve type variables against
* @return the corresponding generic parameter or return type
*/
public
static
Class
<?>
resolveParameterType
(
MethodParameter
methodParam
,
Class
<?>
clazz
)
{
Assert
.
notNull
(
methodParam
,
"MethodParameter must not be null"
);
Assert
.
notNull
(
clazz
,
"Class must not be null"
);
methodParam
.
setContainingClass
(
clazz
);
methodParam
.
setParameterType
(
ResolvableType
.
forMethodParameter
(
methodParam
).
resolve
()
);
return
methodParam
.
getParameterType
();
public
static
Class
<?>
resolveParameterType
(
MethodParameter
methodParam
eter
,
Class
<?>
implementationClass
)
{
Assert
.
notNull
(
methodParam
eter
,
"MethodParameter must not be null"
);
Assert
.
notNull
(
implementationClass
,
"Class must not be null"
);
methodParam
eter
.
setContainingClass
(
implementationClass
);
ResolvableType
.
resolveMethodParameter
(
methodParameter
);
return
methodParam
eter
.
getParameterType
();
}
/**
...
...
spring-core/src/main/java/org/springframework/core/ResolvableType.java
浏览文件 @
57d98013
...
...
@@ -381,8 +381,7 @@ public final class ResolvableType implements Serializable {
return
NONE
;
}
if
(
this
.
superType
==
null
)
{
this
.
superType
=
forType
(
SerializableTypeWrapper
.
forGenericSuperclass
(
resolved
),
asVariableResolver
());
this
.
superType
=
forType
(
SerializableTypeWrapper
.
forGenericSuperclass
(
resolved
),
asVariableResolver
());
}
return
this
.
superType
;
}
...
...
@@ -399,8 +398,7 @@ public final class ResolvableType implements Serializable {
return
EMPTY_TYPES_ARRAY
;
}
if
(
this
.
interfaces
==
null
)
{
this
.
interfaces
=
forTypes
(
SerializableTypeWrapper
.
forGenericInterfaces
(
resolved
),
asVariableResolver
());
this
.
interfaces
=
forTypes
(
SerializableTypeWrapper
.
forGenericInterfaces
(
resolved
),
asVariableResolver
());
}
return
this
.
interfaces
;
}
...
...
@@ -1102,11 +1100,11 @@ public final class ResolvableType implements Serializable {
*/
public
static
ResolvableType
forMethodParameter
(
MethodParameter
methodParameter
,
ResolvableType
implementationType
)
{
Assert
.
notNull
(
methodParameter
,
"MethodParameter must not be null"
);
implementationType
=
(
implementationType
==
null
?
forType
(
methodParameter
.
getContainingClass
())
:
implementationType
);
implementationType
=
(
implementationType
!=
null
?
implementationType
:
forType
(
methodParameter
.
getContainingClass
()));
ResolvableType
owner
=
implementationType
.
as
(
methodParameter
.
getDeclaringClass
());
return
forType
(
null
,
new
MethodParameterTypeProvider
(
methodParameter
),
owner
.
asVariableResolver
()).
getNested
(
methodParameter
.
getNestingLevel
(),
methodParameter
.
typeIndexesPerLevel
);
return
forType
(
null
,
new
MethodParameterTypeProvider
(
methodParameter
),
owner
.
asVariableResolver
()).
getNested
(
methodParameter
.
getNestingLevel
(),
methodParameter
.
typeIndexesPerLevel
);
}
/**
...
...
@@ -1124,13 +1122,26 @@ public final class ResolvableType implements Serializable {
getNested
(
methodParameter
.
getNestingLevel
(),
methodParameter
.
typeIndexesPerLevel
);
}
/**
* Resolve the top-level parameter type of the given {@code MethodParameter}.
* @param methodParameter the method parameter to resolve
* @since 4.1.9
* @see MethodParameter#setParameterType
*/
static
void
resolveMethodParameter
(
MethodParameter
methodParameter
)
{
Assert
.
notNull
(
methodParameter
,
"MethodParameter must not be null"
);
ResolvableType
owner
=
forType
(
methodParameter
.
getContainingClass
()).
as
(
methodParameter
.
getDeclaringClass
());
methodParameter
.
setParameterType
(
forType
(
null
,
new
MethodParameterTypeProvider
(
methodParameter
),
owner
.
asVariableResolver
()).
resolve
());
}
/**
* Return a {@link ResolvableType} as a array of the specified {@code componentType}.
* @param componentType the component type
* @return a {@link ResolvableType} as an array of the specified component type
*/
public
static
ResolvableType
forArrayComponent
(
ResolvableType
componentType
)
{
Assert
.
notNull
(
componentType
,
"
componentT
ype must not be null"
);
Assert
.
notNull
(
componentType
,
"
Component t
ype must not be null"
);
Class
<?>
arrayClass
=
Array
.
newInstance
(
componentType
.
resolve
(),
0
).
getClass
();
return
new
ResolvableType
(
arrayClass
,
null
,
null
,
componentType
);
}
...
...
@@ -1220,7 +1231,7 @@ public final class ResolvableType implements Serializable {
/**
* Strategy interface used to resolve {@link TypeVariable}s.
*/
static
interface
VariableResolver
extends
Serializable
{
interface
VariableResolver
extends
Serializable
{
/**
* Return the source of the resolver (used for hashCode and equals).
...
...
@@ -1230,7 +1241,7 @@ public final class ResolvableType implements Serializable {
/**
* Resolve the specified variable.
* @param variable the variable to resolve
* @return the resolved variable
or {@code null}
* @return the resolved variable
, or {@code null} if not found
*/
ResolvableType
resolveVariable
(
TypeVariable
<?>
variable
);
}
...
...
@@ -1362,7 +1373,7 @@ public final class ResolvableType implements Serializable {
/**
* The various kinds of bounds.
*/
static
enum
Kind
{
UPPER
,
LOWER
}
enum
Kind
{
UPPER
,
LOWER
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录