/** * @return String representation. */ @Override public final String toString() { return super.toString() + "(bytes = " + bytes + ")"; } }
/** * Read constants from given file stream. * * @param file Input stream * @throws IOException * @throws ClassFormatException */ ConstantPool(DataInputStream file) throws IOException, ClassFormatException { byte tag; constant_pool_count = file.readUnsignedShort(); constant_pool = new Constant[constant_pool_count]; /* constant_pool[0] is unused by the compiler and may be used freely * by the implementation. */ for (int i = 1; i < constant_pool_count; i++) { constant_pool[i] = Constant.readConstant(file); /* Quote from the JVM specification: * "All eight byte constants take up two spots in the constant pool. * If this is the n'th byte in the constant pool, then the next item * will be numbered n+2" * * Thus we have to increment the index counter. */ tag = constant_pool[i].getTag(); if ((tag == Constants.CONSTANT_Double) || (tag == Constants.CONSTANT_Long)) { i++; } } }
/** * 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; }
/** * Read constants from given file stream. * * @param file Input stream * @throws IOException * @throws ClassFormatException */ ConstantPool(DataInputStream file) throws IOException, ClassFormatException { byte tag; constant_pool_count = file.readUnsignedShort(); constant_pool = new Constant[constant_pool_count]; /* constant_pool[0] is unused by the compiler and may be used freely * by the implementation. */ for (int i = 1; i < constant_pool_count; i++) { constant_pool[i] = Constant.readConstant(file); /* Quote from the JVM specification: * "All eight byte constants take up two spots in the constant pool. * If this is the n'th byte in the constant pool, then the next item * will be numbered n+2" * * Thus we have to increment the index counter. */ tag = constant_pool[i].getTag(); if ((tag == Constants.CONSTANT_Double) || (tag == Constants.CONSTANT_Long)) { i++; } } }
/** * 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; }
/** * @return String representation. */ @Override public final String toString() { return super.toString() + "(bytes = " + bytes + ")"; }
/** * Read constants from given file stream. * * @param file Input stream * @throws IOException * @throws ClassFormatException */ ConstantPool(DataInputStream file) throws IOException, ClassFormatException { byte tag; constant_pool_count = file.readUnsignedShort(); constant_pool = new Constant[constant_pool_count]; /* constant_pool[0] is unused by the compiler and may be used freely * by the implementation. */ for (int i = 1; i < constant_pool_count; i++) { constant_pool[i] = Constant.readConstant(file); /* Quote from the JVM specification: * "All eight byte constants take up two spots in the constant pool. * If this is the n'th byte in the constant pool, then the next item * will be numbered n+2" * * Thus we have to increment the index counter. */ tag = constant_pool[i].getTag(); if ((tag == Constants.CONSTANT_Double) || (tag == Constants.CONSTANT_Long)) { i++; } } }
/** * 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; }
/** * @return String representation. */ @Override public final String toString() { return super.toString() + "(bytes = " + bytes + ")"; }
/** * Read constants from given file stream. * * @param file Input stream * @throws IOException * @throws ClassFormatException */ ConstantPool(DataInputStream file) throws IOException, ClassFormatException { byte tag; constant_pool_count = file.readUnsignedShort(); constant_pool = new Constant[constant_pool_count]; /* constant_pool[0] is unused by the compiler and may be used freely * by the implementation. */ for (int i = 1; i < constant_pool_count; i++) { constant_pool[i] = Constant.readConstant(file); /* Quote from the JVM specification: * "All eight byte constants take up two spots in the constant pool. * If this is the n'th byte in the constant pool, then the next item * will be numbered n+2" * * Thus we have to increment the index counter. */ tag = constant_pool[i].getTag(); if ((tag == Constants.CONSTANT_Double) || (tag == Constants.CONSTANT_Long)) { i++; } } }
/** * 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; }
/** * @return String representation */ @Override public final String toString() { return super.toString() + "(bootstrap_method_attr_index = " + bootstrap_method_attr_index + ", name_and_type_index = " + name_and_type_index + ")"; } }
/** * Read constants from given input stream. * * @param input Input stream * @throws IOException * @throws ClassFormatException */ ConstantPool(final DataInput input) throws IOException, ClassFormatException { final int constant_pool_count = input.readUnsignedShort(); constant_pool = new Constant[constant_pool_count]; /* constant_pool[0] is unused by the compiler and may be used freely * by the implementation. */ for (int i = 1; i < constant_pool_count; i++) { constant_pool[i] = Constant.readConstant(input); /* Quote from the JVM specification: * "All eight byte constants take up two spots in the constant pool. * If this is the n'th byte in the constant pool, then the next item * will be numbered n+2" * * Thus we have to increment the index counter. */ if (constant_pool[i] != null) { byte tag = constant_pool[i].getTag(); if ((tag == Const.CONSTANT_Double) || (tag == Const.CONSTANT_Long)) { i++; } } } }
int i; switch (c.getTag()) { case Constants.CONSTANT_Long: buf = String.valueOf(((ConstantLong) c).getBytes());
/** * @return String representation */ @Override public final String toString() { return super.toString() + "(descriptor_index = " + descriptor_index + ")"; } }
int i; switch (c.getTag()) { case Constants.CONSTANT_Long: buf = String.valueOf(((ConstantLong) c).getBytes());
/** * @return String representation. */ @Override public final String toString() { return super.toString() + "(class_index = " + class_index + ", name_and_type_index = " + name_and_type_index + ")"; } }
int i; switch (c.getTag()) { case Constants.CONSTANT_Long: buf = String.valueOf(((ConstantLong) c).getBytes());
/** * @return String representation. */ @Override public final String toString() { return super.toString() + "(name_index = " + name_index + ")"; } }
/** * 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 If the constant is not of the expected type */ public Constant getConstant( final int index, final 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 `" + Const.getConstantName(tag) + "' at index " + index + " and got " + c); } return c; } }