Generated metamodel contains invalid import when using generics

Description

Given the following sources

the generated metamodel ChildA_ contains an invalid import

which prevents compilation.

 

By experimenting i found that

  • ChildA needs to be in a different package than Parent for this bug to occur

  • declaring ChildA as ChildA<A, B extends ChildB<A>> (without extends Parent) doesn’t reproduce the bug

  • when ChildB declares multiple type parameters (all specified as a wildcard in ChildA), the generated import changes, e.g. when ChildB declares type parameters <A, B, C> the resulting import will be

 

Java 21, hibernate-jpamodelgen 6.4.1.Final, Maven 3.8.6

Activity

Show:

Gavin King February 20, 2024 at 9:41 AM

This is fixed.

Čedomir Igaly January 19, 2024 at 4:16 PM

Not so quick, and not so dirty solution is now in pull request 7723

Jonah Bauer January 19, 2024 at 9:00 AM

unfortunately, the pull request only addresses trailing >, but as mentioned at the end of the issue, thats not the only problem. a real “quick and dirty” fix would at least require removing (?:,\?)*>$.

Čedomir Igaly January 18, 2024 at 5:13 PM
Edited

I’ve created quick&dirty fix for this problem in pull request 7716 Part of source code that is handling imports is full of things that have dirty smell, so I guess this one is not worse than rest.

Unfortunately, there are more of such “features” hidden in metamodel generator

Fixed

Details

Assignee

Reporter

Worked in

Components

Fix versions

Affects versions

Priority

Created January 4, 2024 at 8:52 AM
Updated April 23, 2024 at 12:03 PM
Resolved February 20, 2024 at 12:52 PM