< prev index next >

src/java.base/share/classes/java/util/jar/JarFile.java

Print this page
rev 51958 : 8211122: Reduce the number of internal classes made accessible to jdk.unsupported
Reviewed-by: alanb, dfuchs, kvn


   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package java.util.jar;
  27 
  28 import jdk.internal.misc.SharedSecrets;
  29 import jdk.internal.misc.JavaUtilZipFileAccess;
  30 import sun.security.action.GetPropertyAction;
  31 import sun.security.util.ManifestEntryVerifier;
  32 import sun.security.util.SignatureFileVerifier;
  33 
  34 import java.io.ByteArrayInputStream;
  35 import java.io.EOFException;
  36 import java.io.File;
  37 import java.io.IOException;
  38 import java.io.InputStream;
  39 import java.lang.ref.SoftReference;
  40 import java.net.URL;
  41 import java.security.CodeSigner;
  42 import java.security.CodeSource;
  43 import java.security.cert.Certificate;
  44 import java.util.ArrayList;
  45 import java.util.Collections;
  46 import java.util.Enumeration;
  47 import java.util.List;
  48 import java.util.Locale;
  49 import java.util.NoSuchElementException;


 155     private SoftReference<Manifest> manRef;
 156     private JarEntry manEntry;
 157     private JarVerifier jv;
 158     private boolean jvInitialized;
 159     private boolean verify;
 160     private final Runtime.Version version;  // current version
 161     private final int versionFeature;         // version.feature()
 162     private boolean isMultiRelease;         // is jar multi-release?
 163 
 164     // indicates if Class-Path attribute present
 165     private boolean hasClassPathAttribute;
 166     // true if manifest checked for special attributes
 167     private volatile boolean hasCheckedSpecialAttributes;
 168 
 169     private static final JavaUtilZipFileAccess JUZFA;
 170 
 171     static {
 172         // Set up JavaUtilJarAccess in SharedSecrets
 173         SharedSecrets.setJavaUtilJarAccess(new JavaUtilJarAccessImpl());
 174         // Get JavaUtilZipFileAccess from SharedSecrets
 175         JUZFA = jdk.internal.misc.SharedSecrets.getJavaUtilZipFileAccess();
 176         // multi-release jar file versions >= 9
 177         BASE_VERSION = Runtime.Version.parse(Integer.toString(8));
 178         BASE_VERSION_FEATURE = BASE_VERSION.feature();
 179         String jarVersion = GetPropertyAction.privilegedGetProperty("jdk.util.jar.version");
 180         int runtimeVersion = Runtime.version().feature();
 181         if (jarVersion != null) {
 182             int jarVer = Integer.parseInt(jarVersion);
 183             runtimeVersion = (jarVer > runtimeVersion)
 184                     ? runtimeVersion
 185                     : Math.max(jarVer, BASE_VERSION_FEATURE);
 186         }
 187         RUNTIME_VERSION = Runtime.Version.parse(Integer.toString(runtimeVersion));
 188         String enableMultiRelease = GetPropertyAction
 189                 .privilegedGetProperty("jdk.util.jar.enableMultiRelease", "true");
 190         switch (enableMultiRelease) {
 191             case "true":
 192             default:
 193                 MULTI_RELEASE_ENABLED = true;
 194                 MULTI_RELEASE_FORCED = false;
 195                 break;




   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package java.util.jar;
  27 
  28 import jdk.internal.access.SharedSecrets;
  29 import jdk.internal.access.JavaUtilZipFileAccess;
  30 import sun.security.action.GetPropertyAction;
  31 import sun.security.util.ManifestEntryVerifier;
  32 import sun.security.util.SignatureFileVerifier;
  33 
  34 import java.io.ByteArrayInputStream;
  35 import java.io.EOFException;
  36 import java.io.File;
  37 import java.io.IOException;
  38 import java.io.InputStream;
  39 import java.lang.ref.SoftReference;
  40 import java.net.URL;
  41 import java.security.CodeSigner;
  42 import java.security.CodeSource;
  43 import java.security.cert.Certificate;
  44 import java.util.ArrayList;
  45 import java.util.Collections;
  46 import java.util.Enumeration;
  47 import java.util.List;
  48 import java.util.Locale;
  49 import java.util.NoSuchElementException;


 155     private SoftReference<Manifest> manRef;
 156     private JarEntry manEntry;
 157     private JarVerifier jv;
 158     private boolean jvInitialized;
 159     private boolean verify;
 160     private final Runtime.Version version;  // current version
 161     private final int versionFeature;         // version.feature()
 162     private boolean isMultiRelease;         // is jar multi-release?
 163 
 164     // indicates if Class-Path attribute present
 165     private boolean hasClassPathAttribute;
 166     // true if manifest checked for special attributes
 167     private volatile boolean hasCheckedSpecialAttributes;
 168 
 169     private static final JavaUtilZipFileAccess JUZFA;
 170 
 171     static {
 172         // Set up JavaUtilJarAccess in SharedSecrets
 173         SharedSecrets.setJavaUtilJarAccess(new JavaUtilJarAccessImpl());
 174         // Get JavaUtilZipFileAccess from SharedSecrets
 175         JUZFA = SharedSecrets.getJavaUtilZipFileAccess();
 176         // multi-release jar file versions >= 9
 177         BASE_VERSION = Runtime.Version.parse(Integer.toString(8));
 178         BASE_VERSION_FEATURE = BASE_VERSION.feature();
 179         String jarVersion = GetPropertyAction.privilegedGetProperty("jdk.util.jar.version");
 180         int runtimeVersion = Runtime.version().feature();
 181         if (jarVersion != null) {
 182             int jarVer = Integer.parseInt(jarVersion);
 183             runtimeVersion = (jarVer > runtimeVersion)
 184                     ? runtimeVersion
 185                     : Math.max(jarVer, BASE_VERSION_FEATURE);
 186         }
 187         RUNTIME_VERSION = Runtime.Version.parse(Integer.toString(runtimeVersion));
 188         String enableMultiRelease = GetPropertyAction
 189                 .privilegedGetProperty("jdk.util.jar.enableMultiRelease", "true");
 190         switch (enableMultiRelease) {
 191             case "true":
 192             default:
 193                 MULTI_RELEASE_ENABLED = true;
 194                 MULTI_RELEASE_FORCED = false;
 195                 break;


< prev index next >