java.lang.classfile library.java.lang.classfile.instruction package contains interfaces describing code instructions.
Implementations of these interfaces are immutable.
APIs in this package perform null and unrepresentable argument checks, unless otherwise noted.
CodeModel, such as CodeModel::forEach, and categorized by pattern-matching.
When read from class files, instructions are lazily inflated; the contents of these instructions, besides the
bare structure, are not evaluated to speed up parsing. Instructions to users interest, such as those filtered by the
pattern matching, have their contents read on demand, to avoid unnecessary reading of unrelated instructions in a code
array.
Due to the lazy nature of class file parsing, IllegalArgumentException indicating malformed
class file data can be thrown at any method invocation. For example, an instruction object for a TypeCheckInstruction may be obtained from a CodeModel, but the subsequent invocation of . may fail with IllegalArgumentException because the instruction refers
to a bad constant pool index.
CodeBuilder. The most basic way to write instructions is to pass an
instruction object to CodeBuilder::with, which supports all valid instructions.
Yet, CodeBuilder provides a lot of convenience factory methods
for easy creation of instructions, named by their mnemonic. These accessors are more concise, and often more
efficient at run-time than passing instruction objects.
Due to restrictions in the class file format, some instructions may not be representable in a CodeBuilder.
In some scenarios, such as for BranchInstruction, Class-File API options control if alternatives can be used
in code generation instead. Otherwise, they can be configured to fail-fast to ensure the parity of CodeBuilder
commands with the generated code array data.
| Modifier and Type | Interface and Description |
|---|---|
| public interface | ArrayLoadInstruction
Models an array load instruction in the |
| public interface | ArrayStoreInstruction
Models an array store instruction in the |
| public interface | BranchInstruction
Models a branching instruction (conditional or unconditional) in the |
| public interface | CharacterRange
A pseudo-instruction which models a single entry in the |
| public interface | ConstantInstruction
Models a constant-load instruction in the |
| public interface | ConvertInstruction
Models a primitive conversion instruction in the |
| public interface | DiscontinuedInstruction
Marker interface for instruction discontinued from the |
| public interface | ExceptionCatch
A pseudo-instruction modeling an entry in the |
| public interface | FieldInstruction
Models a field access instruction in the |
| public interface | IncrementInstruction
Models a local variable increment instruction in the |
| public interface | InvokeDynamicInstruction
Models a dynamically-computed call site invocation instruction in the
|
| public interface | InvokeInstruction
Models a method invocation instruction in the |
| public interface | LabelTarget
A pseudo-instruction which indicates that the specified label corresponds to
the current position in the |
| public interface | LineNumber
A pseudo-instruction which indicates the code for a given line number starts
after the current position in a |
| public interface | LoadInstruction
Models a local variable load instruction in the |
| public interface | LocalVariable
A pseudo-instruction which models a single entry in the |
| public interface | LocalVariableType
A pseudo-instruction which models a single entry in the |
| public interface | LookupSwitchInstruction
Models a |
| public interface | MonitorInstruction
Models a |
| public interface | NewMultiArrayInstruction
Models a |
| public interface | NewObjectInstruction
Models a |
| public interface | NewPrimitiveArrayInstruction
Models a |
| public interface | NewReferenceArrayInstruction
Models a |
| public interface | NopInstruction
Models a |
| public interface | OperatorInstruction
Models an arithmetic operator instruction in the |
| public interface | ReturnInstruction
Models a return-from-method instruction in the |
| public interface | StackInstruction
Models a stack manipulation instruction in the |
| public interface | StoreInstruction
Models a local variable store instruction in the |
| public interface | SwitchCase
Models a single case in a |
| public interface | TableSwitchInstruction
Models a |
| public interface | ThrowInstruction
Models an |
| public interface | TypeCheckInstruction
Models an |