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

[BUG] Jacksonized generates inconsistent annotations in byte code based on imports and builderClassName #3725

Open
jones501 opened this issue Aug 20, 2024 · 2 comments

Comments

@jones501
Copy link

Describe the bug
The annotation @JsonDeserialize is not created consistently for classes annotated with @Jacksonized and @Builder depending on the builderClassName and import statements on the class.

To Reproduce

The bytecode for this class will correctly have the @JsonDeserialize annotation as well as a builder annotated with @JsonPOJOBuilder

package ch.demo.lombok;

import lombok.Builder;
import lombok.extern.jackson.Jacksonized;

@Jacksonized
@Builder(builderClassName = "Builder")
public class LombokClassWithExplicitImportAndBuilderClassName {
    private final String s;
}

However simply by replacing the import with a wildcard import the annotation is not generated, for example the annotation is not present on the bytecode of the following class:

package ch.demo.lombok;

import lombok.*;
import lombok.extern.jackson.Jacksonized;

@Jacksonized
@Builder(builderClassName = "Builder")
public class LombokClassWithWildcardImportAndBuilderClassName {
    private final String s;
}

However again the above class will work with the wildcard imports by simply removing the builderClassName from the annotation:

package ch.demo.lombok;

import lombok.*;
import lombok.extern.jackson.Jacksonized;

@Jacksonized
@Builder
public class LombokClassWithWildcardImport {
    private final String s;
}

Expected behavior

Consistently generate the annotations and builders etc. required for Jackson for classes annotated with @Jacksonized irrespective of other details such as builder class name and unrelated imports.

Version info

  • Lombok version 1.18.34
  • tested with java 17.0.4.1 (liberica)

Additional context

  • built using maven
  • built using jackson-databind and jackson-annotations dependencies version 2.17.1
@jones501
Copy link
Author

lombok-issue-demo.zip

attached an example project which demonstrates the issue

@jones501 jones501 changed the title [BUG] [BUG] Jacksonized generates inconsistent annotations in byte code based on imports and builderClassName Aug 20, 2024
@Rawi01
Copy link
Collaborator

Rawi01 commented Sep 19, 2024

Thank you for reporting this issue. I guess this is some kind of type name confusion caused by your inner class Builder that hides the @Builder wildcard import. You could try to use a fully qualified builder annotation (@lombok.Builder).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants