Skip to content

Reflection-free serializer is generated also for pojos annotated with @JsonValue #47689

@luca-bassoricci

Description

@luca-bassoricci

Describe the bug

A reflection-free serializer is generated for classes annotated with @JsonValue but the usage of this annotation is like using a custom serializer so for that classes the reflection-free serialized should be avoided.

Expected behavior

The standard JsonValueSerializer should be used instead of a reflection-free one.

Actual behavior

A reflection-free serializer is created instead of using the standard Jackson serializer.

How to Reproduce?

https://github.com/luca-bassoricci/reflection-free-serializer-issue
Just run tests

Output of uname -a or ver

windows 11

Output of java -version

jdk21

Quarkus version or git rev

3.22.1

Build tool (ie. output of mvnw --version or gradlew --version)

No response

Additional information

To avoid reflection a reflection-free serializer tha calls @JsonValue annotated method should be created:

public class ItemId$quarkusjacksonserializer extends StdSerializer {
  public ItemId$quarkusjacksonserializer() {
    super(ItemId.class);
  }
  public void serialize(Object var1, JsonGenerator var2, SerializerProvider var3) throws IOException {
    var2.writeXXX(((ItemId) var1).callJsonValueAnnotatedMethod());
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/jacksonIssues related to Jackson (JSON library)env/windowsImpacts Windows machineskind/bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions