@@ -70,7 +70,7 @@ protected String _idFrom(Object value, Class<?> cls, TypeFactory typeFactory)
7070 }
7171 }
7272 String str = cls .getName ();
73- if (str .startsWith ("java.util" )) {
73+ if (str .startsWith ("java.util. " )) {
7474 // 25-Jan-2009, tatu: There are some internal classes that we cannot access as is.
7575 // We need better mechanism; for now this has to do...
7676
@@ -87,22 +87,20 @@ protected String _idFrom(Object value, Class<?> cls, TypeFactory typeFactory)
8787 // not optimal: but EnumMap is not a customizable type so this is sort of ok
8888 str = typeFactory .constructMapType (EnumMap .class , enumClass , valueClass ).toCanonical ();
8989 } 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 ();
102100 }
103101 }
104102 } 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,
106104 * The best way to handle would be to find 'hidden' constructor; pass parent
107105 * value etc (which is actually done for non-anonymous static classes!),
108106 * but that is just not possible due to various things. So, we will instead
@@ -131,8 +129,8 @@ public String getDescForKnownTypeIds() {
131129 return "class name used as type id" ;
132130 }
133131
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 ;
137135 }
138136}
0 commit comments