docs: static File jarFile(URL res, String qualifiedName) throws IOException {
          String resURL = res.toExternalForm();
          String originalURL = resURL;
          if (resURL.startsWith("jar:file:") || resURL.startsWith("wsjar:file:")) {
              return fromJarUrlToFile(resURL);
          }
  
          if (resURL.startsWith("code-source:/")) {
              // OC4J apparently uses this. See http://www.nabble.com/Hudson-on-OC4J-tt16702113.html
              resURL = resURL.substring("code-source:/".length(),
                  resURL.lastIndexOf('!')); // cut off jar: and the file name portion
              return new File(decode(new URL("file:/" + resURL).getPath()));
          }
  
          if (resURL.startsWith("zip:")) {
              // weblogic uses this. See http://www.nabble.com/patch-to-get-Hudson-working-on-weblogic-td23997258.html
              // also see http://www.nabble.com/Re%3A-Hudson-on-Weblogic-10.3-td25038378.html#a25043415
              resURL = resURL.substring("zip:".length(), resURL.lastIndexOf('!')); // cut off zip: and the file name portion
              return new File(decode(new URL("file:" + resURL).getPath()));
          }
  
          if (resURL.startsWith("file:")) {
              // unpackaged classes
              int n = qualifiedName.split("/").length; // how many slashes do wo need to cut?
              for (; n > 0; n--) {
                  int idx = Math.max(resURL.lastIndexOf('/'), resURL.lastIndexOf('\\'));
                  if (idx < 0) throw new IllegalArgumentException(originalURL + " - " + resURL);
                  resURL = resURL.substring(0, idx);
              }
  
              // won't work if res URL contains ' '
              // return new File(new URI(null,new URL(res).toExternalForm(),null));
              // won't work if res URL contains '%20'
              // return new File(new URL(res).toURI());
  
              return new File(decode(new URL(resURL).getPath()));
          }
  
          if (resURL.startsWith("vfszip:")) {
              // JBoss5
              InputStream is = res.openStream();
              try {
                  Object delegate = is;
                  while (delegate.getClass().getEnclosingClass() != ZipFile.class) {
                      Field f = delegate.getClass().getDeclaredField("delegate");
                      f.setAccessible(true);
                      delegate = f.get(delegate);
                      //JENKINS-5922 - workaround for CertificateReaderInputStream; JBoss 5.0.0, EAP 5.0 and EAP 5.1
                      if (delegate.getClass().getName().equals("java.util.jar.JarVerifier$VerifierStream")) {
                          f = delegate.getClass().getDeclaredField("is");
                          f.setAccessible(true);
                          delegate = f.get(delegate);
                      }
                  }
                  Field f = delegate.getClass().getDeclaredField("this$0");
                  f.setAccessible(true);
                  ZipFile zipFile = (ZipFile) f.get(delegate);
                  return new File(zipFile.getName());
              } catch (NoSuchFieldException e) {
                  // something must have changed in JBoss5. fall through
                  LOGGER.log(Level.FINE, "Failed to resolve vfszip into a jar location", e);
              } catch (IllegalAccessException e) {
                  // something must have changed in JBoss5. fall through
                  LOGGER.log(Level.FINE, "Failed to resolve vfszip into a jar location", e);
              } finally {
                  is.close();
              }
          }
  
          if (resURL.startsWith("vfs:")) {
              // JBoss6
              String dotdot = "";
              for (int i = qualifiedName.split("/").length; i > 1; i--)
                  dotdot += "../";
  
              try {
                  URL jar = new URL(res, dotdot);
                  String path = jar.getPath();
                  if (path.endsWith("/")) path = path.substring(0, path.length() - 1);
                  // obtain the file name portion
                  String fileName = path.substring(path.lastIndexOf('/') + 1);
  
                  Object vfs = new URL(jar, "..").getContent(); // a VirtualFile object pointing to the parent of the jar
                  File dir = (File) vfs.getClass().getMethod("getPhysicalFile").invoke(vfs);
  
                  File jarFile = new File(dir, fileName);
                  if (jarFile.exists()) return jarFile;
              } catch (Exception e) {
                  LOGGER.log(Level.FINE, "Failed to resolve vfs file into a location", e);
              }
          }
  
          URLConnection con = res.openConnection();
          if (con instanceof JarURLConnection) {
              JarURLConnection jcon = (JarURLConnection) con;
              JarFile jarFile = jcon.getJarFile();
              if (jarFile != null) {
                  String n = jarFile.getName();
                  if (n.length() > 0) {// JDK6u10 needs this
                      return new File(n);
                  } else {
                      // JDK6u10 apparently starts hiding the real jar file name,
                      // so this just keeps getting tricker and trickier...
                      try {
                          Field f = ZipFile.class.getDeclaredField("name");
                          f.setAccessible(true);
                          return new File((String) f.get(jarFile));
                      } catch (NoSuchFieldException e) {
                          LOGGER.log(Level.INFO, "Failed to obtain the local cache file name of " + resURL, e);
                      } catch (IllegalAccessException e) {
                          LOGGER.log(Level.INFO, "Failed to obtain the local cache file name of " + resURL, e);
                      }
                  }
              }
          }
  
          throw new IllegalArgumentException(originalURL + " - " + resURL);
      }