Index: src/main/java/java/io/ObjectStreamField.java =================================================================== --- src/main/java/java/io/ObjectStreamField.java (revision 554714) +++ src/main/java/java/io/ObjectStreamField.java (working copy) @@ -98,6 +98,7 @@ } this.name = name; this.typeString = signature.replace('.', '/').intern(); + defaultResolve(); this.isDeserialized = true; } @@ -293,31 +294,8 @@ void resolve(ClassLoader loader) { if (typeString.length() == 1) { - switch (typeString.charAt(0)) { - case 'I': - type = Integer.TYPE; - return; - case 'B': - type = Byte.TYPE; - return; - case 'C': - type = Character.TYPE; - return; - case 'S': - type = Short.TYPE; - return; - case 'Z': - type = Boolean.TYPE; - return; - case 'J': - type = Long.TYPE; - return; - case 'F': - type = Float.TYPE; - return; - case 'D': - type = Double.TYPE; - return; + if (defaultResolve()) { + return; } } String className = typeString.replace('/', '.'); @@ -335,6 +313,42 @@ } /** + * Resolves typeString into type. Returns true if the type is primitive + * and false otherwise. + */ + private boolean defaultResolve() { + switch (typeString.charAt(0)) { + case 'I': + type = Integer.TYPE; + return true; + case 'B': + type = Byte.TYPE; + return true; + case 'C': + type = Character.TYPE; + return true; + case 'S': + type = Short.TYPE; + return true; + case 'Z': + type = Boolean.TYPE; + return true; + case 'J': + type = Long.TYPE; + return true; + case 'F': + type = Float.TYPE; + return true; + case 'D': + type = Double.TYPE; + return true; + default: + type = Object.class; + return false; + } + } + + /** * Answers whether this serialized field is unshared. * * @return true if the field is unshared, false otherwise.