org.apache.bcel.generic
Interface InstructionConstants
public
interface
InstructionConstants
This interface contains shareable instruction objects.
In order to save memory you can use some instructions multiply,
since they have an immutable state and are directly derived from
Instruction. I.e. they have no instance fields that could be
changed. Since some of these instructions like ICONST_0 occur
very frequently this can save a lot of time and space. This
feature is an adaptation of the FlyWeight design pattern, we
just use an array instead of a factory.
The Instructions can also accessed directly under their names, so
it's possible to write il.append(Instruction.ICONST_0);
Interfaces may have no static initializers, so we simulate this
with an inner class.
Get object via its opcode, for immutable instructions like
branch instructions entries are set to null.
Predefined instruction objects
You can use these constants in multiple places safely, if you can guarantee
that you will never alter their internal values, e.g. call setIndex().