Hi Andy,
I think I know what the problem is and why this has been so confusing. My environment is running in OSGi which presents all sorts of ClassLoader issues as well as awkward tooling.
In this case, the problem is because the class is being imported via the OSGi Service Registry under a broadly visible interface (let's call it InterfaceA). Once the ServiceReference is obtained, Spring creates a bean in the ApplicationContext that can be post-processed. In my case the Spring AOP post-processor is attempting to parse a PointCut or JoinPoint _expression_ and in doing so is processing the class instance of InterfaceA.
InterfaceA is visible via an Import-Package directive but its concrete class ClassA and AbstractSuperClassA are in packages not found in the bundle's Import-Package directive. At some point in the parsing process ClassA and AbstractSuperClassA requires the Class object to perform some sort of calculation. I believe the Class object can only be retrieved via:
public class ReflectionBasedReferenceTypeDelegateFactory {
public static ReflectionBasedReferenceTypeDelegate createDelegate(ReferenceType forReferenceType, World inWorld,
ClassLoader usingClassLoader) {
try {
Class c = Class.forName(forReferenceType.getName(), false, usingClassLoader);
if (LangUtil.is15VMOrGreater()) {
ReflectionBasedReferenceTypeDelegate rbrtd = create15Delegate(forReferenceType, c, usingClassLoader, inWorld);
if (rbrtd != null) {
return rbrtd; // can be null if we didn't find the class the delegate logic loads
}
}
return new ReflectionBasedReferenceTypeDelegate(c, usingClassLoader, inWorld, forReferenceType);
} catch (ClassNotFoundException cnfEx) {
return null;
}
}
The ReflectionBasedReferenceTypeDelegateFactory.createDelegate() always returns null because of a ClassNotFoundException.