< prev index next >

src/java.base/share/classes/java/lang/reflect/ClassFileFormatVersion.java

Print this page

  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.lang.reflect;
 27 




 28 /**
 29  * Class file format versions of the Java virtual machine.
 30  *
 31  * See the appropriate edition of <cite>The Java Virtual Machine
 32  * Specification</cite> for information about a particular class file
 33  * format version.
 34  *
 35  * <p>Note that additional class file format version constants will be
 36  * added to model future releases of the Java Virtual Machine
 37  * Specification.
 38  *
 39  * @apiNote
 40  * The complete version used in a class file includes a major version
 41  * and a minor version; this enum only models the major version. A
 42  * Java virtual machine implementation is required to support a range
 43  * of major versions; see the corresponding edition of the <cite>The
 44  * Java Virtual Machine Specification</cite> for details.
 45  *
 46  * @since 20
 47  * @see System#getProperties System property {@code java.class.version}

378      *
379      * @since 26
380      *
381      * @see <a
382      * href="https://docs.oracle.com/en/java/javase/26/docs/specs/jvms/index.html">
383      * <cite>The Java Virtual Machine Specification, Java SE 26 Edition</cite></a>
384      */
385     RELEASE_26(70),
386 
387     /**
388      * The version introduced by the Java Platform, Standard Edition
389      * 27.
390      *
391      * @since 27
392      *
393      * @see <a
394      * href="https://docs.oracle.com/en/java/javase/27/docs/specs/jvms/index.html">
395      * <cite>The Java Virtual Machine Specification, Java SE 27 Edition</cite></a>
396      */
397     RELEASE_27(71),
398     ; // Reduce code churn when appending new constants
399 

400     // Note to maintainers: when adding constants for newer releases,
401     // the implementation of latest() must be updated too.
402 





403     private final int major;
404 
405     private ClassFileFormatVersion(int major) {
406         this.major = major;
407     }
408 
409     /**
410      * {@return the latest class file format version}
411      */
412     public static ClassFileFormatVersion latest() {
413         return RELEASE_27;
414     }
415 
416     /**
417      * {@return the major class file version as an integer}
418      * @jvms 4.1 The {@code ClassFile} Structure
419      */
420     public int major() {
421         return major;
422     }

  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.lang.reflect;
 27 
 28 import java.lang.classfile.ClassFile;
 29 
 30 import jdk.internal.javac.PreviewFeature;
 31 
 32 /**
 33  * Class file format versions of the Java virtual machine.
 34  *
 35  * See the appropriate edition of <cite>The Java Virtual Machine
 36  * Specification</cite> for information about a particular class file
 37  * format version.
 38  *
 39  * <p>Note that additional class file format version constants will be
 40  * added to model future releases of the Java Virtual Machine
 41  * Specification.
 42  *
 43  * @apiNote
 44  * The complete version used in a class file includes a major version
 45  * and a minor version; this enum only models the major version. A
 46  * Java virtual machine implementation is required to support a range
 47  * of major versions; see the corresponding edition of the <cite>The
 48  * Java Virtual Machine Specification</cite> for details.
 49  *
 50  * @since 20
 51  * @see System#getProperties System property {@code java.class.version}

382      *
383      * @since 26
384      *
385      * @see <a
386      * href="https://docs.oracle.com/en/java/javase/26/docs/specs/jvms/index.html">
387      * <cite>The Java Virtual Machine Specification, Java SE 26 Edition</cite></a>
388      */
389     RELEASE_26(70),
390 
391     /**
392      * The version introduced by the Java Platform, Standard Edition
393      * 27.
394      *
395      * @since 27
396      *
397      * @see <a
398      * href="https://docs.oracle.com/en/java/javase/27/docs/specs/jvms/index.html">
399      * <cite>The Java Virtual Machine Specification, Java SE 27 Edition</cite></a>
400      */
401     RELEASE_27(71),

402 
403     // Reduce code churn when appending new constants
404     // Note to maintainers: when adding constants for newer releases,
405     // the implementation of latest() must be updated too.
406 
407     /// The preview features of Valhalla.
408     /// @since Valhalla
409     @PreviewFeature(feature = PreviewFeature.Feature.LANGUAGE_MODEL, reflective = true)
410     CURRENT_PREVIEW_FEATURES(ClassFile.latestMajorVersion());
411 
412     private final int major;
413 
414     private ClassFileFormatVersion(int major) {
415         this.major = major;
416     }
417 
418     /**
419      * {@return the latest class file format version}
420      */
421     public static ClassFileFormatVersion latest() {
422         return RELEASE_27;
423     }
424 
425     /**
426      * {@return the major class file version as an integer}
427      * @jvms 4.1 The {@code ClassFile} Structure
428      */
429     public int major() {
430         return major;
431     }
< prev index next >