Skip to content

Commit

Permalink
Register elements accessed by jsonb for native access
Browse files Browse the repository at this point in the history
* `jakarta.json.bind.spi.JsonbProvider` service
* `java.beans.ConstructorProperties` class

Relates to quarkusio#41995
  • Loading branch information
zakkak committed Jan 13, 2025
1 parent 54619a8 commit c3d2fbb
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import static org.jboss.jandex.AnnotationTarget.Kind.FIELD;
import static org.jboss.jandex.AnnotationTarget.Kind.METHOD;

import java.beans.ConstructorProperties;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
Expand All @@ -15,6 +16,7 @@
import jakarta.json.bind.annotation.JsonbTypeSerializer;
import jakarta.json.bind.serializer.JsonbDeserializer;
import jakarta.json.bind.serializer.JsonbSerializer;
import jakarta.json.bind.spi.JsonbProvider;

import org.eclipse.yasson.JsonBindingProvider;
import org.eclipse.yasson.spi.JsonbComponentInstanceCreator;
Expand Down Expand Up @@ -71,6 +73,9 @@ void build(BuildProducer<ReflectiveClassBuildItem> reflectiveClass,
serviceProvider.produce(new ServiceProviderBuildItem(JsonbComponentInstanceCreator.class.getName(),
QuarkusJsonbComponentInstanceCreator.class.getName()));

// Accessed in jakarta.json.bind.spi.JsonbProvider.provider()
serviceProvider.produce(new ServiceProviderBuildItem(JsonbProvider.class.getName()));

// this needs to be registered manually since the runtime module is not indexed by Jandex
additionalBeans.produce(new AdditionalBeanBuildItem(JsonbProducer.class));

Expand All @@ -91,6 +96,9 @@ void build(BuildProducer<ReflectiveClassBuildItem> reflectiveClass,
reflectiveClass.produce(
ReflectiveClassBuildItem.builder("java.lang.String").build());

// register `java.beans.ConstructorProperties` as it's accessed through `io.quarkus.jsonb.JsonbProducer.jsonb`
reflectiveClass.produce(ReflectiveClassBuildItem.builder(ConstructorProperties.class).build());

// Necessary for Yasson versions using MethodHandles (2.0+)
reflectiveMethod.produce(new ReflectiveMethodBuildItem(
getClass().getName(),
Expand Down

0 comments on commit c3d2fbb

Please sign in to comment.