Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ default ClassDesc classSymbol() {
* @param annotationClass the constant pool entry holding the descriptor string
* of the annotation interface
* @param elements the element-value pairs of the annotation
* @throws IllegalArgumentException if the number of pairs exceeds the limit
* of {@link java.lang.classfile##u2 u2}
*/
static Annotation of(Utf8Entry annotationClass,
List<AnnotationElement> elements) {
Expand All @@ -106,6 +108,8 @@ static Annotation of(Utf8Entry annotationClass,
* @param annotationClass the constant pool entry holding the descriptor string
* of the annotation interface
* @param elements the element-value pairs of the annotation
* @throws IllegalArgumentException if the number of pairs exceeds the limit
* of {@link java.lang.classfile##u2 u2}
*/
static Annotation of(Utf8Entry annotationClass,
AnnotationElement... elements) {
Expand All @@ -116,6 +120,8 @@ static Annotation of(Utf8Entry annotationClass,
* {@return an annotation}
* @param annotationClass the descriptor of the annotation interface
* @param elements the element-value pairs of the annotation
* @throws IllegalArgumentException if the number of pairs exceeds the limit
* of {@link java.lang.classfile##u2 u2}
*/
static Annotation of(ClassDesc annotationClass,
List<AnnotationElement> elements) {
Expand All @@ -126,6 +132,8 @@ static Annotation of(ClassDesc annotationClass,
* {@return an annotation}
* @param annotationClass the descriptor of the annotation interface
* @param elements the element-value pairs of the annotation
* @throws IllegalArgumentException if the number of pairs exceeds the limit
* of {@link java.lang.classfile##u2 u2}
*/
static Annotation of(ClassDesc annotationClass,
AnnotationElement... elements) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,8 @@ static AnnotationElement ofAnnotation(String name,
* @param name the name of the key
* @param values the associated values
* @see AnnotationValue#ofArray(AnnotationValue...) AnnotationValue::ofArray
* @throws IllegalArgumentException if the number of associated values
* exceeds the limit of {@link java.lang.classfile##u2 u2}
*/
static AnnotationElement ofArray(String name,
AnnotationValue... values) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,8 @@ static OfAnnotation ofAnnotation(Annotation value) {
* on array values derived from Java source code.
*
* @param values the array elements
* @throws IllegalArgumentException if the length of array exceeds the limit
* of {@link java.lang.classfile##u2 u2}
*/
static OfArray ofArray(List<AnnotationValue> values) {
return new AnnotationImpl.OfArrayImpl(values);
Expand All @@ -686,6 +688,8 @@ static OfArray ofArray(List<AnnotationValue> values) {
* on array values derived from Java source code.
*
* @param values the array elements
* @throws IllegalArgumentException if the length of array exceeds the limit
* of {@link java.lang.classfile##u2 u2}
*/
static OfArray ofArray(AnnotationValue... values) {
return ofArray(List.of(values));
Expand All @@ -699,7 +703,8 @@ static OfArray ofArray(AnnotationValue... values) {
* @param value the annotation value
* @throws IllegalArgumentException when the {@code value} parameter is not
* a primitive, a wrapper of primitive, a String, a ClassDesc,
* an enum constant, or an array of one of these.
* an enum constant, or an array of one of these; or any array has
* length over the limit of {@link java.lang.classfile##u2 u2}
*/
static AnnotationValue of(Object value) {
if (value instanceof String s) {
Expand Down
12 changes: 10 additions & 2 deletions src/java.base/share/classes/java/lang/classfile/ClassBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ default ClassBuilder withSuperclass(ClassDesc desc) {
*
* @param interfaces the interfaces
* @return this builder
* @throws IllegalArgumentException if the number of interfaces exceeds the
* limit of {@link java.lang.classfile##u2 u2}
* @see Interfaces
*/
default ClassBuilder withInterfaces(List<ClassEntry> interfaces) {
Expand All @@ -142,6 +144,8 @@ default ClassBuilder withInterfaces(List<ClassEntry> interfaces) {
*
* @param interfaces the interfaces
* @return this builder
* @throws IllegalArgumentException if the number of interfaces exceeds the
* limit of {@link java.lang.classfile##u2 u2}
* @see Interfaces
*/
default ClassBuilder withInterfaces(ClassEntry... interfaces) {
Expand All @@ -153,7 +157,9 @@ default ClassBuilder withInterfaces(ClassEntry... interfaces) {
*
* @param interfaces the interfaces
* @return this builder
* @throws IllegalArgumentException if any element of {@code interfaces} is primitive
* @throws IllegalArgumentException if any of {@code interfaces} is primitive,
* or if the number of interfaces exceeds the limit of {@link
* java.lang.classfile##u2 u2}
* @see Interfaces
*/
default ClassBuilder withInterfaceSymbols(List<ClassDesc> interfaces) {
Expand All @@ -165,7 +171,9 @@ default ClassBuilder withInterfaceSymbols(List<ClassDesc> interfaces) {
*
* @param interfaces the interfaces
* @return this builder
* @throws IllegalArgumentException if any element of {@code interfaces} is primitive
* @throws IllegalArgumentException if any of {@code interfaces} is primitive,
* or if the number of interfaces exceeds the limit of {@link
* java.lang.classfile##u2 u2}
* @see Interfaces
*/
default ClassBuilder withInterfaceSymbols(ClassDesc... interfaces) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2402,8 +2402,8 @@ default CodeBuilder ifne(Label target) {
* variable by a constant.
* <p>
* This may also generate {@link Opcode#IINC_W wide iinc} instructions if
* {@code slot} exceeds {@code 255} or {@code val} exceeds the range of
* {@link TypeKind#BYTE byte}.
* {@code slot} exceeds the limit of {@link java.lang.classfile##u1 u1} or
* {@code val} exceeds the range of {@link TypeKind#BYTE byte}.
*
* @param slot the local variable slot
* @param val the increment value
Expand Down
12 changes: 10 additions & 2 deletions src/java.base/share/classes/java/lang/classfile/Interfaces.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ public sealed interface Interfaces
/**
* {@return an {@linkplain Interfaces} element}
* @param interfaces the interfaces
* @throws IllegalArgumentException if the number of interfaces
* exceeds the limit of {@link java.lang.classfile##u2 u2}
*/
static Interfaces of(List<ClassEntry> interfaces) {
return new InterfacesImpl(interfaces);
Expand All @@ -62,6 +64,8 @@ static Interfaces of(List<ClassEntry> interfaces) {
/**
* {@return an {@linkplain Interfaces} element}
* @param interfaces the interfaces
* @throws IllegalArgumentException if the number of interfaces
* exceeds the limit of {@link java.lang.classfile##u2 u2}
*/
static Interfaces of(ClassEntry... interfaces) {
return of(List.of(interfaces));
Expand All @@ -70,7 +74,9 @@ static Interfaces of(ClassEntry... interfaces) {
/**
* {@return an {@linkplain Interfaces} element}
* @param interfaces the interfaces
* @throws IllegalArgumentException if any of {@code interfaces} is primitive
* @throws IllegalArgumentException if any of {@code interfaces} is primitive,
* or if the number of interfaces exceeds the limit of {@link
* java.lang.classfile##u2 u2}
*/
static Interfaces ofSymbols(List<ClassDesc> interfaces) {
return of(Util.entryList(interfaces));
Expand All @@ -79,7 +85,9 @@ static Interfaces ofSymbols(List<ClassDesc> interfaces) {
/**
* {@return an {@linkplain Interfaces} element}
* @param interfaces the interfaces
* @throws IllegalArgumentException if any of {@code interfaces} is primitive
* @throws IllegalArgumentException if any of {@code interfaces} is primitive,
* or if the number of interfaces exceeds the limit of {@link
* java.lang.classfile##u2 u2}
*/
static Interfaces ofSymbols(ClassDesc... interfaces) {
return ofSymbols(Arrays.asList(interfaces));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,8 @@ public int sizeIfFixed() {
* @param targetInfo which type in a declaration or expression is annotated
* @param targetPath which part of the type is annotated
* @param annotation the annotation
* @throws IllegalArgumentException if the size of {@code targetPath}
* exceeds the limit of {@link java.lang.classfile##u1 u1}
*/
static TypeAnnotation of(TargetInfo targetInfo, List<TypePathComponent> targetPath,
Annotation annotation) {
Expand Down Expand Up @@ -486,6 +488,8 @@ static ThrowsTarget ofThrows(int throwsTargetIndex) {
* including a variable declared as a resource in a try-with-resources statement}
* @param targetType {@link TargetType#LOCAL_VARIABLE} or {@link TargetType#RESOURCE_VARIABLE}
* @param table the list of local variable targets
* @throws IllegalArgumentException if the size of the list of targets
* exceeds the limit of {@link java.lang.classfile##u2 u2}
*/
static LocalVarTarget ofVariable(TargetType targetType, List<LocalVarTargetInfo> table) {
return new TargetInfoImpl.LocalVarTargetImpl(targetType, table);
Expand All @@ -494,6 +498,8 @@ static LocalVarTarget ofVariable(TargetType targetType, List<LocalVarTargetInfo>
/**
* {@return a target for annotations on the type in a local variable declaration}
* @param table the list of local variable targets
* @throws IllegalArgumentException if the size of the list of targets
* exceeds the limit of {@link java.lang.classfile##u2 u2}
*/
static LocalVarTarget ofLocalVariable(List<LocalVarTargetInfo> table) {
return ofVariable(TargetType.LOCAL_VARIABLE, table);
Expand All @@ -503,6 +509,8 @@ static LocalVarTarget ofLocalVariable(List<LocalVarTargetInfo> table) {
* {@return a target for annotations on the type in a local variable declared
* as a resource in a try-with-resources statement}
* @param table the list of local variable targets
* @throws IllegalArgumentException if the size of the list of targets
* exceeds the limit of {@link java.lang.classfile##u2 u2}
*/
static LocalVarTarget ofResourceVariable(List<LocalVarTargetInfo> table) {
return ofVariable(TargetType.RESOURCE_VARIABLE, table);
Expand Down Expand Up @@ -802,7 +810,6 @@ sealed interface LocalVarTargetInfo
*/
Label startLabel();


/**
* The given local variable has a value at indices into the code array in the interval
* [start_pc, start_pc + length), that is, between start_pc inclusive and start_pc + length exclusive.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ public sealed interface CharacterRangeTableAttribute
* {@link CodeBuilder#characterRange CodeBuilder::characterRange} instead.
*
* @param ranges the descriptions of the character ranges
* @throws IllegalArgumentException if the number of ranges exceeds the
* limit of {@link java.lang.classfile##u2 u2}
*/
static CharacterRangeTableAttribute of(List<CharacterRangeInfo> ranges) {
return new UnboundAttribute.UnboundCharacterRangeTableAttribute(ranges);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ public sealed interface ExceptionsAttribute
/**
* {@return an {@code Exceptions} attribute}
* @param exceptions the exceptions that may be thrown from this method
* @throws IllegalArgumentException if the number of exceptions exceeds the
* limit of {@link java.lang.classfile##u2 u2}
*/
static ExceptionsAttribute of(List<ClassEntry> exceptions) {
return new UnboundAttribute.UnboundExceptionsAttribute(exceptions);
Expand All @@ -85,6 +87,8 @@ static ExceptionsAttribute of(List<ClassEntry> exceptions) {
/**
* {@return an {@code Exceptions} attribute}
* @param exceptions the exceptions that may be thrown from this method
* @throws IllegalArgumentException if the number of exceptions exceeds the
* limit of {@link java.lang.classfile##u2 u2}
*/
static ExceptionsAttribute of(ClassEntry... exceptions) {
return of(List.of(exceptions));
Expand All @@ -93,6 +97,8 @@ static ExceptionsAttribute of(ClassEntry... exceptions) {
/**
* {@return an {@code Exceptions} attribute}
* @param exceptions the exceptions that may be thrown from this method
* @throws IllegalArgumentException if the number of exceptions exceeds the
* limit of {@link java.lang.classfile##u2 u2}
*/
static ExceptionsAttribute ofSymbols(List<ClassDesc> exceptions) {
return of(Util.entryList(exceptions));
Expand All @@ -101,6 +107,8 @@ static ExceptionsAttribute ofSymbols(List<ClassDesc> exceptions) {
/**
* {@return an {@code Exceptions} attribute}
* @param exceptions the exceptions that may be thrown from this method
* @throws IllegalArgumentException if the number of exceptions exceeds the
* limit of {@link java.lang.classfile##u2 u2}
*/
static ExceptionsAttribute ofSymbols(ClassDesc... exceptions) {
return ofSymbols(Arrays.asList(exceptions));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ public sealed interface InnerClassesAttribute
/**
* {@return an {@code InnerClasses} attribute}
* @param innerClasses descriptions of the nested classes
* @throws IllegalArgumentException if the number of descriptions exceeds
* the limit of {@link java.lang.classfile##u2 u2}
*/
static InnerClassesAttribute of(List<InnerClassInfo> innerClasses) {
return new UnboundAttribute.UnboundInnerClassesAttribute(innerClasses);
Expand All @@ -73,6 +75,8 @@ static InnerClassesAttribute of(List<InnerClassInfo> innerClasses) {
/**
* {@return an {@code InnerClasses} attribute}
* @param innerClasses descriptions of the nested classes
* @throws IllegalArgumentException if the number of descriptions exceeds
* the limit of {@link java.lang.classfile##u2 u2}
*/
static InnerClassesAttribute of(InnerClassInfo... innerClasses) {
return new UnboundAttribute.UnboundInnerClassesAttribute(List.of(innerClasses));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ public sealed interface LineNumberTableAttribute
* order instead.
*
* @param lines the line number descriptions
* @throws IllegalArgumentException if the number of descriptions exceeds
* the limit of {@link java.lang.classfile##u2 u2}
*/
static LineNumberTableAttribute of(List<LineNumberInfo> lines) {
return new UnboundAttribute.UnboundLineNumberTableAttribute(lines);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ public sealed interface LocalVariableTableAttribute
* {@link CodeBuilder#localVariable CodeBuilder::localVariable} instead.
*
* @param locals the local variable descriptions
* @throws IllegalArgumentException if the number of descriptions exceeds
* the limit of {@link java.lang.classfile##u2 u2}
*/
static LocalVariableTableAttribute of(List<LocalVariableInfo> locals) {
return new UnboundAttribute.UnboundLocalVariableTableAttribute(locals);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ public sealed interface LocalVariableTypeTableAttribute
/**
* {@return a {@code LocalVariableTypeTable} attribute}
* @param locals the local variable descriptions
* @throws IllegalArgumentException if the number of descriptions exceeds
* the limit of {@link java.lang.classfile##u2 u2}
*/
static LocalVariableTypeTableAttribute of(List<LocalVariableTypeInfo> locals) {
return new UnboundAttribute.UnboundLocalVariableTypeTableAttribute(locals);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ public sealed interface MethodParametersAttribute
/**
* {@return a {@code MethodParameters} attribute}
* @param parameters the method parameter descriptions
* @throws IllegalArgumentException if the number of parameters exceeds the
* limit of {@link java.lang.classfile##u1 u1}
*/
static MethodParametersAttribute of(List<MethodParameterInfo> parameters) {
return new UnboundAttribute.UnboundMethodParametersAttribute(parameters);
Expand All @@ -76,6 +78,8 @@ static MethodParametersAttribute of(List<MethodParameterInfo> parameters) {
/**
* {@return a {@code MethodParameters} attribute}
* @param parameters the method parameter descriptions
* @throws IllegalArgumentException if the number of parameters exceeds the
* limit of {@link java.lang.classfile##u1 u1}
*/
static MethodParametersAttribute of(MethodParameterInfo... parameters) {
return of(List.of(parameters));
Expand Down
Loading