@@ -70,7 +70,7 @@ protected String _idFrom(Object value, Class<?> cls, TypeFactory typeFactory)
70
70
}
71
71
}
72
72
String str = cls .getName ();
73
- if (str .startsWith ("java.util" )) {
73
+ if (str .startsWith ("java.util. " )) {
74
74
// 25-Jan-2009, tatu: There are some internal classes that we cannot access as is.
75
75
// We need better mechanism; for now this has to do...
76
76
@@ -87,22 +87,20 @@ protected String _idFrom(Object value, Class<?> cls, TypeFactory typeFactory)
87
87
// not optimal: but EnumMap is not a customizable type so this is sort of ok
88
88
str = typeFactory .constructMapType (EnumMap .class , enumClass , valueClass ).toCanonical ();
89
89
} else {
90
- /* 17-Feb-2010, tatus: Another such case: result of
91
- * Arrays.asList() is named like so in Sun JDK...
92
- * Let's just plain old ArrayList in its place
93
- * NOTE: chances are there are plenty of similar cases
94
- * for other wrappers... (immutable, singleton, synced etc)
95
- */
96
- if (isJavaUtilCollectionClass (str , "List" )) {
97
- str = "java.util.ArrayList" ;
98
- }else if (isJavaUtilCollectionClass (str , "Map" )){
99
- str = "java.util.HashMap" ;
100
- }else if (isJavaUtilCollectionClass (str , "Set" )){
101
- str = "java.util.HashSet" ;
90
+ // 17-Feb-2010, tatus: Another such case: result of Arrays.asList() is
91
+ // named like so in Sun JDK... Let's just plain old ArrayList in its place.
92
+ // ... also, other similar cases exist...
93
+ String suffix = str .substring (10 );
94
+ if (isJavaUtilCollectionClass (suffix , "List" )) {
95
+ str = ArrayList .class .getName ();
96
+ } else if (isJavaUtilCollectionClass (suffix , "Map" )){
97
+ str = HashMap .class .getName ();
98
+ } else if (isJavaUtilCollectionClass (suffix , "Set" )){
99
+ str = HashSet .class .getName ();
102
100
}
103
101
}
104
102
} else if (str .indexOf ('$' ) >= 0 ) {
105
- /* Other special handling may be needed for inner classes, [JACKSON-584].
103
+ /* Other special handling may be needed for inner classes,
106
104
* The best way to handle would be to find 'hidden' constructor; pass parent
107
105
* value etc (which is actually done for non-anonymous static classes!),
108
106
* but that is just not possible due to various things. So, we will instead
@@ -131,8 +129,8 @@ public String getDescForKnownTypeIds() {
131
129
return "class name used as type id" ;
132
130
}
133
131
134
- private static boolean isJavaUtilCollectionClass (String clazzName , String type ){
135
- String end = clazzName . substring ( 9 );
136
- return ( end . startsWith ( ".Collections$" ) || end . startsWith ( ".Arrays$" )) && clazzName .indexOf (type ) > 0 ;
132
+ private static boolean isJavaUtilCollectionClass (String clz , String type ){
133
+ return ( clz . startsWith ( "Collections$" ) || clz . startsWith ( "Arrays$" ))
134
+ && clz .indexOf (type ) > 0 ;
137
135
}
138
136
}
0 commit comments