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.
BytecodeAttribute.Fn, BytecodeAttribute.Reader, BytecodeAttribute.Unknown| Modifier and Type | Method and Description |
|---|---|
void |
apply(List<Code.Rewrite> rewrites)
This method accepts a list of rewrites which should be applied.
|
void |
write(int[] bytecodeOffsets,
BinaryOutputStream writer,
Map<Constant.Info,Integer> constantPool)
This method requires the attribute to write itself to the binary
stream.
|
addPoolItems, name, print, writevoid apply(List<Code.Rewrite> rewrites)
rewrites - void write(int[] bytecodeOffsets,
BinaryOutputStream writer,
Map<Constant.Info,Integer> constantPool)
throws IOException
bytecodeOffsets - --- maps each bytecode index to its actual offset in the
code block.writer - --- stream to write attribute toconstantPool - --- map of constant pool items to their actual pool indexIOExceptionCopyright © 2016. All rights reserved.