docs: @SuppressWarnings("MagicNumber")
      protected Set<Resource> doFindPathMatchingJarResources(Resource rootDirResource, String subPattern)
          throws IOException {
  
          URLConnection con = rootDirResource.getURL().openConnection();
          JarFile jarFile;
          String jarFileUrl;
          String rootEntryPath;
          boolean newJarFile = false;
  
          if (con instanceof JarURLConnection) {
              // Should usually be the case for traditional JAR files.
              JarURLConnection jarCon = (JarURLConnection) con;
              ResourceUtils.useCachesIfNecessary(jarCon);
              jarFile = jarCon.getJarFile();
              jarFileUrl = jarCon.getJarFileURL().toExternalForm();
              JarEntry jarEntry = jarCon.getJarEntry();
              rootEntryPath = (jarEntry != null ? jarEntry.getName() : "");
          } else {
              // No JarURLConnection -> need to resort to URL file parsing.
              // We'll assume URLs of the format "jar:path!/entry", with the protocol
              // being arbitrary as long as following the entry format.
              // We'll also handle paths with and without leading "file:" prefix.
              String urlFile = rootDirResource.getURL().getFile();
              int separatorIndex = urlFile.indexOf(ResourceUtils.JAR_URL_SEPARATOR);
              if (separatorIndex != -1) {
                  jarFileUrl = urlFile.substring(0, separatorIndex);
                  rootEntryPath = urlFile.substring(separatorIndex + ResourceUtils.JAR_URL_SEPARATOR.length());
                  jarFile = getJarFile(jarFileUrl);
              } else {
                  jarFile = new JarFile(urlFile);
                  jarFileUrl = urlFile;
                  rootEntryPath = "";
              }
              newJarFile = true;
          }
  
          try {
              if (!"".equals(rootEntryPath) && !rootEntryPath.endsWith("/")) {
                  // Root entry path must end with slash to allow for proper matching.
                  // The Sun JRE does not return a slash here, but BEA JRockit does.
                  rootEntryPath = rootEntryPath + "/";
              }
              Set<Resource> result = new LinkedHashSet<Resource>(8);
              for (Enumeration<JarEntry> entries = jarFile.entries(); entries.hasMoreElements(); ) {
                  JarEntry entry = entries.nextElement();
                  String entryPath = entry.getName();
                  if (entryPath.startsWith(rootEntryPath)) {
                      String relativePath = entryPath.substring(rootEntryPath.length());
                      if (getPathMatcher().match(subPattern, relativePath)) {
                          result.add(rootDirResource.createRelative(relativePath));
                      }
                  }
              }
              return result;
          } finally {
              // Close jar file, but only if freshly obtained -
              // not from JarURLConnection, which might cache the file reference.
              if (newJarFile) {
                  jarFile.close();
              }
          }
      }