Skip to content

Commit

Permalink
Introduce reason field in ReflectiveFieldBuildItem
Browse files Browse the repository at this point in the history
  • Loading branch information
zakkak committed Jul 29, 2024
1 parent a8b9707 commit d385ff7
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,24 @@ public final class ReflectiveFieldBuildItem extends MultiBuildItem {

final String declaringClass;
final String name;
final String reason;

public ReflectiveFieldBuildItem(FieldInfo field) {
public ReflectiveFieldBuildItem(String reason, FieldInfo field) {
this.reason = reason;
this.name = field.name();
this.declaringClass = field.declaringClass().name().toString();
}

public ReflectiveFieldBuildItem(FieldInfo field) {
this(null, field);
}

public ReflectiveFieldBuildItem(Field field) {
this(null, field);
}

public ReflectiveFieldBuildItem(String reason, Field field) {
this.reason = reason;
this.name = field.getName();
this.declaringClass = field.getDeclaringClass().getName();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,13 @@ public void addReflectiveField(Map<String, ReflectionInfo> reflectiveClasses, Re
reflectiveClasses.put(cl, existing = new ReflectionInfo());
}
existing.fieldSet.add(fieldInfo.getName());
String reason = fieldInfo.getReason();
if (reason != null) {
if (existing.reasons == null) {
existing.reasons = new ArrayList<>();
}
existing.reasons.add(reason);
}
}

static final class ReflectionInfo {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ public void registerMethod(MethodInfo methodInfo) {

@Override
public void registerField(FieldInfo fieldInfo) {
reflectiveFields.produce(new ReflectiveFieldBuildItem(fieldInfo));
reflectiveFields.produce(new ReflectiveFieldBuildItem(getClass().getName(), fieldInfo));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ public void build(
for (AnnotationInstance annotation : annotationInstances) {
if (annotation.target().kind() == AnnotationTarget.Kind.FIELD) {
contributeClass(classNamesToBeValidated, indexView, annotation.target().asField().declaringClass().name());
reflectiveFields.produce(new ReflectiveFieldBuildItem(annotation.target().asField()));
reflectiveFields.produce(new ReflectiveFieldBuildItem(getClass().getName(), annotation.target().asField()));
contributeClassMarkedForCascadingValidation(classNamesToBeValidated, indexView, consideredAnnotation,
annotation.target().asField().type());
} else if (annotation.target().kind() == AnnotationTarget.Kind.METHOD) {
Expand Down Expand Up @@ -527,7 +527,7 @@ public void build(
AnnotationTarget enclosingTarget = annotation.target().asType().enclosingTarget();
if (enclosingTarget.kind() == AnnotationTarget.Kind.FIELD) {
contributeClass(classNamesToBeValidated, indexView, enclosingTarget.asField().declaringClass().name());
reflectiveFields.produce(new ReflectiveFieldBuildItem(enclosingTarget.asField()));
reflectiveFields.produce(new ReflectiveFieldBuildItem(getClass().getName(), enclosingTarget.asField()));
if (annotation.target().asType().target() != null) {
contributeClassMarkedForCascadingValidation(classNamesToBeValidated, indexView,
consideredAnnotation,
Expand Down

0 comments on commit d385ff7

Please sign in to comment.