// 得到对应的Class对象
Class<?> beanClass = resolveBeanClass(mbd, beanName);
// 判断Class对象;访问修饰符;nonPublicAccessAllowed默认为true
if (beanClass != null && !Modifier.isPublic(beanClass.getModifiers()) && !mbd.isNonPublicAccessAllowed()) {
throw new BeanCreationException(mbd.getResourceDescription(), beanName,
"Bean class isn't public, and non-public access not allowed: " + beanClass.getName());
}
获取类的访问修饰符方法 public native int getModifiers(); 是个 native 方法将 public, protected, private, final, static, abstract and interface 转换成 integer 返回。对应的枚举在 Modifier 接口中。
public static final int PUBLIC = 0x00000001;
public static final int PRIVATE = 0x00000002;
......省略