-
-
Notifications
You must be signed in to change notification settings - Fork 76
Description
- I am willing to put in the work and submit a PR to resolve this issue.
Describe the bug
When I have upgraded JDK from 17 to 21 JPAAnnotationProcessor throws java.lang.IllegalStateException: Did not find type T in ClassA>
To Reproduce
@MappedSuperclass
public abstract class ClassA<T extends ClassB<?> extends ClassC {
}
@MappedSuperclass
public abstract class ClassB<V extends ClassA<?>> extends ClassD {
}
@MappedSuperclass
public abstract class ClassD extends ClassC {
}
@MappedSuperclass
public abstract class ClassC {
}
On JDK 17 JPAAnnotationProcessor generates Q classes correctly, but JDK 21 throws error. I found problem in com.querydsl.apt.ExtendedTypeFactory (part of querydsl-apt module) in method visitTypeVariable. ExtendedTypeFactory overrides com.querydsl.apt.SimpleTypeVisitorAdapter. SimpleTypeVisitorAdapter overrides javax.lang.model.util.SimpleTypeVisitor6 which is part of JDK. So probably JDK changes behaviour of this SimpleTypeVisitor6, because in method ExtendedTypeFactory#visitTypeVariable
String varName = typeVariable.toString();
returns ' T' instead of 'T' (empty space before T). When I change line to
String varName = typeVariable.asElement().getSimpleName().toString();
generation works correctly.
Expected behavior
Generated Q-class for generic MappedSuperclass class.
Desktop (please complete the following information):
- Windows: 10
- Spring core: 6.1.16
- Querydsl version: 7.0
- Database: doesn't matter
- JDK: 21
Additional info
querydsl/querydsl#3747