@Override public Object run() throws ClassNotFoundException { // First think check if we are allowed to define the package checkPackageDefinition(className); ResourceHandle resourceHandle = findClassFileResource(className); byte[] bytes; Manifest manifest; try { // get the bytes from the class file bytes = resourceHandle.getBytes(); // get the manifest for defining the packages manifest = resourceHandle.getManifest(); } catch (IOException e) { throw new ClassNotFoundException(className, e); } // get the certificates for the code source Certificate[] certificates = resourceHandle.getCertificates(); // the code source url is used to define the package and as the security context for the class URL codeSourceUrl = resourceHandle.getCodeSourceUrl(); // define the package (required for security) definePackage(className, codeSourceUrl, manifest); // this is the security context of the class CodeSource codeSource = new CodeSource(codeSourceUrl, certificates); // load the class into the vm return defineClass(className, bytes, 0, bytes.length, codeSource); }
private void fetchNext() { if (iterator == null) { return; } if (next != null) { return; } try { while (iterator.hasNext()) { ResourceLocation resourceLocation = (ResourceLocation) iterator.next(); ResourceHandle resourceHandle = resourceLocation.getResourceHandle(resourceName); if (resourceHandle != null) { next = resourceHandle.getUrl(); return; } } // no more elements // clear the iterator so it can be GCed iterator = null; } catch (IllegalStateException e) { // Jar file was closed... this means the resource finder was destroyed // clear the iterator so it can be GCed iterator = null; throw e; } } }
public ResourceHandle getResource(String resourceName) { synchronized (lock) { if (destroyed) { return null; } for (Iterator iterator = getClassPath().entrySet().iterator(); iterator.hasNext();) { Map.Entry entry = (Map.Entry) iterator.next(); ResourceLocation resourceLocation = (ResourceLocation) entry.getValue(); ResourceHandle resourceHandle = resourceLocation.getResourceHandle(resourceName); if (resourceHandle != null && !resourceHandle.isDirectory()) { return resourceHandle; } } } return null; }
@Override public Object run() throws ClassNotFoundException { // First think check if we are allowed to define the package checkPackageDefinition(className); ResourceHandle resourceHandle = findClassFileResource(className); byte[] bytes; Manifest manifest; try { // get the bytes from the class file bytes = resourceHandle.getBytes(); // get the manifest for defining the packages manifest = resourceHandle.getManifest(); } catch (IOException e) { throw new ClassNotFoundException(className, e); } // get the certificates for the code source Certificate[] certificates = resourceHandle.getCertificates(); // the code source url is used to define the package and as the security context for the class URL codeSourceUrl = resourceHandle.getCodeSourceUrl(); // define the package (required for security) definePackage(className, codeSourceUrl, manifest); // this is the security context of the class CodeSource codeSource = new CodeSource(codeSourceUrl, certificates); // load the class into the vm return defineClass(className, bytes, 0, bytes.length, codeSource); }
public URL findResource(String resourceName) { synchronized (lock) { if (destroyed) { return null; } for (Iterator iterator = getClassPath().entrySet().iterator(); iterator.hasNext();) { Map.Entry entry = (Map.Entry) iterator.next(); ResourceLocation resourceLocation = (ResourceLocation) entry.getValue(); ResourceHandle resourceHandle = resourceLocation.getResourceHandle(resourceName); if (resourceHandle != null) { return resourceHandle.getUrl(); } } } return null; }
try { bytes = resourceHandle.getBytes(); manifest = resourceHandle.getManifest(); } catch (IOException e) { throw new ClassNotFoundException(className, e); Certificate[] certificates = resourceHandle.getCertificates(); URL codeSourceUrl = resourceHandle.getCodeSourceUrl();
URL url = resourceHandle.getUrl(); if (!"file".equals(url.getProtocol())) { return null;
URL url = resourceHandle.getUrl(); if (!"file".equals(url.getProtocol())) { return null;
URL url = resourceHandle.getUrl(); if (!"file".equals(url.getProtocol())) { return null;