LocalVariableTypeTable(final int nameIdx, final int len, final DataInput input, final ConstantPool cpool) throws IOException { this(nameIdx, len, (LocalVariable[]) null, cpool); final int local_variable_type_table_length = input.readUnsignedShort(); local_variable_type_table = new LocalVariable[local_variable_type_table_length]; for (int i = 0; i < local_variable_type_table_length; i++) { local_variable_type_table[i] = new LocalVariable(input, cpool); } }
/** * Construct object from input stream. * @param name_index Index in constant pool * @param length Content length in bytes * @param input Input stream * @param constant_pool Array of constants * @throws IOException */ LocalVariableTable(final int name_index, final int length, final DataInput input, final ConstantPool constant_pool) throws IOException { this(name_index, length, (LocalVariable[]) null, constant_pool); final int local_variable_table_length = input.readUnsignedShort(); local_variable_table = new LocalVariable[local_variable_table_length]; for (int i = 0; i < local_variable_table_length; i++) { local_variable_table[i] = new LocalVariable(input, constant_pool); } }
/** * Construct object from file stream. * @param name_index Index in constant pool * @param length Content length in bytes * @param file Input stream * @param constant_pool Array of constants * @throws IOException */ LocalVariableTable(int name_index, int length, DataInputStream file, ConstantPool constant_pool) throws IOException { this(name_index, length, (LocalVariable[])null, constant_pool); local_variable_table_length = (file.readUnsignedShort()); local_variable_table = new LocalVariable[local_variable_table_length]; for(int i=0; i < local_variable_table_length; i++) local_variable_table[i] = new LocalVariable(file, constant_pool); }
/** * Get LocalVariable object. * * This relies on that the instruction list has already been dumped to byte code or * or that the `setPositions' methods has been called for the instruction list. * * Note that for local variables whose scope end at the last * instruction of the method's code, the JVM specification is ambiguous: * both a start_pc+length ending at the last instruction and * start_pc+length ending at first index beyond the end of the code are * valid. * * @param il instruction list (byte code) which this variable belongs to * @param cp constant pool */ public LocalVariable getLocalVariable(ConstantPoolGen cp) { int start_pc = start.getPosition(); int length = end.getPosition() - start_pc; if(length > 0) length += end.getInstruction().getLength(); int name_index = cp.addUtf8(name); int signature_index = cp.addUtf8(type.getSignature()); return new LocalVariable(start_pc, length, name_index, signature_index, index, cp.getConstantPool()); }
/** * Get LocalVariable object. * * This relies on that the instruction list has already been dumped to byte code or * or that the `setPositions' methods has been called for the instruction list. * * Note that due to the conversion from byte code offset to InstructionHandle, * it is impossible to tell the difference between a live range that ends BEFORE * the last insturction of the method or a live range that ends AFTER the last * instruction of the method. Hence the live_to_end flag to differentiate * between these two cases. * * @param cp constant pool */ public LocalVariable getLocalVariable( final ConstantPoolGen cp ) { int start_pc = 0; int length = 0; if ((start != null) && (end != null)) { start_pc = start.getPosition(); length = end.getPosition() - start_pc; if ((end.getNext() == null) && live_to_end) { length += end.getInstruction().getLength(); } } final int name_index = cp.addUtf8(name); final int signature_index = cp.addUtf8(type.getSignature()); return new LocalVariable(start_pc, length, name_index, signature_index, index, cp .getConstantPool(), orig_index); }