HHH-16711 Ensure static accessor methods for accessing foreign package state use visible types

This commit is contained in:
Christian Beikov 2023-06-20 19:48:30 +02:00
parent 2076fc0976
commit 28043f8fc4
1 changed files with 22 additions and 35 deletions

View File

@ -324,23 +324,14 @@ public class BytecodeProviderImpl implements BytecodeProvider {
getterType = ( (Method) getter ).getReturnType(); getterType = ( (Method) getter ).getReturnType();
} }
builder = builder.define( builder = builder.defineMethod(
new MethodDescription.InDefinedShape.Latent(
builder.toTypeDescription(),
new MethodDescription.Token(
"get_" + getter.getName(), "get_" + getter.getName(),
Opcodes.ACC_PROTECTED | Opcodes.ACC_STATIC,
TypeDescription.Generic.OfNonGenericType.ForLoadedType.of( TypeDescription.Generic.OfNonGenericType.ForLoadedType.of(
getterType getterType
), ),
Collections.singletonList( Opcodes.ACC_PROTECTED | Opcodes.ACC_STATIC
TypeDescription.Generic.OfNonGenericType.ForLoadedType.of(
clazz
)
)
)
)
) )
.withParameter( foreignPackageClassInfo.clazz )
.intercept( .intercept(
new Implementation.Simple( new Implementation.Simple(
new GetFieldOnArgument( new GetFieldOnArgument(
@ -358,24 +349,13 @@ public class BytecodeProviderImpl implements BytecodeProvider {
setterType = ( (Method) setter ).getParameterTypes()[0]; setterType = ( (Method) setter ).getParameterTypes()[0];
} }
builder = builder.define( builder = builder.defineMethod(
new MethodDescription.InDefinedShape.Latent(
builder.toTypeDescription(),
new MethodDescription.Token(
"set_" + setter.getName(), "set_" + setter.getName(),
Opcodes.ACC_PROTECTED | Opcodes.ACC_STATIC,
TypeDescription.Generic.VOID, TypeDescription.Generic.VOID,
Arrays.asList( Opcodes.ACC_PROTECTED | Opcodes.ACC_STATIC
TypeDescription.Generic.OfNonGenericType.ForLoadedType.of(
clazz
),
TypeDescription.Generic.OfNonGenericType.ForLoadedType.of(
setterType
)
)
)
)
) )
.withParameter( foreignPackageClassInfo.clazz )
.withParameter( setterType )
.intercept( .intercept(
new Implementation.Simple( new Implementation.Simple(
new SetFieldOnArgument( new SetFieldOnArgument(
@ -788,7 +768,10 @@ public class BytecodeProviderImpl implements BytecodeProvider {
Opcodes.INVOKESTATIC, Opcodes.INVOKESTATIC,
Type.getInternalName( foreignPackageMember.getForeignPackageAccessor() ), Type.getInternalName( foreignPackageMember.getForeignPackageAccessor() ),
"get_" + getterMember.getName(), "get_" + getterMember.getName(),
Type.getMethodDescriptor( Type.getType( type ), Type.getType( clazz ) ), Type.getMethodDescriptor(
Type.getType( type ),
Type.getType( underlyingMember.getDeclaringClass() )
),
false false
); );
} }
@ -983,7 +966,11 @@ public class BytecodeProviderImpl implements BytecodeProvider {
Opcodes.INVOKESTATIC, Opcodes.INVOKESTATIC,
Type.getInternalName( foreignPackageMember.getForeignPackageAccessor() ), Type.getInternalName( foreignPackageMember.getForeignPackageAccessor() ),
"set_" + setterMember.getName(), "set_" + setterMember.getName(),
Type.getMethodDescriptor( Type.getType( void.class ), Type.getType( clazz ), Type.getType( type ) ), Type.getMethodDescriptor(
Type.getType( void.class ),
Type.getType( foreignPackageMember.getMember().getDeclaringClass() ),
Type.getType( type )
),
false false
); );
} }