changeset 13815:721288127c82

8150679: closed/javax/crypto/CryptoPermission/CallerIdentification.sh fails after fix for JDK-8132734 Summary: also fixes JDK-8150920 Reviewed-by: psandoz, redestad Contributed-by: steve.drach@oracle.com
author sdrach
date Thu, 03 Mar 2016 09:47:40 -0800
parents a603b1f1d9a1
children 232843a54696
files src/java.base/share/classes/java/util/jar/JarFile.java test/sun/net/www/protocol/jar/MultiReleaseJarURLConnection.java
diffstat 2 files changed, 29 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.base/share/classes/java/util/jar/JarFile.java	Thu Mar 03 12:49:12 2016 -0800
+++ b/src/java.base/share/classes/java/util/jar/JarFile.java	Thu Mar 03 09:47:40 2016 -0800
@@ -893,11 +893,15 @@
     }
 
     private JarEntry verifiableEntry(ZipEntry ze) {
-        if (!(ze instanceof JarFileEntry)) {
-            ze = getJarEntry(ze.getName());
+        if (ze instanceof JarFileEntry) {
+            // assure the name and entry match for verification
+            return ((JarFileEntry)ze).reifiedEntry();
         }
-        // assure the name and entry match for verification
-        return ze == null ? null : ((JarFileEntry)ze).reifiedEntry();
+        ze = getJarEntry(ze.getName());
+        if (ze instanceof JarFileEntry) {
+            return ((JarFileEntry)ze).reifiedEntry();
+        }
+        return (JarEntry)ze;
     }
 
     // Statics for hand-coded Boyer-Moore search
--- a/test/sun/net/www/protocol/jar/MultiReleaseJarURLConnection.java	Thu Mar 03 12:49:12 2016 -0800
+++ b/test/sun/net/www/protocol/jar/MultiReleaseJarURLConnection.java	Thu Mar 03 09:47:40 2016 -0800
@@ -42,27 +42,40 @@
 import org.testng.Assert;
 import org.testng.annotations.AfterClass;
 import org.testng.annotations.BeforeClass;
+import org.testng.annotations.DataProvider;
 import org.testng.annotations.Test;
 
 public class MultiReleaseJarURLConnection {
     String userdir = System.getProperty("user.dir",".");
-    String urlFile = "jar:file:" + userdir + "/multi-release.jar!/";
-    String urlEntry = urlFile + "version/Version.java";
+    String file = userdir + "/signed-multi-release.jar";
 
     @BeforeClass
     public void initialize() throws Exception {
         CreateMultiReleaseTestJars creator = new CreateMultiReleaseTestJars();
         creator.compileEntries();
         creator.buildMultiReleaseJar();
+        creator.buildSignedMultiReleaseJar();
     }
 
     @AfterClass
     public void close() throws IOException {
         Files.delete(Paths.get(userdir, "multi-release.jar"));
+        Files.delete(Paths.get(userdir, "signed-multi-release.jar"));
     }
 
-    @Test
-    public void testRuntimeVersioning() throws Exception {
+    @DataProvider(name = "data")
+    public Object[][] createData() {
+        return new Object[][]{
+                {"unsigned file", userdir + "/multi-release.jar"},
+                {"signed file", userdir + "/signed-multi-release.jar"},
+        };
+    }
+
+    @Test(dataProvider = "data")
+    public void testRuntimeVersioning(String ignore, String file) throws Exception {
+        String urlFile = "jar:file:" + file + "!/";
+        String urlEntry = urlFile + "version/Version.java";
+
         Assert.assertTrue(readAndCompare(new URL(urlEntry), "return 8"));
         // #runtime is "magic"
         Assert.assertTrue(readAndCompare(new URL(urlEntry + "#runtime"), "return 9"));
@@ -72,8 +85,10 @@
         Assert.assertTrue(readAndCompare(new URL(urlEntry), "return 8"));
     }
 
-    @Test
-    public void testCachedJars() throws Exception {
+    @Test(dataProvider = "data")
+    public void testCachedJars(String ignore, String file) throws Exception {
+        String urlFile = "jar:file:" + file + "!/";
+
         URL rootUrl = new URL(urlFile);
         JarURLConnection juc = (JarURLConnection)rootUrl.openConnection();
         JarFile rootJar = juc.getJarFile();