Skip to content

Immutables integration not working correctly with custom Value.Style typeImmutable #1924

@ThLeu

Description

@ThLeu
  • Is this an issue (and hence not a question)?

Hi, This issue basically concerns what was already mentioned in this comment (#782 (comment)) and as I didn't find an issue yet, here it is now because we ran into this problem aswell.

So the issue is concerning this exact line here:
https://github.com/mapstruct/mapstruct/blob/master/processor/src/main/java/org/mapstruct/ap/spi/ImmutablesBuilderProvider.java#L83

The Immutables integration only works correctly if Immutables generated classes are configured to use the default "Immutables" prefix (which is hardcoded on this line).

This caused us some severe issues because MapStruct will in some cases not generate an implementation and also not report any errors or anything (even with MapStruct policies set to ERROR), the build was even successful as only the implementation was missing. This happened when we used an Immutable class inside another Immutable class (both not with the default prefix style), but I am not sure if the problem only occurs with nested Immutables classes.

We also defined a custom annotation which uses the Immutables @Value.Style annotation as a meta-annotation.

@Value.Style(
      // The generated Immutable will have 'Immutable' suffix instead of prefix
      typeImmutable = "*Immutable"
public @interface CustomStyleAnnotation {
}

So in short the bug is that that @Value.Style typeImmutablevalue is not considered when working with Immutables.

The addition that it can also be a meta-annotation in a custom annotation is probably just a detail but it also be considered.

Best regards

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions