8329099: Undocumented exception thrown by Instruction factory methods accepting Opcode
Reviewed-by: briangoetz
This commit is contained in:
parent
def257727d
commit
97c180892b
@ -54,6 +54,8 @@ public sealed interface ArrayLoadInstruction extends Instruction
|
||||
*
|
||||
* @param op the opcode for the specific type of array load instruction,
|
||||
* which must be of kind {@link Opcode.Kind#ARRAY_LOAD}
|
||||
* @throws IllegalArgumentException if the opcode kind is not
|
||||
* {@link Opcode.Kind#ARRAY_LOAD}.
|
||||
*/
|
||||
static ArrayLoadInstruction of(Opcode op) {
|
||||
Util.checkKind(op, Opcode.Kind.ARRAY_LOAD);
|
||||
|
@ -54,6 +54,8 @@ public sealed interface ArrayStoreInstruction extends Instruction
|
||||
*
|
||||
* @param op the opcode for the specific type of array store instruction,
|
||||
* which must be of kind {@link Opcode.Kind#ARRAY_STORE}
|
||||
* @throws IllegalArgumentException if the opcode kind is not
|
||||
* {@link Opcode.Kind#ARRAY_STORE}.
|
||||
*/
|
||||
static ArrayStoreInstruction of(Opcode op) {
|
||||
Util.checkKind(op, Opcode.Kind.ARRAY_STORE);
|
||||
|
@ -56,6 +56,8 @@ public sealed interface BranchInstruction extends Instruction
|
||||
* @param op the opcode for the specific type of branch instruction,
|
||||
* which must be of kind {@link Opcode.Kind#BRANCH}
|
||||
* @param target the target of the branch
|
||||
* @throws IllegalArgumentException if the opcode kind is not
|
||||
* {@link Opcode.Kind#BRANCH}.
|
||||
*/
|
||||
static BranchInstruction of(Opcode op, Label target) {
|
||||
Util.checkKind(op, Opcode.Kind.BRANCH);
|
||||
|
@ -131,6 +131,8 @@ public sealed interface ConstantInstruction extends Instruction {
|
||||
*
|
||||
* @param op the opcode for the specific type of intrinsic constant instruction,
|
||||
* which must be of kind {@link Opcode.Kind#CONSTANT}
|
||||
* @throws IllegalArgumentException if the opcode does not represent a constant
|
||||
* with implicit value
|
||||
*/
|
||||
static IntrinsicConstantInstruction ofIntrinsic(Opcode op) {
|
||||
Util.checkKind(op, Opcode.Kind.CONSTANT);
|
||||
@ -145,6 +147,8 @@ public sealed interface ConstantInstruction extends Instruction {
|
||||
* @param op the opcode for the specific type of intrinsic constant instruction,
|
||||
* which must be of kind {@link Opcode.Kind#CONSTANT}
|
||||
* @param value the constant value
|
||||
* @throws IllegalArgumentException if the opcode is not {@link Opcode#BIPUSH}
|
||||
* or {@link Opcode#SIPUSH}
|
||||
*/
|
||||
static ArgumentConstantInstruction ofArgument(Opcode op, int value) {
|
||||
Util.checkKind(op, Opcode.Kind.CONSTANT);
|
||||
@ -159,6 +163,8 @@ public sealed interface ConstantInstruction extends Instruction {
|
||||
* @param op the opcode for the specific type of load constant instruction,
|
||||
* which must be of kind {@link Opcode.Kind#CONSTANT}
|
||||
* @param constant the constant value
|
||||
* @throws IllegalArgumentException if the opcode is not {@link Opcode#LDC},
|
||||
* {@link Opcode#LDC_W}, or {@link Opcode#LDC2_W}
|
||||
*/
|
||||
static LoadConstantInstruction ofLoad(Opcode op, LoadableConstantEntry constant) {
|
||||
Util.checkKind(op, Opcode.Kind.CONSTANT);
|
||||
|
@ -70,6 +70,8 @@ public sealed interface ConvertInstruction extends Instruction
|
||||
*
|
||||
* @param op the opcode for the specific type of conversion instruction,
|
||||
* which must be of kind {@link Opcode.Kind#CONVERT}
|
||||
* @throws IllegalArgumentException if the opcode kind is not
|
||||
* {@link Opcode.Kind#CONVERT}.
|
||||
*/
|
||||
static ConvertInstruction of(Opcode op) {
|
||||
Util.checkKind(op, Opcode.Kind.CONVERT);
|
||||
|
@ -68,6 +68,8 @@ public sealed interface DiscontinuedInstruction extends Instruction {
|
||||
* @param op the opcode for the specific type of JSR instruction,
|
||||
* which must be of kind {@link Opcode.Kind#DISCONTINUED_JSR}
|
||||
* @param target target label of the subroutine
|
||||
* @throws IllegalArgumentException if the opcode kind is not
|
||||
* {@link Opcode.Kind#DISCONTINUED_JSR}.
|
||||
*/
|
||||
static JsrInstruction of(Opcode op, Label target) {
|
||||
Util.checkKind(op, Opcode.Kind.DISCONTINUED_JSR);
|
||||
@ -109,6 +111,8 @@ public sealed interface DiscontinuedInstruction extends Instruction {
|
||||
* @param op the opcode for the specific type of RET instruction,
|
||||
* which must be of kind {@link Opcode.Kind#DISCONTINUED_RET}
|
||||
* @param slot the local variable slot to load return address from
|
||||
* @throws IllegalArgumentException if the opcode kind is not
|
||||
* {@link Opcode.Kind#DISCONTINUED_RET}.
|
||||
*/
|
||||
static RetInstruction of(Opcode op, int slot) {
|
||||
Util.checkKind(op, Opcode.Kind.DISCONTINUED_RET);
|
||||
|
@ -89,6 +89,8 @@ public sealed interface FieldInstruction extends Instruction
|
||||
* @param op the opcode for the specific type of field access instruction,
|
||||
* which must be of kind {@link Opcode.Kind#FIELD_ACCESS}
|
||||
* @param field a constant pool entry describing the field
|
||||
* @throws IllegalArgumentException if the opcode kind is not
|
||||
* {@link Opcode.Kind#FIELD_ACCESS}.
|
||||
*/
|
||||
static FieldInstruction of(Opcode op, FieldRefEntry field) {
|
||||
Util.checkKind(op, Opcode.Kind.FIELD_ACCESS);
|
||||
|
@ -104,6 +104,8 @@ public sealed interface InvokeInstruction extends Instruction
|
||||
* @param op the opcode for the specific type of invocation instruction,
|
||||
* which must be of kind {@link Opcode.Kind#INVOKE}
|
||||
* @param method a constant pool entry describing the method
|
||||
* @throws IllegalArgumentException if the opcode kind is not
|
||||
* {@link Opcode.Kind#INVOKE}.
|
||||
*/
|
||||
static InvokeInstruction of(Opcode op, MemberRefEntry method) {
|
||||
Util.checkKind(op, Opcode.Kind.INVOKE);
|
||||
|
@ -73,6 +73,8 @@ public sealed interface LoadInstruction extends Instruction
|
||||
* @param op the opcode for the specific type of load instruction,
|
||||
* which must be of kind {@link Opcode.Kind#LOAD}
|
||||
* @param slot the local variable slot to load from
|
||||
* @throws IllegalArgumentException if the opcode kind is not
|
||||
* {@link Opcode.Kind#LOAD}.
|
||||
*/
|
||||
static LoadInstruction of(Opcode op, int slot) {
|
||||
Util.checkKind(op, Opcode.Kind.LOAD);
|
||||
|
@ -48,6 +48,8 @@ public sealed interface MonitorInstruction extends Instruction
|
||||
*
|
||||
* @param op the opcode for the specific type of monitor instruction,
|
||||
* which must be of kind {@link Opcode.Kind#MONITOR}
|
||||
* @throws IllegalArgumentException if the opcode kind is not
|
||||
* {@link Opcode.Kind#MONITOR}.
|
||||
*/
|
||||
static MonitorInstruction of(Opcode op) {
|
||||
Util.checkKind(op, Opcode.Kind.MONITOR);
|
||||
|
@ -51,8 +51,14 @@ public sealed interface NewPrimitiveArrayInstruction extends Instruction
|
||||
* {@return a new primitive array instruction}
|
||||
*
|
||||
* @param typeKind the component type of the array
|
||||
* @throws IllegalArgumentException when the {@code typeKind} is not a legal
|
||||
* primitive array component type
|
||||
*/
|
||||
static NewPrimitiveArrayInstruction of(TypeKind typeKind) {
|
||||
// Implicit null-check:
|
||||
if (typeKind.newarraycode() < 0) {
|
||||
throw new IllegalArgumentException("Illegal component type: " + typeKind.typeName());
|
||||
}
|
||||
return new AbstractInstruction.UnboundNewPrimitiveArrayInstruction(typeKind);
|
||||
}
|
||||
}
|
||||
|
@ -54,6 +54,8 @@ public sealed interface OperatorInstruction extends Instruction
|
||||
*
|
||||
* @param op the opcode for the specific type of array load instruction,
|
||||
* which must be of kind {@link Opcode.Kind#OPERATOR}
|
||||
* @throws IllegalArgumentException if the opcode kind is not
|
||||
* {@link Opcode.Kind#OPERATOR}.
|
||||
*/
|
||||
static OperatorInstruction of(Opcode op) {
|
||||
Util.checkKind(op, Opcode.Kind.OPERATOR);
|
||||
|
@ -65,6 +65,8 @@ public sealed interface ReturnInstruction extends Instruction
|
||||
*
|
||||
* @param op the opcode for the specific type of return instruction,
|
||||
* which must be of kind {@link Opcode.Kind#RETURN}
|
||||
* @throws IllegalArgumentException if the opcode kind is not
|
||||
* {@link Opcode.Kind#RETURN}.
|
||||
*/
|
||||
static ReturnInstruction of(Opcode op) {
|
||||
Util.checkKind(op, Opcode.Kind.RETURN);
|
||||
|
@ -49,6 +49,8 @@ public sealed interface StackInstruction extends Instruction
|
||||
*
|
||||
* @param op the opcode for the specific type of stack instruction,
|
||||
* which must be of kind {@link Opcode.Kind#STACK}
|
||||
* @throws IllegalArgumentException if the opcode kind is not
|
||||
* {@link Opcode.Kind#STACK}.
|
||||
*/
|
||||
static StackInstruction of(Opcode op) {
|
||||
Util.checkKind(op, Opcode.Kind.STACK);
|
||||
|
@ -72,6 +72,8 @@ public sealed interface StoreInstruction extends Instruction
|
||||
* @param op the opcode for the specific type of store instruction,
|
||||
* which must be of kind {@link Opcode.Kind#STORE}
|
||||
* @param slot the local variable slot to store to
|
||||
* @throws IllegalArgumentException if the opcode kind is not
|
||||
* {@link Opcode.Kind#STORE}.
|
||||
*/
|
||||
static StoreInstruction of(Opcode op, int slot) {
|
||||
Util.checkKind(op, Opcode.Kind.STORE);
|
||||
|
@ -59,6 +59,8 @@ public sealed interface TypeCheckInstruction extends Instruction
|
||||
* @param op the opcode for the specific type of type check instruction,
|
||||
* which must be of kind {@link Opcode.Kind#TYPE_CHECK}
|
||||
* @param type the type against which to check or cast
|
||||
* @throws IllegalArgumentException if the opcode kind is not
|
||||
* {@link Opcode.Kind#TYPE_CHECK}.
|
||||
*/
|
||||
static TypeCheckInstruction of(Opcode op, ClassEntry type) {
|
||||
Util.checkKind(op, Opcode.Kind.TYPE_CHECK);
|
||||
|
@ -238,6 +238,12 @@
|
||||
* the convenience method {@code CodeBuilder.invokeInstruction}, which in turn behaves
|
||||
* as if it calls method {@code CodeBuilder.with}. This composing of method calls on the
|
||||
* builder enables the composing of transforms (as described later).
|
||||
* <p>
|
||||
* Unless otherwise noted, passing a {@code null} argument to a constructor
|
||||
* or method of any Class-File API class or interface will cause a {@link
|
||||
* java.lang.NullPointerException NullPointerException} to be thrown. Additionally,
|
||||
* invoking a method with an array or collection containing a {@code null} element
|
||||
* will cause a {@code NullPointerException}, unless otherwise specified. </p>
|
||||
*
|
||||
* <h3>Symbolic information</h3>
|
||||
* To describe symbolic information for classes and types, the API uses the
|
||||
|
Loading…
x
Reference in New Issue
Block a user