protected Class < ? > resolveClass ( ObjectStreamClass v ) throws IOException , ClassNotFoundException { ClassLoader loader = Thread . currentThread ( ) . getContextClassLoader ( ) ; String className = v . getName ( ) ; try { // JDK 6, by default, only supports array types (ex. [[B) using Class.forName() return Class . forName ( className , false , loader ) ; } catch ( ClassNotFoundException cnfe ) { Class cl = primClasses . get ( className ) ; if ( cl == null ) throw cnfe ; else return cl ; } }
Use the thread context class loader to resolve the class