.doPrivileged(J2DoPrivHelper.newBCClassLoaderAction(_project,
parentLoader));
BCClassLoader enhLoader = (BCClassLoader) AccessController
.doPrivileged(J2DoPrivHelper.newBCClassLoaderAction(_enhProject,
parentLoader));
BCClass bc = _project.loadClass(getClassName(meta));
bc.declareInterface(iface);
ClassMetaData sup = meta.getPCSuperclassMetaData();
if (sup != null) {
bc.setSuperclass(sup.getInterfaceImpl());
enhLoader = (BCClassLoader) AccessController
.doPrivileged(J2DoPrivHelper.newBCClassLoaderAction(
_enhProject, (ClassLoader) AccessController
.doPrivileged(J2DoPrivHelper.getClassLoaderAction(sup
.getInterfaceImpl()))));
}
FieldMetaData[] fields = meta.getDeclaredFields();
Set methods = new HashSet();
for (int i = 0; i < fields.length; i++)
addField(bc, iface, fields[i], methods);
invalidateNonBeanMethods(bc, iface, methods);
// first load the base class as the enhancer requires the class
// to be available
try {
meta.setInterfaceImpl(Class.forName(bc.getName(), true, loader));
} catch (Throwable t) {
throw new InternalException(_loc.get("interface-load", iface,
loader), t).setFatal(true);
}
// copy the BCClass into the enhancer project.
bc = _enhProject.loadClass(new ByteArrayInputStream(bc.toByteArray()),
loader);
PCEnhancer enhancer = new PCEnhancer(_repos.getConfiguration(), bc,
meta);
int result = enhancer.run();
if (result != PCEnhancer.ENHANCE_PC)
throw new InternalException(_loc.get("interface-badenhance",
iface)).setFatal(true);
try{
// load the class for real.
impl = Class.forName(bc.getName(), true, enhLoader);
} catch (Throwable t) {
throw new InternalException(_loc.get("interface-load2", iface,
enhLoader), t).setFatal(true);
}
// cache the generated impl.