8315541: Classfile API TypeAnnotation.TargetInfo factory methods accept null labels

Reviewed-by: briangoetz
This commit is contained in:
Adam Sotona 2023-09-14 18:27:12 +00:00
parent c11f8352e9
commit c7d306c65c

View File

@ -29,6 +29,7 @@ import java.util.Objects;
import jdk.internal.classfile.Label; import jdk.internal.classfile.Label;
import jdk.internal.classfile.TypeAnnotation.*; import jdk.internal.classfile.TypeAnnotation.*;
import static jdk.internal.classfile.Classfile.*; import static jdk.internal.classfile.Classfile.*;
import static java.util.Objects.requireNonNull;
public final class TargetInfoImpl { public final class TargetInfoImpl {
@ -104,6 +105,11 @@ public final class TargetInfoImpl {
public record LocalVarTargetInfoImpl(Label startLabel, Label endLabel, int index) public record LocalVarTargetInfoImpl(Label startLabel, Label endLabel, int index)
implements LocalVarTargetInfo { implements LocalVarTargetInfo {
public LocalVarTargetInfoImpl {
requireNonNull(startLabel);
requireNonNull(endLabel);
}
} }
public record CatchTargetImpl(int exceptionTableIndex) implements CatchTarget { public record CatchTargetImpl(int exceptionTableIndex) implements CatchTarget {
@ -117,7 +123,7 @@ public final class TargetInfoImpl {
public OffsetTargetImpl(TargetType targetType, Label target) { public OffsetTargetImpl(TargetType targetType, Label target) {
this.targetType = checkValid(targetType, TAT_INSTANCEOF, TAT_METHOD_REFERENCE); this.targetType = checkValid(targetType, TAT_INSTANCEOF, TAT_METHOD_REFERENCE);
this.target = target; this.target = requireNonNull(target);
} }
} }
@ -126,7 +132,7 @@ public final class TargetInfoImpl {
public TypeArgumentTargetImpl(TargetType targetType, Label target, int typeArgumentIndex) { public TypeArgumentTargetImpl(TargetType targetType, Label target, int typeArgumentIndex) {
this.targetType = checkValid(targetType, TAT_CAST, TAT_METHOD_REFERENCE_TYPE_ARGUMENT); this.targetType = checkValid(targetType, TAT_CAST, TAT_METHOD_REFERENCE_TYPE_ARGUMENT);
this.target = target; this.target = requireNonNull(target);
this.typeArgumentIndex = typeArgumentIndex; this.typeArgumentIndex = typeArgumentIndex;
} }
} }