HHH-17034 Bytecode enhancement leads to broken constructor for a generic embedded field in a twice removed MappedSuperclass

This commit is contained in:
Andrea Boriero 2023-08-07 16:32:04 +02:00 committed by Andrea Boriero
parent b250f3f1fb
commit 267e65239e
1 changed files with 4 additions and 4 deletions

View File

@ -608,20 +608,20 @@ class CodeTemplates {
static class GetterMapping implements Advice.OffsetMapping { static class GetterMapping implements Advice.OffsetMapping {
private final TypeDescription.Generic returnType; private final TypeDescription.Generic returnType;
private final String name; private final FieldDescription persistentField;
GetterMapping(FieldDescription persistentField) { GetterMapping(FieldDescription persistentField) {
this( persistentField, persistentField.getType() ); this( persistentField, persistentField.getType() );
} }
GetterMapping(FieldDescription persistentField, TypeDescription.Generic returnType) { GetterMapping(FieldDescription persistentField, TypeDescription.Generic returnType) {
this.name = persistentField.getName(); this.persistentField = persistentField;
this.returnType = returnType; this.returnType = returnType;
} }
@Override public Target resolve(TypeDescription instrumentedType, MethodDescription instrumentedMethod, Assigner assigner, Advice.ArgumentHandler argumentHandler, Sort sort) { @Override public Target resolve(TypeDescription instrumentedType, MethodDescription instrumentedMethod, Assigner assigner, Advice.ArgumentHandler argumentHandler, Sort sort) {
MethodDescription.Token signature = new MethodDescription.Token( EnhancerConstants.PERSISTENT_FIELD_READER_PREFIX + name , Opcodes.ACC_PUBLIC, returnType ); MethodDescription.Token signature = new MethodDescription.Token( EnhancerConstants.PERSISTENT_FIELD_READER_PREFIX + persistentField.getName() , Opcodes.ACC_PUBLIC, returnType );
MethodDescription method = new MethodDescription.Latent( instrumentedType.getSuperClass().asErasure(), signature ); MethodDescription method = new MethodDescription.Latent( persistentField.getDeclaringType().asErasure(), signature );
return new Target.AbstractReadOnlyAdapter() { return new Target.AbstractReadOnlyAdapter() {
@Override @Override