/** * Returns the class loader for the class. Some implementations may use * null to represent the bootstrap class loader. This method will return * null in such implementations if this class was loaded by the bootstrap * class loader. * 返回这个class的类加载器,有些实现使用null代替bootstrap 加载器,如果这个类的加载器是bootstrap 那么这个方法返回null * <p> If a security manager is present, and the caller's class loader is * not null and the caller's class loader is not the same as or an ancestor of * the class loader for the class whose class loader is requested, then * this method calls the security manager's {@code checkPermission} * method with a {@code RuntimePermission("getClassLoader")} * permission to ensure it's ok to access the class loader for the class. * 如果使用了安全管理器,调用者的类加载器不是null,并且调用者的类加载器和类的加载器的层次关系不相等,那么就会用RuntimePermission("getClassLoader")调用安全管理器的getClassLoader方法来确认是否可以允许这个类的加载器去加载它。 * <p>If this object * represents a primitive type or void, null is returned. * * @return the class loader that loaded the class or interface * represented by this object. * 返回加载了当前对象对应类的接口的加载器 * @throws SecurityException * if a security manager exists and its * {@code checkPermission} method denies * access to the class loader for the class. * @see java.lang.ClassLoader * @see SecurityManager#checkPermission * @see java.lang.RuntimePermission */ @CallerSensitive public ClassLoader getClassLoader() { ... }