Try to load resource from JAR file of Findbugs core plugin.
@param slashedResourceName Name of resource to load
@return URL which points resource in jar file, or null if JAR file not found
557623
@CheckForNull
    private static URL resourceFromFindbugsJar(String slashedResourceName) {
        try {
            @Nullable
            URL findbugsJar = getFindbugsJar();
            if (findbugsJar == null) {
                return null;
            }
            assert findbugsJar.getProtocol().equals("file");
            try (ZipFile jarFile = new ZipFile(new File(findbugsJar.toURI()))) {
                ZipEntry entry = jarFile.getEntry(slashedResourceName);
                if (entry != null) {
                    return resourceFromPlugin(findbugsJar, slashedResourceName);
                }
            } catch (ZipException e) {
                LOG.warn("Failed to load resourceFromFindbugsJar: {} is not valid zip file.", findbugsJar, e);
            } catch (IOException e) {
                LOG.warn("Failed to load resourceFromFindbugsJar: IOException was thrown at zip file {} loading.",
                        findbugsJar, e);
            }
        } catch (MalformedURLException | URISyntaxException e) {
            LOG.warn("Failed to load resourceFromFindbugsJar: Resource name is {}", slashedResourceName, e);
        }
        return null;
    }
675107
@Override
    public URL getResource(String name) {
        return name == null ? null : shadowedLoader.getResource(name);
    }
305897
@Override
	public URL getResource(String resourceName) {
		final String sourceMethod = "getResource"; //$NON-NLS-1$
		boolean isTraceLogging = log.isLoggable(Level.FINER);
		if (isTraceLogging) {
			log.entering(PlatformServicesImpl.class.getName(), sourceMethod, new Object[]{resourceName});
		}
		URL result = null;
		if (contributingBundle != null) {
			result = contributingBundle.getResource(resourceName);
		}
		if (isTraceLogging) {
			log.exiting(PlatformServicesImpl.class.getName(), sourceMethod, result);
		}
		return result;
	}
825436
String getResourceName() {
        if (!resourceNameKnown) {
            // The resource name of a classfile can only be determined by
            // reading
            // the file and parsing the constant pool.
            // If we can't do this for some reason, then we just
            // make the resource name equal to the filename.

            try {
                resourceName = getClassDescriptor().toResourceName();
            } catch (Exception e) {
                resourceName = fileName;
            }

            resourceNameKnown = true;
        }
        return resourceName;
    }
1278165
public static Reader resource(String resourceName) {
        if (resourceName == null) {
            throw new NullPointerException("'null' passed instead of resource name");
        }

        final InputStream resourceStream = ClassLoader.getSystemResourceAsStream(resourceName);
        if (resourceStream == null) {
            throw new IllegalArgumentException(format("resource '%s' not found", resourceName));
        }

        return new BufferedReader(new InputStreamReader(resourceStream));
    }
50859
public static URL getResource(String resource, Class<?> baseClass) {
		return (null != baseClass) ? baseClass.getResource(resource) : ClassLoaderUtil.getClassLoader().getResource(resource);
	}
500352
@Override
	@Pure
	public Enumeration<URL> findResources(final String name) throws IOException {
		final Enumeration<?> e = this.ucp.findResources(name, true);

		return new Enumeration<URL>() {
			private URL url;

			private boolean next() {
				if (this.url != null) {
					return true;
				}
				do {
					final URL u = AccessController.doPrivileged(new PrivilegedAction<URL>() {
						@Override
						public URL run() {
							if (!e.hasMoreElements()) {
								return null;
							}
							return (URL) e.nextElement();
						}
					}, DynamicURLClassLoader.this.acc);
					if (u == null) {
						break;
					}
					this.url = DynamicURLClassLoader.this.ucp.checkURL(u);
				}
				while (this.url == null);

				return this.url != null;
			}

			@Override
			public URL nextElement() {
				if (!next()) {
					throw new NoSuchElementException();
				}
				final URL u = this.url;
				this.url = null;
				return u;
			}

			@Override
			public boolean hasMoreElements() {
				return next();
			}
		};
	}
