File tree Expand file tree Collapse file tree 1 file changed +17
-2
lines changed
hibernate-core/src/main/java/org/hibernate/bytecode/enhance/internal/bytebuddy Expand file tree Collapse file tree 1 file changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -810,8 +810,23 @@ String getDescriptor() {
810
810
return fieldDescription .getDescriptor ();
811
811
}
812
812
813
- boolean isVisibleTo (TypeDescription typeDescription ) {
814
- return fieldDescription .isVisibleTo ( typeDescription );
813
+ boolean isVisibleTo (TypeDescription type ) {
814
+ final var declaringType = fieldDescription .getDeclaringType ().asErasure ();
815
+ if ( declaringType .isVisibleTo ( type ) ) {
816
+ if ( fieldDescription .isPublic () || type .equals ( declaringType ) ) {
817
+ return true ;
818
+ }
819
+ else if ( fieldDescription .isProtected () ) {
820
+ return declaringType .isAssignableFrom ( type );
821
+ }
822
+ else if ( fieldDescription .isPrivate () ) {
823
+ return type .isNestMateOf ( declaringType );
824
+ }
825
+ // We explicitly consider package-private fields as not visible, as the classes
826
+ // might have the same package name but be loaded by different class loaders.
827
+ // (see https://hibernate.atlassian.net/browse/HHH-19784)
828
+ }
829
+ return false ;
815
830
}
816
831
817
832
FieldDescription getFieldDescription () {
You can’t perform that action at this time.
0 commit comments