Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix boolean values getters for RegisterForReflection annotations #38701

Merged
merged 1 commit into from
Feb 12, 2024
Merged
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 @@ -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();
}
}
Loading