protectedClass<?>loadClass(String name,boolean resolve)throwsClassNotFoundException{synchronized(getClassLoadingLock(name)){// First, check if the class has already been loadedClass<?> c =findLoadedClass(name);//如果没有if(c ==null){long t0 =System.nanoTime();try{if(parent !=null){//如果父类不空 就交给父类递归
c = parent.loadClass(name,false);}else{//当某一个父类为空时就交给BootstrapClassLoad去加载
c =findBootstrapClassOrNull(name);}}catch(ClassNotFoundException e){// ClassNotFoundException thrown if class not found// from the non-null parent class loader}if(c ==null){// If still not found, then invoke findClass in order// to find the class.long t1 =System.nanoTime();//加载失败就class not find 了
c =findClass(name);// this is the defining class loader; record the statssun.misc.PerfCounter.getParentDelegationTime().addTime(t1 - t0);sun.misc.PerfCounter.getFindClassTime().addElapsedTimeFrom(t1);sun.misc.PerfCounter.getFindClasses().increment();}}if(resolve){resolveClass(c);}return c;}}