Skip to content

Commit

Permalink
Merge pull request quarkusio#38701 from zakkak/2024-02-09-fix-get-boo…
Browse files Browse the repository at this point in the history
…lean-value

Fix boolean values getters for RegisterForReflection annotations
  • Loading branch information
zakkak authored Feb 12, 2024
2 parents 7fd19a8 + 04f9286 commit 0290e66
Showing 1 changed file with 9 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,18 @@ public void build(CombinedIndexBuildItem combinedIndexBuildItem, Capabilities ca
ReflectiveHierarchyBuildItem.Builder builder = new ReflectiveHierarchyBuildItem.Builder();
Set<DotName> processedReflectiveHierarchies = new HashSet<DotName>();

IndexView index = combinedIndexBuildItem.getComputingIndex();
for (AnnotationInstance i : combinedIndexBuildItem.getIndex()
.getAnnotations(DotName.createSimple(RegisterForReflection.class.getName()))) {

boolean methods = getBooleanValue(i, "methods");
boolean fields = getBooleanValue(i, "fields");
boolean ignoreNested = i.value("ignoreNested") != null && i.value("ignoreNested").asBoolean();
boolean serialization = i.value("serialization") != null && i.value("serialization").asBoolean();
boolean unsafeAllocated = i.value("unsafeAllocated") != null && i.value("unsafeAllocated").asBoolean();
boolean methods = i.valueWithDefault(index, "methods").asBoolean();
boolean fields = i.valueWithDefault(index, "fields").asBoolean();
boolean ignoreNested = i.valueWithDefault(index, "ignoreNested").asBoolean();
boolean serialization = i.valueWithDefault(index, "serialization").asBoolean();
boolean unsafeAllocated = i.valueWithDefault(index, "unsafeAllocated").asBoolean();
boolean registerFullHierarchyValue = i.valueWithDefault(index, "registerFullHierarchy").asBoolean();

AnnotationValue targetsValue = i.value("targets");
AnnotationValue registerFullHierarchyValue = i.value("registerFullHierarchy");
AnnotationValue classNamesValue = i.value("classNames");
AnnotationValue lambdaCapturingTypesValue = i.value("lambdaCapturingTypes");

Expand Down Expand Up @@ -114,14 +115,14 @@ private void registerClass(ClassLoader classLoader, String className, boolean me
boolean ignoreNested, boolean serialization, boolean unsafeAllocated,
final BuildProducer<ReflectiveClassBuildItem> reflectiveClass,
BuildProducer<ReflectiveHierarchyBuildItem> reflectiveClassHierarchy, Set<DotName> processedReflectiveHierarchies,
AnnotationValue registerFullHierarchyValue, Builder builder) {
boolean registerFullHierarchyValue, Builder builder) {
reflectiveClass.produce(serialization
? ReflectiveClassBuildItem.builder(className).serialization().unsafeAllocated(unsafeAllocated).build()
: ReflectiveClassBuildItem.builder(className).constructors().methods(methods).fields(fields)
.unsafeAllocated(unsafeAllocated).build());

//Search all class hierarchy, fields and methods in order to register its classes for reflection
if (registerFullHierarchyValue != null && registerFullHierarchyValue.asBoolean()) {
if (registerFullHierarchyValue) {
registerClassDependencies(reflectiveClassHierarchy, classLoader, processedReflectiveHierarchies, methods, builder,
className);
}
Expand Down Expand Up @@ -228,7 +229,4 @@ private static Type getMethodReturnType(IndexView indexView, DotName initialName
return methodReturnType;
}

private static boolean getBooleanValue(AnnotationInstance i, String name) {
return i.value(name) == null || i.value(name).asBoolean();
}
}

0 comments on commit 0290e66

Please sign in to comment.