Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
08dad4e3
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,发现更多精彩内容 >>
提交
08dad4e3
编写于
3月 29, 2018
作者:
J
Juergen Hoeller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Consistent references to primitive types (in alphabetical order)
上级
695bf296
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
89 addition
and
92 deletion
+89
-92
spring-core/src/main/java/org/springframework/core/convert/TypeDescriptor.java
...java/org/springframework/core/convert/TypeDescriptor.java
+5
-5
spring-expression/src/main/java/org/springframework/expression/spel/CodeFlow.java
...in/java/org/springframework/expression/spel/CodeFlow.java
+12
-12
spring-expression/src/main/java/org/springframework/expression/spel/ast/ConstructorReference.java
...ngframework/expression/spel/ast/ConstructorReference.java
+11
-11
spring-expression/src/main/java/org/springframework/expression/spel/ast/Indexer.java
...java/org/springframework/expression/spel/ast/Indexer.java
+45
-45
spring-expression/src/main/java/org/springframework/expression/spel/ast/TypeCode.java
...ava/org/springframework/expression/spel/ast/TypeCode.java
+6
-6
spring-expression/src/main/java/org/springframework/expression/spel/ast/TypeReference.java
...rg/springframework/expression/spel/ast/TypeReference.java
+10
-13
未找到文件。
spring-core/src/main/java/org/springframework/core/convert/TypeDescriptor.java
浏览文件 @
08dad4e3
/*
* Copyright 2002-201
7
the original author or authors.
* Copyright 2002-201
8
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.
...
...
@@ -49,14 +49,14 @@ import org.springframework.util.ObjectUtils;
@SuppressWarnings
(
"serial"
)
public
class
TypeDescriptor
implements
Serializable
{
static
final
Annotation
[]
EMPTY_ANNOTATION_ARRAY
=
new
Annotation
[
0
];
private
static
final
Annotation
[]
EMPTY_ANNOTATION_ARRAY
=
new
Annotation
[
0
];
private
static
final
Map
<
Class
<?>,
TypeDescriptor
>
commonTypesCache
=
new
HashMap
<>(
18
);
private
static
final
Map
<
Class
<?>,
TypeDescriptor
>
commonTypesCache
=
new
HashMap
<>(
32
);
private
static
final
Class
<?>[]
CACHED_COMMON_TYPES
=
{
boolean
.
class
,
Boolean
.
class
,
byte
.
class
,
Byte
.
class
,
char
.
class
,
Character
.
class
,
double
.
class
,
Double
.
class
,
int
.
class
,
Integer
.
class
,
long
.
class
,
Long
.
class
,
float
.
class
,
Float
.
class
,
short
.
class
,
Short
.
class
,
String
.
class
,
Object
.
class
};
double
.
class
,
Double
.
class
,
float
.
class
,
Float
.
class
,
int
.
class
,
Integer
.
class
,
long
.
class
,
Long
.
class
,
short
.
class
,
Short
.
class
,
String
.
class
,
Object
.
class
};
static
{
for
(
Class
<?>
preCachedClass
:
CACHED_COMMON_TYPES
)
{
...
...
spring-expression/src/main/java/org/springframework/expression/spel/CodeFlow.java
浏览文件 @
08dad4e3
...
...
@@ -478,33 +478,33 @@ public class CodeFlow implements Opcodes {
}
}
if
(
clazz
.
isPrimitive
())
{
if
(
clazz
==
Void
.
TYPE
)
{
sb
.
append
(
'V'
);
}
else
if
(
clazz
==
Integer
.
TYPE
)
{
sb
.
append
(
'I'
);
}
else
if
(
clazz
==
Boolean
.
TYPE
)
{
if
(
clazz
==
Boolean
.
TYPE
)
{
sb
.
append
(
'Z'
);
}
else
if
(
clazz
==
Byte
.
TYPE
)
{
sb
.
append
(
'B'
);
}
else
if
(
clazz
==
Character
.
TYPE
)
{
sb
.
append
(
'C'
);
}
else
if
(
clazz
==
Long
.
TYPE
)
{
sb
.
append
(
'J'
);
}
else
if
(
clazz
==
Double
.
TYPE
)
{
sb
.
append
(
'D'
);
}
else
if
(
clazz
==
Float
.
TYPE
)
{
sb
.
append
(
'F'
);
}
else
if
(
clazz
==
Byte
.
TYPE
)
{
sb
.
append
(
'B'
);
else
if
(
clazz
==
Integer
.
TYPE
)
{
sb
.
append
(
'I'
);
}
else
if
(
clazz
==
Long
.
TYPE
)
{
sb
.
append
(
'J'
);
}
else
if
(
clazz
==
Short
.
TYPE
)
{
sb
.
append
(
'S'
);
}
else
if
(
clazz
==
Void
.
TYPE
)
{
sb
.
append
(
'V'
);
}
}
else
{
sb
.
append
(
"L"
);
...
...
spring-expression/src/main/java/org/springframework/expression/spel/ast/ConstructorReference.java
浏览文件 @
08dad4e3
...
...
@@ -295,29 +295,29 @@ public class ConstructorReference extends SpelNodeImpl {
if
(
arrayTypeCode
==
TypeCode
.
OBJECT
)
{
populateReferenceTypeArray
(
state
,
newArray
,
typeConverter
,
initializer
,
componentType
);
}
else
if
(
arrayTypeCode
==
TypeCode
.
INT
)
{
populateIntArray
(
state
,
newArray
,
typeConverter
,
initializer
);
}
else
if
(
arrayTypeCode
==
TypeCode
.
BOOLEAN
)
{
populateBooleanArray
(
state
,
newArray
,
typeConverter
,
initializer
);
}
else
if
(
arrayTypeCode
==
TypeCode
.
BYTE
)
{
populateByteArray
(
state
,
newArray
,
typeConverter
,
initializer
);
}
else
if
(
arrayTypeCode
==
TypeCode
.
CHAR
)
{
populateCharArray
(
state
,
newArray
,
typeConverter
,
initializer
);
}
else
if
(
arrayTypeCode
==
TypeCode
.
LONG
)
{
populateLongArray
(
state
,
newArray
,
typeConverter
,
initializer
);
}
else
if
(
arrayTypeCode
==
TypeCode
.
SHORT
)
{
populateShortArray
(
state
,
newArray
,
typeConverter
,
initializer
);
}
else
if
(
arrayTypeCode
==
TypeCode
.
DOUBLE
)
{
populateDoubleArray
(
state
,
newArray
,
typeConverter
,
initializer
);
}
else
if
(
arrayTypeCode
==
TypeCode
.
FLOAT
)
{
populateFloatArray
(
state
,
newArray
,
typeConverter
,
initializer
);
}
else
if
(
arrayTypeCode
==
TypeCode
.
BYTE
)
{
populateByteArray
(
state
,
newArray
,
typeConverter
,
initializer
);
else
if
(
arrayTypeCode
==
TypeCode
.
INT
)
{
populateIntArray
(
state
,
newArray
,
typeConverter
,
initializer
);
}
else
if
(
arrayTypeCode
==
TypeCode
.
LONG
)
{
populateLongArray
(
state
,
newArray
,
typeConverter
,
initializer
);
}
else
if
(
arrayTypeCode
==
TypeCode
.
SHORT
)
{
populateShortArray
(
state
,
newArray
,
typeConverter
,
initializer
);
}
else
{
throw
new
IllegalStateException
(
arrayTypeCode
.
name
());
...
...
spring-expression/src/main/java/org/springframework/expression/spel/ast/Indexer.java
浏览文件 @
08dad4e3
...
...
@@ -335,7 +335,22 @@ public class Indexer extends SpelNodeImpl {
private
void
setArrayElement
(
TypeConverter
converter
,
Object
ctx
,
int
idx
,
@Nullable
Object
newValue
,
Class
<?>
arrayComponentType
)
throws
EvaluationException
{
if
(
arrayComponentType
==
Double
.
TYPE
)
{
if
(
arrayComponentType
==
Boolean
.
TYPE
)
{
boolean
[]
array
=
(
boolean
[])
ctx
;
checkAccess
(
array
.
length
,
idx
);
array
[
idx
]
=
convertValue
(
converter
,
newValue
,
Boolean
.
class
);
}
else
if
(
arrayComponentType
==
Byte
.
TYPE
)
{
byte
[]
array
=
(
byte
[])
ctx
;
checkAccess
(
array
.
length
,
idx
);
array
[
idx
]
=
convertValue
(
converter
,
newValue
,
Byte
.
class
);
}
else
if
(
arrayComponentType
==
Character
.
TYPE
)
{
char
[]
array
=
(
char
[])
ctx
;
checkAccess
(
array
.
length
,
idx
);
array
[
idx
]
=
convertValue
(
converter
,
newValue
,
Character
.
class
);
}
else
if
(
arrayComponentType
==
Double
.
TYPE
)
{
double
[]
array
=
(
double
[])
ctx
;
checkAccess
(
array
.
length
,
idx
);
array
[
idx
]
=
convertValue
(
converter
,
newValue
,
Double
.
class
);
...
...
@@ -345,36 +360,21 @@ public class Indexer extends SpelNodeImpl {
checkAccess
(
array
.
length
,
idx
);
array
[
idx
]
=
convertValue
(
converter
,
newValue
,
Float
.
class
);
}
else
if
(
arrayComponentType
==
Long
.
TYPE
)
{
long
[]
array
=
(
long
[])
ctx
;
checkAccess
(
array
.
length
,
idx
);
array
[
idx
]
=
convertValue
(
converter
,
newValue
,
Long
.
class
);
}
else
if
(
arrayComponentType
==
Integer
.
TYPE
)
{
int
[]
array
=
(
int
[])
ctx
;
checkAccess
(
array
.
length
,
idx
);
array
[
idx
]
=
convertValue
(
converter
,
newValue
,
Integer
.
class
);
}
else
if
(
arrayComponentType
==
Long
.
TYPE
)
{
long
[]
array
=
(
long
[])
ctx
;
checkAccess
(
array
.
length
,
idx
);
array
[
idx
]
=
convertValue
(
converter
,
newValue
,
Long
.
class
);
}
else
if
(
arrayComponentType
==
Short
.
TYPE
)
{
short
[]
array
=
(
short
[])
ctx
;
checkAccess
(
array
.
length
,
idx
);
array
[
idx
]
=
convertValue
(
converter
,
newValue
,
Short
.
class
);
}
else
if
(
arrayComponentType
==
Byte
.
TYPE
)
{
byte
[]
array
=
(
byte
[])
ctx
;
checkAccess
(
array
.
length
,
idx
);
array
[
idx
]
=
convertValue
(
converter
,
newValue
,
Byte
.
class
);
}
else
if
(
arrayComponentType
==
Character
.
TYPE
)
{
char
[]
array
=
(
char
[])
ctx
;
checkAccess
(
array
.
length
,
idx
);
array
[
idx
]
=
convertValue
(
converter
,
newValue
,
Character
.
class
);
}
else
if
(
arrayComponentType
==
Boolean
.
TYPE
)
{
boolean
[]
array
=
(
boolean
[])
ctx
;
checkAccess
(
array
.
length
,
idx
);
array
[
idx
]
=
convertValue
(
converter
,
newValue
,
Boolean
.
class
);
}
else
{
Object
[]
array
=
(
Object
[])
ctx
;
checkAccess
(
array
.
length
,
idx
);
...
...
@@ -384,52 +384,52 @@ public class Indexer extends SpelNodeImpl {
private
Object
accessArrayElement
(
Object
ctx
,
int
idx
)
throws
SpelEvaluationException
{
Class
<?>
arrayComponentType
=
ctx
.
getClass
().
getComponentType
();
if
(
arrayComponentType
==
Double
.
TYPE
)
{
double
[]
array
=
(
double
[])
ctx
;
if
(
arrayComponentType
==
Boolean
.
TYPE
)
{
boolean
[]
array
=
(
boolean
[])
ctx
;
checkAccess
(
array
.
length
,
idx
);
this
.
exitTypeDescriptor
=
"
D
"
;
this
.
exitTypeDescriptor
=
"
Z
"
;
return
array
[
idx
];
}
else
if
(
arrayComponentType
==
Float
.
TYPE
)
{
float
[]
array
=
(
float
[])
ctx
;
else
if
(
arrayComponentType
==
Byte
.
TYPE
)
{
byte
[]
array
=
(
byte
[])
ctx
;
checkAccess
(
array
.
length
,
idx
);
this
.
exitTypeDescriptor
=
"
F
"
;
this
.
exitTypeDescriptor
=
"
B
"
;
return
array
[
idx
];
}
else
if
(
arrayComponentType
==
Long
.
TYPE
)
{
long
[]
array
=
(
long
[])
ctx
;
else
if
(
arrayComponentType
==
Character
.
TYPE
)
{
char
[]
array
=
(
char
[])
ctx
;
checkAccess
(
array
.
length
,
idx
);
this
.
exitTypeDescriptor
=
"
J
"
;
this
.
exitTypeDescriptor
=
"
C
"
;
return
array
[
idx
];
}
else
if
(
arrayComponentType
==
Integer
.
TYPE
)
{
int
[]
array
=
(
int
[])
ctx
;
else
if
(
arrayComponentType
==
Double
.
TYPE
)
{
double
[]
array
=
(
double
[])
ctx
;
checkAccess
(
array
.
length
,
idx
);
this
.
exitTypeDescriptor
=
"
I
"
;
this
.
exitTypeDescriptor
=
"
D
"
;
return
array
[
idx
];
}
else
if
(
arrayComponentType
==
Shor
t
.
TYPE
)
{
short
[]
array
=
(
shor
t
[])
ctx
;
else
if
(
arrayComponentType
==
Floa
t
.
TYPE
)
{
float
[]
array
=
(
floa
t
[])
ctx
;
checkAccess
(
array
.
length
,
idx
);
this
.
exitTypeDescriptor
=
"
S
"
;
this
.
exitTypeDescriptor
=
"
F
"
;
return
array
[
idx
];
}
else
if
(
arrayComponentType
==
Byte
.
TYPE
)
{
byte
[]
array
=
(
byte
[])
ctx
;
else
if
(
arrayComponentType
==
Integer
.
TYPE
)
{
int
[]
array
=
(
int
[])
ctx
;
checkAccess
(
array
.
length
,
idx
);
this
.
exitTypeDescriptor
=
"
B
"
;
this
.
exitTypeDescriptor
=
"
I
"
;
return
array
[
idx
];
}
else
if
(
arrayComponentType
==
Character
.
TYPE
)
{
char
[]
array
=
(
char
[])
ctx
;
else
if
(
arrayComponentType
==
Long
.
TYPE
)
{
long
[]
array
=
(
long
[])
ctx
;
checkAccess
(
array
.
length
,
idx
);
this
.
exitTypeDescriptor
=
"
C
"
;
this
.
exitTypeDescriptor
=
"
J
"
;
return
array
[
idx
];
}
else
if
(
arrayComponentType
==
Boolean
.
TYPE
)
{
boolean
[]
array
=
(
boolean
[])
ctx
;
else
if
(
arrayComponentType
==
Short
.
TYPE
)
{
short
[]
array
=
(
short
[])
ctx
;
checkAccess
(
array
.
length
,
idx
);
this
.
exitTypeDescriptor
=
"
Z
"
;
this
.
exitTypeDescriptor
=
"
S
"
;
return
array
[
idx
];
}
else
{
...
...
spring-expression/src/main/java/org/springframework/expression/spel/ast/TypeCode.java
浏览文件 @
08dad4e3
/*
* Copyright 2002-201
4
the original author or authors.
* Copyright 2002-201
8
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.
...
...
@@ -32,15 +32,15 @@ public enum TypeCode {
CHAR
(
Character
.
TYPE
),
SHORT
(
Short
.
TYPE
),
DOUBLE
(
Double
.
TYPE
),
FLOAT
(
Float
.
TYPE
),
INT
(
Integer
.
TYPE
),
LONG
(
Long
.
TYPE
),
FLOAT
(
Float
.
TYPE
),
DOUBLE
(
Double
.
TYPE
);
SHORT
(
Short
.
TYPE
);
private
Class
<?>
type
;
...
...
@@ -64,7 +64,7 @@ public enum TypeCode {
return
tcs
[
i
];
}
}
return
TypeCode
.
OBJECT
;
return
OBJECT
;
}
public
static
TypeCode
forClass
(
Class
<?>
clazz
)
{
...
...
spring-expression/src/main/java/org/springframework/expression/spel/ast/TypeReference.java
浏览文件 @
08dad4e3
/*
* Copyright 2002-201
7
the original author or authors.
* Copyright 2002-201
8
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.
...
...
@@ -103,33 +103,30 @@ public class TypeReference extends SpelNodeImpl {
// TODO Future optimization - if followed by a static method call, skip generating code here
Assert
.
state
(
this
.
type
!=
null
,
"No type available"
);
if
(
this
.
type
.
isPrimitive
())
{
if
(
this
.
type
==
Integer
.
TYPE
)
{
mv
.
visitFieldInsn
(
GETSTATIC
,
"java/lang/Integer"
,
"TYPE"
,
"Ljava/lang/Class;"
);
}
else
if
(
this
.
type
==
Boolean
.
TYPE
)
{
if
(
this
.
type
==
Boolean
.
TYPE
)
{
mv
.
visitFieldInsn
(
GETSTATIC
,
"java/lang/Boolean"
,
"TYPE"
,
"Ljava/lang/Class;"
);
}
else
if
(
this
.
type
==
Byte
.
TYPE
)
{
mv
.
visitFieldInsn
(
GETSTATIC
,
"java/lang/Byte"
,
"TYPE"
,
"Ljava/lang/Class;"
);
}
else
if
(
this
.
type
==
Short
.
TYPE
)
{
mv
.
visitFieldInsn
(
GETSTATIC
,
"java/lang/
Short
"
,
"TYPE"
,
"Ljava/lang/Class;"
);
else
if
(
this
.
type
==
Character
.
TYPE
)
{
mv
.
visitFieldInsn
(
GETSTATIC
,
"java/lang/
Character
"
,
"TYPE"
,
"Ljava/lang/Class;"
);
}
else
if
(
this
.
type
==
Double
.
TYPE
)
{
mv
.
visitFieldInsn
(
GETSTATIC
,
"java/lang/Double"
,
"TYPE"
,
"Ljava/lang/Class;"
);
}
else
if
(
this
.
type
==
Character
.
TYPE
)
{
mv
.
visitFieldInsn
(
GETSTATIC
,
"java/lang/Character"
,
"TYPE"
,
"Ljava/lang/Class;"
);
}
else
if
(
this
.
type
==
Float
.
TYPE
)
{
mv
.
visitFieldInsn
(
GETSTATIC
,
"java/lang/Float"
,
"TYPE"
,
"Ljava/lang/Class;"
);
}
else
if
(
this
.
type
==
Integer
.
TYPE
)
{
mv
.
visitFieldInsn
(
GETSTATIC
,
"java/lang/Integer"
,
"TYPE"
,
"Ljava/lang/Class;"
);
}
else
if
(
this
.
type
==
Long
.
TYPE
)
{
mv
.
visitFieldInsn
(
GETSTATIC
,
"java/lang/Long"
,
"TYPE"
,
"Ljava/lang/Class;"
);
}
else
if
(
this
.
type
==
Boolean
.
TYPE
)
{
mv
.
visitFieldInsn
(
GETSTATIC
,
"java/lang/
Boolean
"
,
"TYPE"
,
"Ljava/lang/Class;"
);
}
else
if
(
this
.
type
==
Short
.
TYPE
)
{
mv
.
visitFieldInsn
(
GETSTATIC
,
"java/lang/
Short
"
,
"TYPE"
,
"Ljava/lang/Class;"
);
}
}
else
{
mv
.
visitLdcInsn
(
Type
.
getType
(
this
.
type
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录