jasm.attributes
Interface Code.BytecodeMapAttribute

All Superinterfaces:
BytecodeAttribute
All Known Implementing Classes:
LineNumberTable
Enclosing class:
Code

public static interface Code.BytecodeMapAttribute
extends BytecodeAttribute

Maps bytecodes to some kind of attribute. For example, the Exceptions attribute maps bytecodes to exception handler regions; likewise, the LineNumbersTable attribute maps bytecodes to source code line numbers.

During bytecode optimisation, the relative position of bytecodes may change as a result of eliminating redundant bytecodes. In such a case we need to update those attributes which are affected. This interface captures those attributes which are affected, and provides a hook to tell them about rewrites as they happen.

Finally, the actual bytecode offsets in the code block (as opposed to their index in the block) are not known until the class file is actually written. Attributes which write bytecode offsets must convert between indices and actual code offsets.

Author:
David J. Pearce

Nested Class Summary
 
Nested classes/interfaces inherited from interface jasm.lang.BytecodeAttribute
BytecodeAttribute.Fn, BytecodeAttribute.Reader, BytecodeAttribute.Unknown
 
Method Summary
 void apply(java.util.List<Code.Rewrite> rewrites)
          This method accepts a list of rewrites which should be applied.
 void write(int[] bytecodeOffsets, BinaryOutputStream writer, java.util.Map<Constant.Info,java.lang.Integer> constantPool)
          This method requires the attribute to write itself to the binary stream.
 
Methods inherited from interface jasm.lang.BytecodeAttribute
addPoolItems, name, print, write
 

Method Detail

apply

void apply(java.util.List<Code.Rewrite> rewrites)
This method accepts a list of rewrites which should be applied. For efficiency reasons, several constraints are made on the list:
  1. The rewrites are ordered by their start location, such that the first rewrite has the lowest start location
  2. The rewrites don't overlap. That is, we assume only one rewrite can be applied to any given region of bytecodes.
If the complete set of rewrites cannot be constructed according to these constraints, then it needs to be split up into several calls to this method.

Parameters:
rewrites -

write

void write(int[] bytecodeOffsets,
           BinaryOutputStream writer,
           java.util.Map<Constant.Info,java.lang.Integer> constantPool)
           throws java.io.IOException
This method requires the attribute to write itself to the binary stream.

Parameters:
bytecodeOffsets - --- maps each bytecode index to its actual offset in the code block.
writer - --- stream to write attribute to
constantPool - --- map of constant pool items to their actual pool index
load - --- class loader instance
Throws:
java.io.IOException


Copyright © 2013 David J. Pearce. All Rights Reserved.