@ Override protected synchronized Class < ? > loadClass ( final String className , final boolean resolve ) throws ClassNotFoundException { // check first if the class has already been loaded Class < ? > c = findLoadedClass ( className ) ; if ( c != null ) { if ( resolve ) { resolveClass ( c ) ; } return c ; } // class not loaded yet Loading loading = resolveLoading ( parentFirst , className ) ; if ( parentFirst ) { // PARENT FIRST if ( loading . withParent ) { try { c = parentClassLoader . loadClass ( className ) ; } catch ( ClassNotFoundException ignore ) { } } if ( c == null ) { if ( loading . withLoader ) { c = this . findClass ( className ) ; } else { throw new ClassNotFoundException ( "Class not found: " + className ) ; } } } else { // THIS FIRST if ( loading . withLoader ) { try { c = this . findClass ( className ) ; } catch ( ClassNotFoundException ignore ) { } } if ( c == null ) { if ( loading . withParent ) { c = parentClassLoader . loadClass ( className ) ; } else { throw new ClassNotFoundException ( "Class not found: " + className ) ; } } } if ( resolve ) { resolveClass ( c ) ; } return c ; }
Loads class using parent - first or parent - last strategy .