Lines 58-63
Link Here
|
58 |
import java.net.URI; |
58 |
import java.net.URI; |
59 |
import java.net.URISyntaxException; |
59 |
import java.net.URISyntaxException; |
60 |
import java.net.URL; |
60 |
import java.net.URL; |
|
|
61 |
import java.net.URLConnection; |
61 |
import java.net.URLStreamHandler; |
62 |
import java.net.URLStreamHandler; |
62 |
import java.security.CodeSource; |
63 |
import java.security.CodeSource; |
63 |
import java.security.PermissionCollection; |
64 |
import java.security.PermissionCollection; |
Lines 505-511
Link Here
|
505 |
if (buf == null) return null; |
506 |
if (buf == null) return null; |
506 |
LOGGER.log(Level.FINER, "Loading {0} from {1}", new Object[] {name, file.getPath()}); |
507 |
LOGGER.log(Level.FINER, "Loading {0} from {1}", new Object[] {name, file.getPath()}); |
507 |
try { |
508 |
try { |
508 |
return new URL(resPrefix + new URI(null, name, null).getRawPath()); |
509 |
return new URL(null, resPrefix + new URI(null, name, null).getRawPath(), new JarURLStreamHandler(jcl)); |
509 |
} catch (URISyntaxException x) { |
510 |
} catch (URISyntaxException x) { |
510 |
throw new IOException(name + " in " + resPrefix + ": " + x.toString(), x); |
511 |
throw new IOException(name + " in " + resPrefix + ": " + x.toString(), x); |
511 |
} |
512 |
} |
Lines 830-841
Link Here
|
830 |
|
831 |
|
831 |
static class JarURLStreamHandler extends URLStreamHandler { |
832 |
static class JarURLStreamHandler extends URLStreamHandler { |
832 |
|
833 |
|
|
|
834 |
private static final URLStreamHandler fallback = new URLStreamHandler() { |
835 |
protected @Override URLConnection openConnection(URL u) throws IOException { |
836 |
return new URL(u.toString()).openConnection(); |
837 |
} |
838 |
}; |
839 |
|
833 |
private final URLStreamHandler originalJarHandler; |
840 |
private final URLStreamHandler originalJarHandler; |
|
|
841 |
private ClassLoader loader; |
834 |
|
842 |
|
835 |
JarURLStreamHandler(URLStreamHandler originalJarHandler) { |
843 |
JarURLStreamHandler(URLStreamHandler originalJarHandler) { |
836 |
this.originalJarHandler = originalJarHandler; |
844 |
this.originalJarHandler = originalJarHandler; |
837 |
} |
845 |
} |
838 |
|
846 |
|
|
|
847 |
private JarURLStreamHandler(ClassLoader l) { |
848 |
this(fallback); |
849 |
this.loader = l; |
850 |
} |
851 |
|
839 |
/** |
852 |
/** |
840 |
* Creates URLConnection for URL with res protocol. |
853 |
* Creates URLConnection for URL with res protocol. |
841 |
* @param u URL for which the URLConnection should be created |
854 |
* @param u URL for which the URLConnection should be created |
Lines 871-877
Link Here
|
871 |
} catch (URISyntaxException x) { |
884 |
} catch (URISyntaxException x) { |
872 |
throw (IOException) new IOException("Decoding " + u + ": " + x).initCause(x); |
885 |
throw (IOException) new IOException("Decoding " + u + ": " + x).initCause(x); |
873 |
} |
886 |
} |
874 |
return new NbJarURLConnection (u, _src, _name); |
887 |
return new NbJarURLConnection(u, _src, _name, loader); |
875 |
} |
888 |
} |
876 |
|
889 |
|
877 |
@Override |
890 |
@Override |
Lines 893-908
Link Here
|
893 |
private final String name; |
906 |
private final String name; |
894 |
private byte[] data; |
907 |
private byte[] data; |
895 |
private InputStream iStream; |
908 |
private InputStream iStream; |
|
|
909 |
private final ClassLoader loader; |
896 |
|
910 |
|
897 |
/** |
911 |
/** |
898 |
* Creates new URLConnection |
912 |
* Creates new URLConnection |
899 |
* @param url the parameter for which the connection should be |
913 |
* @param url the parameter for which the connection should be |
900 |
* created |
914 |
* created |
901 |
*/ |
915 |
*/ |
902 |
private NbJarURLConnection(URL url, Source src, String name) throws MalformedURLException { |
916 |
private NbJarURLConnection(URL url, Source src, String name, ClassLoader l) throws MalformedURLException { |
903 |
super(url); |
917 |
super(url); |
904 |
this.src = (JarSource)src; |
918 |
this.src = (JarSource)src; |
905 |
this.name = name; |
919 |
this.name = name; |
|
|
920 |
this.loader = l; |
906 |
} |
921 |
} |
907 |
|
922 |
|
908 |
private boolean isFolder() { |
923 |
private boolean isFolder() { |
Lines 961-965
Link Here
|
961 |
public JarFile getJarFile() throws IOException { |
976 |
public JarFile getJarFile() throws IOException { |
962 |
return new JarFile(src.file); // #134424 |
977 |
return new JarFile(src.file); // #134424 |
963 |
} |
978 |
} |
|
|
979 |
|
980 |
public @Override Object getContent(Class[] classes) throws IOException { |
981 |
if (Arrays.asList(classes).contains(ClassLoader.class)) { |
982 |
return loader; |
983 |
} else { |
984 |
return super.getContent(classes); |
964 |
} |
985 |
} |
965 |
} |
986 |
} |
|
|
987 |
|
988 |
} |
989 |
} |