1217887
public static Path getJarPathFromUrl(URL jarUrl) {
        try {
            String pathString = jarUrl.getPath();
            // for Jar URL, the path is in the form of: file:/path/to/groovy/myJar.jar!/path/to/resource/myResource.txt
            int endIndex = pathString.lastIndexOf("!");
            return Paths.get(new URI(pathString.substring(0, endIndex)));
        } catch (URISyntaxException e) {
            throw new IllegalStateException("Unsupported URL syntax: " + jarUrl.getPath(), e);
        }
    }
764983
@Override
    public Enumeration<URL> getResources(String name) throws IOException {
        if (this.rootClassLoader == null) {
            return findResources(name);
        }
        return new ResourceEnumeration(this.rootClassLoader.getResources(name),
                findResources(name));
    }
527419
private static URL getUrlValueFromRow(QuerySolution resultRow, String variableName) {

        // Check the input and exit immediately if null
        if (resultRow == null) {
            return null;
        }
        URL result = null;
        Resource res = resultRow.getResource(variableName);

        // Ignore and track services that are blank nodes
        if (res.isAnon()) {
            log.warn("Blank node found and ignored " + res.toString());
        } else if (res.isURIResource()) {
            try {
                result = new URL(res.getURI());
            } catch (MalformedURLException e) {
                log.error("Malformed URL for node", e);
            } catch (ClassCastException e) {
                log.error("The node is not a URI", e);
            }
        }

        return result;
    }
603580
public URLConnection getResourceConnection(String resourceName) throws ResourceException {
        // Get the URLConnection
        URLConnection groovyScriptConn = null;

        ResourceException se = null;
        for (URL root : roots) {
            URL scriptURL = null;
            try {
                scriptURL = new URL(root, resourceName);
                groovyScriptConn = openConnection(scriptURL);

                break; // Now this is a bit unusual
            } catch (MalformedURLException e) {
                String message = "Malformed URL: " + root + ", " + resourceName;
                if (se == null) {
                    se = new ResourceException(message);
                } else {
                    se = new ResourceException(message, se);
                }
            } catch (IOException e1) {
                String message = "Cannot open URL: " + root + resourceName;
                groovyScriptConn = null;
                if (se == null) {
                    se = new ResourceException(message);
                } else {
                    se = new ResourceException(message, se);
                }
            }
        }

        if (se == null) se = new ResourceException("No resource for " + resourceName + " was found");

        // If we didn't find anything, report on all the exceptions that occurred.
        if (groovyScriptConn == null) throw se;
        return groovyScriptConn;
    }
959187
public URL getResource(String name)
  {
    Path path;

    path = getPath(name);

    if (path != null && path.exists()) {
      try {
        return path.getNetURL();
      } catch (Exception e) {
        log.log(Level.FINER, e.toString(), e);
      }
    }

    return null;
  }
1014038
function getResourcePath(sResourceName, sSuffix) {

		var sNamePrefix = sResourceName,
			p = sResourceName.length,
			sPath;

		// search for a registered name prefix, starting with the full name and successively removing one segment
		while ( p > 0 && !mUrlPrefixes[sNamePrefix] ) {
			p = sNamePrefix.lastIndexOf('/');
			// Note: an empty segment at p = 0 (leading slash) will be ignored
			sNamePrefix = p > 0 ? sNamePrefix.slice(0, p) : '';
		}

		assert((p > 0 || sNamePrefix === '') && mUrlPrefixes[sNamePrefix], "there always must be a mapping");

		sPath = mUrlPrefixes[sNamePrefix].url + sResourceName.slice(p + 1); // also skips a leading slash!

		//remove trailing slash
		if ( sPath.slice(-1) === '/' ) {
			sPath = sPath.slice(0, -1);
		}
		return sPath + (sSuffix || '');

	}
114291
private List<URL> getResources() throws IOException {
        final ClassLoader cl = getClassLoader();

        // ConcurrentHashMap doesn't support null keys, so substitute a pseudo
        // key
        final Object key = cl == null ? NULL_CLASS_LOADER : cl;

        // computeIfAbsent requires unchecked exceptions for the creation
        // process, so we
        // cannot easily use it directly, instead using get and putIfAbsent
        List<URL> newValue = cachedResourceList.get(key);
        if (newValue != null) {
            return newValue;
        }

        if (cl != null) {
            newValue = Collections
                    .unmodifiableList(Collections.list(cl.getResources(JARCACHE_JSON)));
        } else {
            newValue = Collections.unmodifiableList(
                    Collections.list(ClassLoader.getSystemResources(JARCACHE_JSON)));
        }

        final List<URL> oldValue = cachedResourceList.putIfAbsent(key, newValue);
        // We are not synchronising access to the ConcurrentMap, so if there
        // were
        // multiple classpath scans, we always choose the first one
        return oldValue != null ? oldValue : newValue;
    }
