src/share/classes/com/sun/java/util/jar/pack/PackageWriter.java

Print this page


   1 /*
   2  * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   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


 125      * or set the user defined version preset via properties.
 126      */
 127     void chooseDefaultPackageVersion() throws IOException {
 128         if (pkg.packageVersion != null) {
 129             packageVersion = pkg.packageVersion;
 130             if (verbose > 0) {
 131                 Utils.log.info("package version overridden with: "
 132                                 + packageVersion);
 133             }
 134             return;
 135         }
 136 
 137         Package.Version highV = getHighestClassVersion();
 138         // set the package version now
 139         if (highV.lessThan(JAVA6_MAX_CLASS_VERSION)) {
 140             // There are only old classfiles in this segment or resources
 141             packageVersion = JAVA5_PACKAGE_VERSION;
 142         } else if (highV.equals(JAVA6_MAX_CLASS_VERSION) ||
 143                 (highV.equals(JAVA7_MAX_CLASS_VERSION) && !pkg.cp.haveExtraTags())) {
 144             // force down the package version if we have jdk7 classes without
 145             // any Indy references, this is because jdk7 class file (52.0) without
 146             // Indy is identical to jdk6 class file (51.0).
 147             packageVersion = JAVA6_PACKAGE_VERSION;


 148         } else {
 149             // Normal case.  Use the newest archive format, when available
 150             packageVersion = JAVA7_PACKAGE_VERSION;
 151         }
 152 
 153         if (verbose > 0) {
 154             Utils.log.info("Highest version class file: " + highV
 155                     + " package version: " + packageVersion);
 156         }
 157     }
 158 
 159     void checkVersion() throws IOException {
 160         assert(packageVersion != null);
 161 
 162         if (packageVersion.lessThan(JAVA7_PACKAGE_VERSION)) {
 163             // this bit was reserved for future use in previous versions
 164             if (testBit(archiveOptions, AO_HAVE_CP_EXTRAS)) {
 165                 throw new IOException("Format bits for Java 7 must be zero in previous releases");
 166             }
 167         }
 168         if (testBit(archiveOptions, AO_UNUSED_MBZ)) {
 169             throw new IOException("High archive option bits are reserved and must be zero: " + Integer.toHexString(archiveOptions));
 170         }


   1 /*
   2  * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   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


 125      * or set the user defined version preset via properties.
 126      */
 127     void chooseDefaultPackageVersion() throws IOException {
 128         if (pkg.packageVersion != null) {
 129             packageVersion = pkg.packageVersion;
 130             if (verbose > 0) {
 131                 Utils.log.info("package version overridden with: "
 132                                 + packageVersion);
 133             }
 134             return;
 135         }
 136 
 137         Package.Version highV = getHighestClassVersion();
 138         // set the package version now
 139         if (highV.lessThan(JAVA6_MAX_CLASS_VERSION)) {
 140             // There are only old classfiles in this segment or resources
 141             packageVersion = JAVA5_PACKAGE_VERSION;
 142         } else if (highV.equals(JAVA6_MAX_CLASS_VERSION) ||
 143                 (highV.equals(JAVA7_MAX_CLASS_VERSION) && !pkg.cp.haveExtraTags())) {
 144             // force down the package version if we have jdk7 classes without
 145             // any Indy references, this is because jdk7 class file (51.0) without
 146             // Indy is identical to jdk6 class file (50.0).
 147             packageVersion = JAVA6_PACKAGE_VERSION;
 148         } else if (highV.equals(JAVA7_MAX_CLASS_VERSION)) {
 149             packageVersion = JAVA7_PACKAGE_VERSION;
 150         } else {
 151             // Normal case.  Use the newest archive format, when available
 152             packageVersion = JAVA8_PACKAGE_VERSION;
 153         }
 154 
 155         if (verbose > 0) {
 156             Utils.log.info("Highest version class file: " + highV
 157                     + " package version: " + packageVersion);
 158         }
 159     }
 160 
 161     void checkVersion() throws IOException {
 162         assert(packageVersion != null);
 163 
 164         if (packageVersion.lessThan(JAVA7_PACKAGE_VERSION)) {
 165             // this bit was reserved for future use in previous versions
 166             if (testBit(archiveOptions, AO_HAVE_CP_EXTRAS)) {
 167                 throw new IOException("Format bits for Java 7 must be zero in previous releases");
 168             }
 169         }
 170         if (testBit(archiveOptions, AO_UNUSED_MBZ)) {
 171             throw new IOException("High archive option bits are reserved and must be zero: " + Integer.toHexString(archiveOptions));
 172         }