Index: working_classlib/modules/luni/src/main/java/java/io/ObjectInputStream.java =================================================================== --- working_classlib/modules/luni/src/main/java/java/io/ObjectInputStream.java (revision 645620) +++ working_classlib/modules/luni/src/main/java/java/io/ObjectInputStream.java (working copy) @@ -2391,16 +2391,27 @@ */ protected Class resolveClass(ObjectStreamClass osClass) throws IOException, ClassNotFoundException { - String className = osClass.getName(); - // if it is primitive class, for example, long.class - Class cls = PRIMITIVE_CLASSES.get(className); - if (null == cls) { - // not primitive class - // Use the first non-null ClassLoader on the stack. If null, use the - // system class loader - return Class.forName(className, true, callerClassLoader); - } - return cls; + + // fastpath: obtain cached value + Class cls = osClass.forClass(); + if (null == cls) { + // slowpath: resolve the class + String className = osClass.getName(); + + // if it is primitive class, for example, long.class + cls = PRIMITIVE_CLASSES.get(className); + + if (null == cls) { + // not primitive class + // Use the first non-null ClassLoader on the stack. If null, use the + // system class loader + cls = Class.forName(className, true, callerClassLoader); + + // save the value + osClass.setClass(cls); + } + } + return cls; } /**