HHH-16832 Bytecode enhancement leads to broken constructor for a generic embedded field in a MappedSuperclass
This commit is contained in:
parent
35206ddb19
commit
1b3f728703
|
@ -607,14 +607,20 @@ class CodeTemplates {
|
|||
// mapping to get private field from superclass by calling the enhanced reader, for use when field is not visible
|
||||
static class GetterMapping implements Advice.OffsetMapping {
|
||||
|
||||
private final FieldDescription persistentField;
|
||||
private final TypeDescription.Generic returnType;
|
||||
private final String name;
|
||||
|
||||
GetterMapping(FieldDescription persistentField) {
|
||||
this.persistentField = persistentField;
|
||||
this( persistentField, persistentField.getType() );
|
||||
}
|
||||
|
||||
GetterMapping(FieldDescription persistentField, TypeDescription.Generic returnType) {
|
||||
this.name = persistentField.getName();
|
||||
this.returnType = returnType;
|
||||
}
|
||||
|
||||
@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 + persistentField.getName(), Opcodes.ACC_PUBLIC, persistentField.getType() );
|
||||
MethodDescription.Token signature = new MethodDescription.Token( EnhancerConstants.PERSISTENT_FIELD_READER_PREFIX + name , Opcodes.ACC_PUBLIC, returnType );
|
||||
MethodDescription method = new MethodDescription.Latent( instrumentedType.getSuperClass().asErasure(), signature );
|
||||
|
||||
return new Target.AbstractReadOnlyAdapter() {
|
||||
|
|
|
@ -87,7 +87,7 @@ final class InlineDirtyCheckingHandler implements Implementation, ByteCodeAppend
|
|||
Advice.WithCustomMapping advice = Advice.withCustomMapping();
|
||||
advice = persistentField.isVisibleTo( managedCtClass )
|
||||
? advice.bind( CodeTemplates.FieldValue.class, persistentField.getFieldDescription() )
|
||||
: advice.bind( CodeTemplates.FieldValue.class, new CodeTemplates.GetterMapping( persistentField.getFieldDescription() ) );
|
||||
: advice.bind( CodeTemplates.FieldValue.class, new CodeTemplates.GetterMapping( persistentField.getFieldDescription(), persistentField.getGetter().get().getReturnType() ) );
|
||||
|
||||
implementation = advice
|
||||
.bind( CodeTemplates.FieldName.class, persistentField.getName() )
|
||||
|
|
Loading…
Reference in New Issue