< prev index next >

src/java.base/share/classes/jdk/internal/jimage/ImageHeader.java

Print this page

  1 /*
  2  * Copyright (c) 2014, 2016, 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
 23  * questions.
 24  */
 25 
 26 package jdk.internal.jimage;
 27 
 28 import java.nio.ByteBuffer;
 29 import java.nio.IntBuffer;
 30 import java.util.Objects;
 31 
 32 /**

















 33  * @implNote This class needs to maintain JDK 8 source compatibility.
 34  *
 35  * It is used internally in the JDK to implement jimage/jrtfs access,
 36  * but also compiled and delivered as part of the jrtfs.jar to support access
 37  * to the jimage file provided by the shipped JDK by tools running on JDK 8.
 38  */
 39 public final class ImageHeader {
 40     public static final int MAGIC = 0xCAFEDADA;
 41     public static final int MAJOR_VERSION = 1;
 42     public static final int MINOR_VERSION = 0;
 43     private static final int HEADER_SLOTS = 7;
 44 
 45     private final int magic;
 46     private final int majorVersion;
 47     private final int minorVersion;
 48     private final int flags;
 49     private final int resourceCount;
 50     private final int tableLength;
 51     private final int locationsSize;
 52     private final int stringsSize;
 53 
 54     public ImageHeader(int resourceCount, int tableCount,
 55             int locationsSize, int stringsSize) {
 56         this(MAGIC, MAJOR_VERSION, MINOR_VERSION, 0, resourceCount,
 57                 tableCount, locationsSize, stringsSize);
 58     }
 59 
 60     public ImageHeader(int magic, int majorVersion, int minorVersion,
 61                 int flags, int resourceCount,
 62                 int tableLength, int locationsSize, int stringsSize)

  1 /*
  2  * Copyright (c) 2014, 2025, 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
 23  * questions.
 24  */
 25 
 26 package jdk.internal.jimage;
 27 
 28 import java.nio.ByteBuffer;
 29 import java.nio.IntBuffer;
 30 import java.util.Objects;
 31 
 32 /**
 33  * Defines the header and version information for jimage files.
 34  *
 35  * <p>Version number changes must be synced in a single change across all code
 36  * which reads/writes jimage files, and code which tries to open a jimage file
 37  * with an unexpected version should fail.
 38  *
 39  * <p>Known jimage file code which needs updating on version change:
 40  * <ul>
 41  *     <li>src/java.base/share/native/libjimage/imageFile.hpp
 42  * </ul>
 43  *
 44  * <p>Version history:
 45  * <ul>
 46  *     <li>{@code 1.0}: Original version.
 47  *     <li>{@code 1.1}: Support preview mode with new flags.
 48  * </ul>
 49  *
 50  * @implNote This class needs to maintain JDK 8 source compatibility.
 51  *
 52  * It is used internally in the JDK to implement jimage/jrtfs access,
 53  * but also compiled and delivered as part of the jrtfs.jar to support access
 54  * to the jimage file provided by the shipped JDK by tools running on JDK 8.
 55  */
 56 public final class ImageHeader {
 57     public static final int MAGIC = 0xCAFEDADA;
 58     public static final int MAJOR_VERSION = 1;
 59     public static final int MINOR_VERSION = 1;
 60     private static final int HEADER_SLOTS = 7;
 61 
 62     private final int magic;
 63     private final int majorVersion;
 64     private final int minorVersion;
 65     private final int flags;
 66     private final int resourceCount;
 67     private final int tableLength;
 68     private final int locationsSize;
 69     private final int stringsSize;
 70 
 71     public ImageHeader(int resourceCount, int tableCount,
 72             int locationsSize, int stringsSize) {
 73         this(MAGIC, MAJOR_VERSION, MINOR_VERSION, 0, resourceCount,
 74                 tableCount, locationsSize, stringsSize);
 75     }
 76 
 77     public ImageHeader(int magic, int majorVersion, int minorVersion,
 78                 int flags, int resourceCount,
 79                 int tableLength, int locationsSize, int stringsSize)
< prev index next >