Skip to content

Commit

Permalink
feat(objectionary#534): fix problem with empty array default value
Browse files Browse the repository at this point in the history
  • Loading branch information
volodya-lombrozo committed Apr 2, 2024
1 parent f1a74fb commit cc06063
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,17 @@ public void writeTo(final AnnotationVisitor avisitor) {
);
break;
case ARRAY:
final AnnotationVisitor array = avisitor.visitArray(
Optional.ofNullable(this.params.get(0)).map(String.class::cast).orElse(null)
);
for (final Object param : this.params.subList(1, this.params.size())) {
((BytecodeAnnotationValue) param).writeTo(array);
if (this.params.isEmpty()) {
avisitor.visitArray(null).visitEnd();
} else {
final AnnotationVisitor array = avisitor.visitArray(
Optional.ofNullable(this.params.get(0)).map(String.class::cast).orElse(null)
);
for (final Object param : this.params.subList(1, this.params.size())) {
((BytecodeAnnotationValue) param).writeTo(array);
}
array.visitEnd();
}
array.visitEnd();
break;
case ANNOTATION:
final AnnotationVisitor annotation = avisitor.visitAnnotation(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ public AnnotationVisitor visitArray(final String name) {
final DirectivesAnnotationProperty prop = new DirectivesAnnotationProperty(
DirectivesAnnotationProperty.Type.ARRAY
);
prop.append(new DirectivesData("name", name));
if (name != null) {
prop.append(new DirectivesData("name", name));
}
this.annotation.append(prop);
return new DirectivesAnnotationVisitor(this.api, super.visitArray(name), prop);
}
Expand Down

0 comments on commit cc06063

Please sign in to comment.