boolean (@NotNull ClassLoaderReference fromLoader, final ReferenceType refType) { // IMPORTANT! Even if the refType is already loaded by some parent or bootstrap loader, it may not be visible from the given loader. // For example because there were no accesses yet from this loader to this class. So the loader is not in the list of "initialing" loaders // for this refType and the refType is not visible to the loader. // Attempt to evaluate method with this refType will yield ClassNotLoadedException. // The only way to say for sure whether the class is _visible_ to the given loader, is to use the following API call if (fromLoader instanceof ClassLoaderReferenceImpl) { return ((ClassLoaderReferenceImpl)fromLoader).isVisible(refType); } return fromLoader.visibleClasses().contains(refType); }