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 @@ -823,8 +823,23 @@ String getDescriptor() {
823823 return fieldDescription .getDescriptor ();
824824 }
825825
826- boolean isVisibleTo (TypeDescription typeDescription ) {
827- return fieldDescription .isVisibleTo ( typeDescription );
826+ boolean isVisibleTo (TypeDescription type ) {
827+ final var declaringType = fieldDescription .getDeclaringType ().asErasure ();
828+ if ( declaringType .isVisibleTo ( type ) ) {
829+ if ( fieldDescription .isPublic () || type .equals ( declaringType ) ) {
830+ return true ;
831+ }
832+ else if ( fieldDescription .isProtected () ) {
833+ return declaringType .isAssignableFrom ( type );
834+ }
835+ else if ( fieldDescription .isPrivate () ) {
836+ return type .isNestMateOf ( declaringType );
837+ }
838+ // We explicitly consider package-private fields as not visible, as the classes
839+ // might have the same package name but be loaded by different class loaders.
840+ // (see https://hibernate.atlassian.net/browse/HHH-19784)
841+ }
842+ return false ;
828843 }
829844
830845 FieldDescription getFieldDescription () {
You can’t perform that action at this time.
0 commit comments