prevent non-public access to bean class as well, if demanded

This commit is contained in:
Juergen Hoeller
2009-07-29 15:15:47 +00:00
parent 12e43ff92d
commit 5d009a2a98

View File

@@ -841,6 +841,11 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
// Make sure bean class is actually resolved at this point.
Class beanClass = resolveBeanClass(mbd, beanName);
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());
}
if (mbd.getFactoryMethodName() != null) {
return instantiateUsingFactoryMethod(beanName, mbd, args);
}