public List < ClasspathResourceVersion > getResourceVersions ( ) throws URISyntaxException , IOException { if ( ! lazyLoadDone ) { if ( isClassFolder ( ) ) { logger . debug ( "\nScanning class folder: " + getUrl ( ) ) ; URI uri = new URI ( getUrl ( ) ) ; Path start = Paths . get ( uri ) ; scanClasspathEntry ( start ) ; } else if ( isJar ( ) ) { logger . debug ( "\nScanning jar: " + getUrl ( ) ) ; URI uri = new URI ( "jar:" + getUrl ( ) ) ; try ( FileSystem jarFS = FileSystems . newFileSystem ( uri , new HashMap < String , String > ( ) ) ) { Path zipInJarPath = jarFS . getPath ( "/" ) ; scanClasspathEntry ( zipInJarPath ) ; } catch ( Exception exc ) { logger . debug ( "Could not scan jar: " + getUrl ( ) + " - reason:" + exc . getMessage ( ) ) ; } } lazyLoadDone = true ; } return resourceVersions ; }
The contents of a jar are only loaded if accessed the first time .