/** * Get constant from constant pool. * * @param index Index in constant pool * @return Constant value * @see Constant */ public Constant getConstant( int index ) { if (index >= constant_pool.length || index < 0) { throw new ClassFormatException("Invalid constant pool reference: " + index + ". Constant pool size is: " + constant_pool.length); } return constant_pool[index]; }
/** * Get constant from constant pool. * * @param index Index in constant pool * @return Constant value * @see Constant */ public Constant getConstant( int index ) { if (index >= constant_pool.length || index < 0) { throw new ClassFormatException("Invalid constant pool reference: " + index + ". Constant pool size is: " + constant_pool.length); } return constant_pool[index]; }
/** * Get constant from constant pool. * * @param index Index in constant pool * @return Constant value * @see Constant */ public Constant getConstant( int index ) { if (index >= constant_pool.length || index < 0) { throw new ClassFormatException("Invalid constant pool reference: " + index + ". Constant pool size is: " + constant_pool.length); } return constant_pool[index]; }
/** * Get constant from constant pool. * * @param index Index in constant pool * @return Constant value * @see Constant */ public Constant getConstant( final int index ) { if (index >= constant_pool.length || index < 0) { throw new ClassFormatException("Invalid constant pool reference: " + index + ". Constant pool size is: " + constant_pool.length); } return constant_pool[index]; }
/** * Get constant from constant pool. * * @param index Index in constant pool * @return Constant value * @see Constant */ public Constant getConstant( int index ) { if (index >= constant_pool.length || index < 0) { throw new ClassFormatException("Invalid constant pool reference: " + index + ". Constant pool size is: " + constant_pool.length); } return constant_pool[index]; }
static void swallowSynthetic(DataInput file, int length) throws IOException { if (length > 0) { byte[] bytes = new byte[length]; file.readFully(bytes); throw new ClassFormatException("Synthetic attribute with length > 0"); } } }
/** * Check whether the header of the file is ok. * Of course, this has to be the first action on successive file reads. * @throws IOException * @throws ClassFormatException */ private final void readID() throws IOException, ClassFormatException { if (file.readInt() != MAGIC) { throw new ClassFormatException(file_name + " is not a Java .class file"); } }
/** * Check whether the header of the file is ok. * Of course, this has to be the first action on successive file reads. * @throws IOException * @throws ClassFormatException */ private final void readID() throws IOException, ClassFormatException { int magic = 0xCAFEBABE; if (file.readInt() != magic) { throw new ClassFormatException(file_name + " is not a Java .class file"); } }
/** * Check whether the header of the file is ok. * Of course, this has to be the first action on successive file reads. * @throws IOException * @throws ClassFormatException */ private final void readID() throws IOException, ClassFormatException { int magic = 0xCAFEBABE; if (file.readInt() != magic) { throw new ClassFormatException(file_name + " is not a Java .class file"); } }
/** * Check whether the header of the file is ok. * Of course, this has to be the first action on successive file reads. * @throws IOException * @throws ClassFormatException */ private void readID() throws IOException, ClassFormatException { if (dataInputStream.readInt() != MAGIC) { throw new ClassFormatException("It is not a Java .class file"); } }
/** * Check whether the header of the file is ok. * Of course, this has to be the first action on successive file reads. * @throws IOException * @throws ClassFormatException */ private final void readID() throws IOException, ClassFormatException { int magic = 0xCAFEBABE; if (file.readInt() != magic) { throw new ClassFormatException(file_name + " is not a Java .class file"); } }
static void swallowStackMapType(DataInput file) throws IOException { byte type = file.readByte(); if ((type < Constants.ITEM_Bogus) || (type > Constants.ITEM_NewObject)) { throw new ClassFormatException("Illegal type for StackMapType: " + type); } // Check to see if type has an index if ((type == Constants.ITEM_Object) || (type == Constants.ITEM_NewObject)) { file.readShort(); // Unused index } }
/** * Read information about the class and its super class. * @throws IOException * @throws ClassFormatException */ private final void readClassInfo() throws IOException, ClassFormatException { access_flags = file.readUnsignedShort(); /* Interfaces are implicitely abstract, the flag should be set * according to the JVM specification. */ if ((access_flags & Constants.ACC_INTERFACE) != 0) { access_flags |= Constants.ACC_ABSTRACT; } if (((access_flags & Constants.ACC_ABSTRACT) != 0) && ((access_flags & Constants.ACC_FINAL) != 0)) { throw new ClassFormatException("Class " + file_name + " can't be both final and abstract"); } class_name_index = file.readUnsignedShort(); superclass_name_index = file.readUnsignedShort(); }
/** * Read information about the class and its super class. * @throws IOException * @throws ClassFormatException */ private final void readClassInfo() throws IOException, ClassFormatException { access_flags = file.readUnsignedShort(); /* Interfaces are implicitely abstract, the flag should be set * according to the JVM specification. */ if ((access_flags & Constants.ACC_INTERFACE) != 0) { access_flags |= Constants.ACC_ABSTRACT; } if (((access_flags & Constants.ACC_ABSTRACT) != 0) && ((access_flags & Constants.ACC_FINAL) != 0)) { throw new ClassFormatException("Class " + file_name + " can't be both final and abstract"); } class_name_index = file.readUnsignedShort(); superclass_name_index = file.readUnsignedShort(); }
/** * Read information about the class and its super class. * @throws IOException * @throws ClassFormatException */ private final void readClassInfo() throws IOException, ClassFormatException { access_flags = file.readUnsignedShort(); /* Interfaces are implicitely abstract, the flag should be set * according to the JVM specification. */ if ((access_flags & Constants.ACC_INTERFACE) != 0) { access_flags |= Constants.ACC_ABSTRACT; } if (((access_flags & Constants.ACC_ABSTRACT) != 0) && ((access_flags & Constants.ACC_FINAL) != 0)) { throw new ClassFormatException("Class " + file_name + " can't be both final and abstract"); } class_name_index = file.readUnsignedShort(); superclass_name_index = file.readUnsignedShort(); }
/** * Read information about the class and its super class. * @throws IOException * @throws ClassFormatException */ private final void readClassInfo() throws IOException, ClassFormatException { access_flags = file.readUnsignedShort(); /* Interfaces are implicitely abstract, the flag should be set * according to the JVM specification. */ if ((access_flags & Constants.ACC_INTERFACE) != 0) { access_flags |= Constants.ACC_ABSTRACT; } if (((access_flags & Constants.ACC_ABSTRACT) != 0) && ((access_flags & Constants.ACC_FINAL) != 0)) { throw new ClassFormatException("Class " + file_name + " can't be both final and abstract"); } class_name_index = file.readUnsignedShort(); superclass_name_index = file.readUnsignedShort(); }
/** * Get constant from constant pool and check whether it has the * expected type. * * @param index Index in constant pool * @param tag Tag of expected constant, i.e., its type * @return Constant value * @see Constant * @throws ClassFormatException */ public Constant getConstant( int index, byte tag ) throws ClassFormatException { Constant c; c = getConstant(index); if (c == null) { throw new ClassFormatException("Constant pool at index " + index + " is null."); } if (c.getTag() != tag) { throw new ClassFormatException("Expected class `" + Constants.CONSTANT_NAMES[tag] + "' at index " + index + " and got " + c); } return c; }
/** * Get constant from constant pool and check whether it has the * expected type. * * @param index Index in constant pool * @param tag Tag of expected constant, i.e., its type * @return Constant value * @see Constant * @throws ClassFormatException */ public Constant getConstant( int index, byte tag ) throws ClassFormatException { Constant c; c = getConstant(index); if (c == null) { throw new ClassFormatException("Constant pool at index " + index + " is null."); } if (c.getTag() != tag) { throw new ClassFormatException("Expected class `" + Constants.CONSTANT_NAMES[tag] + "' at index " + index + " and got " + c); } return c; }
/** * Get constant from constant pool and check whether it has the * expected type. * * @param index Index in constant pool * @param tag Tag of expected constant, i.e., its type * @return Constant value * @see Constant * @throws ClassFormatException */ public Constant getConstant( int index, byte tag ) throws ClassFormatException { Constant c; c = getConstant(index); if (c == null) { throw new ClassFormatException("Constant pool at index " + index + " is null."); } if (c.getTag() != tag) { throw new ClassFormatException("Expected class `" + Constants.CONSTANT_NAMES[tag] + "' at index " + index + " and got " + c); } return c; }
/** * Get constant from constant pool and check whether it has the * expected type. * * @param index Index in constant pool * @param tag Tag of expected constant, i.e., its type * @return Constant value * @see Constant * @throws ClassFormatException */ public Constant getConstant( int index, byte tag ) throws ClassFormatException { Constant c; c = getConstant(index); if (c == null) { throw new ClassFormatException("Constant pool at index " + index + " is null."); } if (c.getTag() != tag) { throw new ClassFormatException("Expected class `" + Constants.CONSTANT_NAMES[tag] + "' at index " + index + " and got " + c); } return c; }