liquibase-core/src/main/java/liquibase/servicelocator/DefaultPackageScanClassResolver.java
protected void loadImplementationsInJar(
            String parentPackage,
            InputStream parentFileStream,
            ClassLoader loader,
            String parentFileName,
            String grandparentFileName) throws IOException {
        Set<String> classFiles = classFilesByLocation.get(parentFileName);

        if (classFiles == null) {
            classFiles = new HashSet<String>();
            classFilesByLocation.put(parentFileName, classFiles);

            Set<String> grandparentClassFiles = classFilesByLocation.get(grandparentFileName);
            if (grandparentClassFiles == null) {
                grandparentClassFiles = new HashSet<String>();
                classFilesByLocation.put(grandparentFileName, grandparentClassFiles);
            }
            JarInputStream jarStream;
            if (parentFileStream instanceof JarInputStream) {
                jarStream = (JarInputStream) parentFileStream;
            } else {
                jarStream = new JarInputStream(parentFileStream);
            }

            JarEntry entry;
            while ((entry = jarStream.getNextJarEntry()) != null) {
                String name = entry.getName();
                if (name != null) {
                    if (name.endsWith(".jar")) { //in a nested jar
                        log.fine(LogType.LOG, "Found nested jar " + name);

                        // To avoid needing to unzip 'parentFile' in its entirety, as that
                        // may take a very long time (see CORE-2115) or not even be possible
                        // (see CORE-2595), we load the nested JAR from the classloader and
                        // read it as a zip.
                        //
                        // It is safe to assume that the nested JAR is readable by the classloader
                        // as a resource stream, because we have reached this point by scanning
                        // through packages located from `classloader` by using `getResource`.
                        // If loading this nested JAR as a resource fails, then certainly loading
                        // classes from inside it with `classloader` would fail and we are safe
                        // to exclude it form the PackageScan.
                        InputStream nestedJarResourceStream = loader.getResourceAsStream(name);
                        if (nestedJarResourceStream != null) {
                            JarInputStream nestedJarStream = new JarInputStream(nestedJarResourceStream);
                            try {
                                loadImplementationsInJar(
                                        parentPackage,
                                        nestedJarStream,
                                        loader,
                                        parentFileName + "!" + name,
                                        parentFileName);
                            } finally {
                                nestedJarStream.close();
                            }
                        }
                    } else if (!entry.isDirectory() && name.endsWith(".class")) {
                        classFiles.add(name.trim());
                        grandparentClassFiles.add(name.trim());
                    }
                }
            }
        }

        for (String name : classFiles) {
            if (name.contains(parentPackage)) {
                loadClass(name, loader);
            }
        }
    }
protected void loadImplementationsInJar(
            String parentPackage,
            InputStream parentFileStream,
            ClassLoader loader,
            String parentFileName,
            String grandparentFileName) throws IOException {
        Set<String> classFiles = classFilesByLocation.get(parentFileName);

        if (classFiles == null) {
            classFiles = new HashSet<String>();
            classFilesByLocation.put(parentFileName, classFiles);

            Set<String> grandparentClassFiles = classFilesByLocation.get(grandparentFileName);
            if (grandparentClassFiles == null) {
                grandparentClassFiles = new HashSet<String>();
                classFilesByLocation.put(grandparentFileName, grandparentClassFiles);
            }
            JarInputStream jarStream;
            if (parentFileStream instanceof JarInputStream) {
                jarStream = (JarInputStream) parentFileStream;
            } else {
                jarStream = new JarInputStream(parentFileStream);
            }

            JarEntry entry;
            while ((entry = jarStream.getNextJarEntry()) != null) {
                String name = entry.getName();
                if (name != null) {
                    if (name.endsWith(".jar")) { //in a nested jar
                        log.fine(LogType.LOG, "Found nested jar " + name);

                        // To avoid needing to unzip 'parentFile' in its entirety, as that
                        // may take a very long time (see CORE-2115) or not even be possible
                        // (see CORE-2595), we load the nested JAR from the classloader and
                        // read it as a zip.
                        //
                        // It is safe to assume that the nested JAR is readable by the classloader
                        // as a resource stream, because we have reached this point by scanning
                        // through packages located from `classloader` by using `getResource`.
                        // If loading this nested JAR as a resource fails, then certainly loading
                        // classes from inside it with `classloader` would fail and we are safe
                        // to exclude it form the PackageScan.
                        InputStream nestedJarResourceStream = loader.getResourceAsStream(name);
                        if (nestedJarResourceStream != null) {
                            JarInputStream nestedJarStream = new JarInputStream(nestedJarResourceStream);
                            try {
                                loadImplementationsInJar(
                                        parentPackage,
                                        nestedJarStream,
                                        loader,
                                        parentFileName + "!" + name,
                                        parentFileName);
                            } finally {
                                nestedJarStream.close();
                            }
                        }
                    } else if (!entry.isDirectory() && name.endsWith(".class")) {
                        classFiles.add(name.trim());
                        grandparentClassFiles.add(name.trim());
                    }
                }
            }
        }

        for (String name : classFiles) {
            if (name.contains(parentPackage)) {
                loadClass(name, loader);
            }
        }
    }
Finds matching classes within a jar files that contains a folder
structure matching the package structure. If the File is not a JarFile or
does not exist a warning will be logged, but no error will be raised.

Any nested JAR files found inside this JAR will be assumed to also be
on the classpath and will be recursively examined for classes in `parentPackage`.
@param parentPackage  the parent package under which classes must be in order to
be considered
@param parentFileStream  the inputstream of the jar file to be examined for classes
@param loader a classloader which can load classes contained within the JAR file
@param parentFileName a unique name for the parentFileStream, to be used for caching.
This is the URL of the parentFileStream, if it comes from a URL,
or a composite ID if we are currently examining a nested JAR.