335553
public byte[] getResource(String pluginName, String fileName) throws Exception {
        // TODO: This is going to be slow.. future improvement is to cache the data instead of searching all jars
        for (String jarFilename : jarInformation) {
            JarFile jarFile = new JarFile(new File(jarFilename));
            Enumeration<?> enumer = jarFile.entries();

            // Use the Plugin-Name manifest entry to match with the provided pluginName
            String jarPluginName = jarFile.getManifest().getMainAttributes().getValue("Plugin-Name");

            if (!jarPluginName.equals(pluginName)) {
                continue;
            }

            while (enumer.hasMoreElements()) {
                Object element = enumer.nextElement();
                String elementName = element.toString();

                // Skip items in the jar that don't start with "resources/"
                if (!elementName.startsWith("resources/")) {
                    continue;
                }

                elementName = elementName.replace("resources/", "");
                if (elementName.equals(fileName)) {
                    // get the file from the jar
                    ZipEntry ze = jarFile.getEntry(element.toString());

                    InputStream fileStream = jarFile.getInputStream(ze);
                    byte[] data = new byte[(int) ze.getSize()];
                    DataInputStream dataIs = new DataInputStream(fileStream);
                    dataIs.readFully(data);
                    dataIs.close();
                    return data;
                }
            }
        }
        throw new FileNotFoundException("Could not find resource");
    }
323762
public URL getResource(String name) {
        for (int i = 0; i < classLoaders.length; i++) {
            URL url = classLoaders[i].getResource(name);
            if (url != null) {
                return url;
            }
        }
        if (getParent() != null) {
            return super.getResource(name);
        } else {
            return null;
        }
    }
1143694
private Set<String> getResourceNamesFromJar(String path, URL resourceURL) {

		URLConnection con = null;

		try {
			if (resourceURL.toString().startsWith(JawrConstant.JAR_URL_PREFIX)) {
				con = resourceURL.openConnection();
			}
		} catch (IOException e) {

			if (LOGGER.isDebugEnabled()) {
				LOGGER.debug("Unable to find resources name for path '" + path + "'", e);
			}
			return Collections.emptySet();
		}

		JarFile jarFile;
		String jarFileUrl;
		String rootEntryPath;
		boolean newJarFile = false;

		try {
			if (con instanceof JarURLConnection) {
				// Should usually be the case for traditional JAR files.
				JarURLConnection jarCon = (JarURLConnection) con;
				jarCon.setUseCaches(true);
				jarFile = jarCon.getJarFile();
				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 = resourceURL.getFile();
				int separatorIndex = urlFile.indexOf(JAR_URL_SEPARATOR);
				if (separatorIndex != -1) {
					jarFileUrl = urlFile.substring(0, separatorIndex);
					rootEntryPath = urlFile.substring(separatorIndex + JAR_URL_SEPARATOR.length());
					jarFile = getJarFile(jarFileUrl);
				} else {
					jarFile = new JarFile(urlFile);
					rootEntryPath = "";
				}
				newJarFile = true;
			}
		} catch (IOException e) {
			if (LOGGER.isDebugEnabled()) {
				LOGGER.debug("Unable to find resources name for path '" + path + "'", e);
			}
			return Collections.emptySet();
		}
		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<String> result = new LinkedHashSet<>(8);
			for (Enumeration<JarEntry> entries = jarFile.entries(); entries.hasMoreElements();) {
				JarEntry entry = entries.nextElement();
				String entryPath = entry.getName();
				if (isDirectChildPath(rootEntryPath, entryPath)) {
					String relativePath = entryPath.substring(rootEntryPath.length());
					result.add(relativePath);
				}
			}
			return result;
		} finally {
			// Close jar file, but only if freshly obtained -
			// not from JarURLConnection, which might cache the file reference.
			if (newJarFile) {
				try {
					jarFile.close();
				} catch (IOException e) {
					// Nothing to do
				}
			}
		}
	}