File tree Expand file tree Collapse file tree 2 files changed +33
-7
lines changed
main/java/com/alibaba/fastjson
test/java/com/alibaba/json/bvt Expand file tree Collapse file tree 2 files changed +33
-7
lines changed Original file line number Diff line number Diff line change @@ -34,14 +34,18 @@ protected TypeReference(){
34
34
35
35
Type oriType = ((ParameterizedType ) superClass ).getActualTypeArguments ()[0 ];
36
36
37
- //修复在安卓环境中问题
38
- Type cachedType = classTypeCache .get (oriType );
39
- if (cachedType == null ) {
40
- classTypeCache .putIfAbsent (oriType , oriType );
41
- cachedType = classTypeCache .get (oriType );
42
- }
37
+ if (oriType instanceof Class ) {
38
+ type = oriType ;
39
+ } else {
40
+ //修复在安卓环境中问题
41
+ Type cachedType = classTypeCache .get (oriType );
42
+ if (cachedType == null ) {
43
+ classTypeCache .putIfAbsent (oriType , oriType );
44
+ cachedType = classTypeCache .get (oriType );
45
+ }
43
46
44
- type = cachedType ;
47
+ type = cachedType ;
48
+ }
45
49
}
46
50
47
51
/**
Original file line number Diff line number Diff line change
1
+ package com .alibaba .json .bvt ;
2
+
3
+ import com .alibaba .fastjson .TypeReference ;
4
+ import junit .framework .TestCase ;
5
+
6
+ import java .lang .reflect .Type ;
7
+
8
+ /**
9
+ * Created by wenshao on 01/07/2017.
10
+ */
11
+ public class TypeReferenceTest13 extends TestCase {
12
+ public void test_typeRef () throws Exception {
13
+ Type type = new TypeReference <Integer >(){}.getType ();
14
+ assertSame (Integer .class , type );
15
+ }
16
+
17
+ public <T > void test_typeRef_1 () throws Exception {
18
+ Type type1 = new TypeReference <T >(){}.getType ();
19
+ Type type2 = new TypeReference <T >(){}.getType ();
20
+ assertSame (type1 , type2 );
21
+ }
22
+ }
You can’t perform that action at this time.
0 commit comments