private static Class < ? > getClassWithCaching ( String className , Configuration conf ) { Class < ? > classs = cachedClassObjects . get ( className ) ; if ( classs == null ) { try { classs = conf . getClassByName ( className ) ; if ( cachedClassObjects . size ( ) < CACHE_MAX_SIZE ) { cachedClassObjects . put ( className , classs ) ; } } catch ( ClassNotFoundException e ) { throw new RuntimeException ( "readObject can't find class " + className , e ) ; } } // for sanity check if the class is not null if ( classs == null ) { throw new RuntimeException ( "readObject can't find class " + className ) ; } return classs ; }
Retrieve Class for given name from cache . if not present cache it it the map capacity is not exceeded .