< prev index next >

src/java.base/share/classes/jdk/internal/org/objectweb/asm/ClassReader.java

Print this page




 193     public ClassReader(
 194             final byte[] classFileBuffer,
 195             final int classFileOffset,
 196             final int classFileLength) { // NOPMD(UnusedFormalParameter) used for backward compatibility.
 197         this(classFileBuffer, classFileOffset, /* checkClassVersion = */ true);
 198     }
 199 
 200     /**
 201       * Constructs a new {@link ClassReader} object. <i>This internal constructor must not be exposed
 202       * as a public API</i>.
 203       *
 204       * @param classFileBuffer a byte array containing the JVMS ClassFile structure to be read.
 205       * @param classFileOffset the offset in byteBuffer of the first byte of the ClassFile to be read.
 206       * @param checkClassVersion whether to check the class version or not.
 207       */
 208     ClassReader(
 209             final byte[] classFileBuffer, final int classFileOffset, final boolean checkClassVersion) {
 210         b = classFileBuffer;
 211         // Check the class' major_version. This field is after the magic and minor_version fields, which
 212         // use 4 and 2 bytes respectively.
 213         if (checkClassVersion && readShort(classFileOffset + 6) > Opcodes.V12) {
 214             throw new IllegalArgumentException(
 215                     "Unsupported class file major version " + readShort(classFileOffset + 6));
 216         }
 217         // Create the constant pool arrays. The constant_pool_count field is after the magic,
 218         // minor_version and major_version fields, which use 4, 2 and 2 bytes respectively.
 219         int constantPoolCount = readUnsignedShort(classFileOffset + 8);
 220         cpInfoOffsets = new int[constantPoolCount];
 221         constantUtf8Values = new String[constantPoolCount];
 222         // Compute the offset of each constant pool entry, as well as a conservative estimate of the
 223         // maximum length of the constant pool strings. The first constant pool entry is after the
 224         // magic, minor_version, major_version and constant_pool_count fields, which use 4, 2, 2 and 2
 225         // bytes respectively.
 226         int currentCpInfoIndex = 1;
 227         int currentCpInfoOffset = classFileOffset + 10;
 228         int currentMaxStringLength = 0;
 229         boolean hasConstantDynamic = false;
 230         boolean hasConstantInvokeDynamic = false;
 231         // The offset of the other entries depend on the total size of all the previous entries.
 232         while (currentCpInfoIndex < constantPoolCount) {
 233             cpInfoOffsets[currentCpInfoIndex++] = currentCpInfoOffset + 1;




 193     public ClassReader(
 194             final byte[] classFileBuffer,
 195             final int classFileOffset,
 196             final int classFileLength) { // NOPMD(UnusedFormalParameter) used for backward compatibility.
 197         this(classFileBuffer, classFileOffset, /* checkClassVersion = */ true);
 198     }
 199 
 200     /**
 201       * Constructs a new {@link ClassReader} object. <i>This internal constructor must not be exposed
 202       * as a public API</i>.
 203       *
 204       * @param classFileBuffer a byte array containing the JVMS ClassFile structure to be read.
 205       * @param classFileOffset the offset in byteBuffer of the first byte of the ClassFile to be read.
 206       * @param checkClassVersion whether to check the class version or not.
 207       */
 208     ClassReader(
 209             final byte[] classFileBuffer, final int classFileOffset, final boolean checkClassVersion) {
 210         b = classFileBuffer;
 211         // Check the class' major_version. This field is after the magic and minor_version fields, which
 212         // use 4 and 2 bytes respectively.
 213         if (checkClassVersion && readShort(classFileOffset + 6) > Opcodes.V13) {
 214             throw new IllegalArgumentException(
 215                     "Unsupported class file major version " + readShort(classFileOffset + 6));
 216         }
 217         // Create the constant pool arrays. The constant_pool_count field is after the magic,
 218         // minor_version and major_version fields, which use 4, 2 and 2 bytes respectively.
 219         int constantPoolCount = readUnsignedShort(classFileOffset + 8);
 220         cpInfoOffsets = new int[constantPoolCount];
 221         constantUtf8Values = new String[constantPoolCount];
 222         // Compute the offset of each constant pool entry, as well as a conservative estimate of the
 223         // maximum length of the constant pool strings. The first constant pool entry is after the
 224         // magic, minor_version, major_version and constant_pool_count fields, which use 4, 2, 2 and 2
 225         // bytes respectively.
 226         int currentCpInfoIndex = 1;
 227         int currentCpInfoOffset = classFileOffset + 10;
 228         int currentMaxStringLength = 0;
 229         boolean hasConstantDynamic = false;
 230         boolean hasConstantInvokeDynamic = false;
 231         // The offset of the other entries depend on the total size of all the previous entries.
 232         while (currentCpInfoIndex < constantPoolCount) {
 233             cpInfoOffsets[currentCpInfoIndex++] = currentCpInfoOffset + 1;


< prev index next >