File tree Expand file tree Collapse file tree 1 file changed +20
-2
lines changed
hibernate-core/src/main/java/org/hibernate/bytecode/enhance/internal/bytebuddy Expand file tree Collapse file tree 1 file changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -532,8 +532,26 @@ String getDescriptor() {
532532 return fieldDescription .getDescriptor ();
533533 }
534534
535- boolean isVisibleTo (TypeDescription typeDescription ) {
536- return fieldDescription .isVisibleTo ( typeDescription );
535+ boolean isVisibleTo (TypeDescription type ) {
536+ final var declaringType = fieldDescription .getDeclaringType ().asErasure ();
537+ if ( declaringType .isVisibleTo ( type ) ) {
538+ if ( fieldDescription .isPublic () ) {
539+ return true ;
540+ }
541+ else if ( type .equals ( declaringType ) ) {
542+ return true ;
543+ }
544+ else if ( fieldDescription .isProtected () ) {
545+ return declaringType .isAssignableFrom ( type );
546+ }
547+ else if ( fieldDescription .isPrivate () ) {
548+ return type .isNestMateOf ( declaringType );
549+ }
550+ // We explicitly consider package-private fields as not visible, as the classes
551+ // might have the same package name but be loaded by different class loaders.
552+ // (see https://hibernate.atlassian.net/browse/HHH-19784)
553+ }
554+ return false ;
537555 }
538556
539557 FieldDescription getFieldDescription () {
You can’t perform that action at this time.
0 commit comments