jdk/src/java.base/share/classes/sun/misc/URLClassPath.java
changeset 36129 332b49163fc9
parent 36000 86257b272c96
child 36251 e909478d3e1d
equal deleted inserted replaced
36128:e17994ab030a 36129:332b49163fc9
    61 import java.util.zip.ZipEntry;
    61 import java.util.zip.ZipEntry;
    62 import java.util.jar.JarEntry;
    62 import java.util.jar.JarEntry;
    63 import java.util.jar.Manifest;
    63 import java.util.jar.Manifest;
    64 import java.util.jar.Attributes;
    64 import java.util.jar.Attributes;
    65 import java.util.jar.Attributes.Name;
    65 import java.util.jar.Attributes.Name;
       
    66 import java.util.zip.ZipFile;
    66 
    67 
    67 import jdk.internal.jimage.ImageLocation;
    68 import jdk.internal.jimage.ImageLocation;
    68 import jdk.internal.jimage.ImageReader;
    69 import jdk.internal.jimage.ImageReader;
    69 import jdk.internal.misc.JavaUtilZipFileAccess;
    70 import jdk.internal.misc.JavaUtilZipFileAccess;
    70 import jdk.internal.misc.SharedSecrets;
    71 import jdk.internal.misc.SharedSecrets;
   725             if (isOptimizable(url)) {
   726             if (isOptimizable(url)) {
   726                 FileURLMapper p = new FileURLMapper (url);
   727                 FileURLMapper p = new FileURLMapper (url);
   727                 if (!p.exists()) {
   728                 if (!p.exists()) {
   728                     throw new FileNotFoundException(p.getPath());
   729                     throw new FileNotFoundException(p.getPath());
   729                 }
   730                 }
   730                 return checkJar(new JarFile(p.getPath()));
   731                 return checkJar(new JarFile(new File(p.getPath()), true, ZipFile.OPEN_READ,
   731             }
   732                         JarFile.Release.RUNTIME));
   732             URLConnection uc = getBaseURL().openConnection();
   733             }
       
   734             URLConnection uc = (new URL(getBaseURL(), "#runtime")).openConnection();
   733             uc.setRequestProperty(USER_AGENT_JAVA_VERSION, JAVA_VERSION);
   735             uc.setRequestProperty(USER_AGENT_JAVA_VERSION, JAVA_VERSION);
   734             JarFile jarFile = ((JarURLConnection)uc).getJarFile();
   736             JarFile jarFile = ((JarURLConnection)uc).getJarFile();
   735             return checkJar(jarFile);
   737             return checkJar(jarFile);
   736         }
   738         }
   737 
   739 
   754         Resource checkResource(final String name, boolean check,
   756         Resource checkResource(final String name, boolean check,
   755             final JarEntry entry) {
   757             final JarEntry entry) {
   756 
   758 
   757             final URL url;
   759             final URL url;
   758             try {
   760             try {
   759                 url = new URL(getBaseURL(), ParseUtil.encodePath(name, false));
   761                 // add #runtime fragment to tell JarURLConnection to use
       
   762                 // runtime versioning if the underlying jar file is multi-release
       
   763                 url = new URL(getBaseURL(), ParseUtil.encodePath(name, false) + "#runtime");
   760                 if (check) {
   764                 if (check) {
   761                     URLClassPath.check(url);
   765                     URLClassPath.check(url);
   762                 }
   766                 }
   763             } catch (MalformedURLException e) {
   767             } catch (MalformedURLException e) {
   764                 return null;
   768                 return null;