private void scheduleScanningIfExternalClass ( final String className , final String relationship ) { // Don't scan Object if ( className != null && ! className . equals ( "java.lang.Object" ) // Only schedule each external class once for scanning, across all threads && classNamesScheduledForScanning . add ( className ) ) { // Search for the named class' classfile among classpath elements, in classpath order (this is O(N) // for each class, but there shouldn't be too many cases of extending scanning upwards) final String classfilePath = JarUtils . classNameToClassfilePath ( className ) ; // First check current classpath element, to avoid iterating through other classpath elements Resource classResource = classpathElement . getResource ( classfilePath ) ; ClasspathElement foundInClasspathElt = null ; if ( classResource != null ) { // Found the classfile in the current classpath element foundInClasspathElt = classpathElement ; } else { // Didn't find the classfile in the current classpath element -- iterate through other elements for ( final ClasspathElement classpathOrderElt : classpathOrder ) { if ( classpathOrderElt != classpathElement ) { classResource = classpathOrderElt . getResource ( classfilePath ) ; if ( classResource != null ) { foundInClasspathElt = classpathOrderElt ; break ; } } } } if ( classResource != null ) { // Found class resource if ( log != null ) { log . log ( "Scheduling external class for scanning: " + relationship + " " + className + ( foundInClasspathElt == classpathElement ? "" : " -- found in classpath element " + foundInClasspathElt ) ) ; } if ( additionalWorkUnits == null ) { additionalWorkUnits = new ArrayList <> ( ) ; } // Schedule class resource for scanning additionalWorkUnits . add ( new ClassfileScanWorkUnit ( foundInClasspathElt , classResource , /* isExternalClass = */ true ) ) ; } else { if ( log != null ) { log . log ( "External " + relationship + " " + className + " was not found in " + "non-blacklisted packages -- cannot extend scanning to this class" ) ; } } } }
Extend scanning to a superclass interface or annotation .