Skip to content

Conversation

mbellade
Copy link
Member

@mbellade mbellade commented Sep 17, 2025

Fixes https://hibernate.atlassian.net/browse/HHH-19784 in the first commit.

The rest of the commits are a backport of #10192, which are required to make access optimizers work in similar cases (package-private fields in the same hierarchy but with different classloaders).


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license
and can be relicensed under the terms of the LGPL v2.1 license in the future at the maintainers' discretion.
For more information on licensing, please check here.


https://hibernate.atlassian.net/browse/HHH-19369
https://hibernate.atlassian.net/browse/HHH-19372

@mbellade mbellade added the 6.2 label Sep 17, 2025
@mbellade mbellade requested a review from beikov September 17, 2025 09:13
@mbellade mbellade changed the title Pacakge private 6.2 [6.2] Pacakge-private members access fixes for bytecode enhancement Sep 17, 2025
@yrodiere yrodiere changed the title [6.2] Pacakge-private members access fixes for bytecode enhancement [6.2] Package-private members access fixes for bytecode enhancement Sep 17, 2025
Comment on lines 537 to 539
if ( declaringType.isVisibleTo( type ) ) {
if ( fieldDescription.isPublic() ) {
return true;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically a package-protected declaring type would pass the check, but would likely end up hitting the problem we're trying to fix in case of split packages.

Though in practice I doubt package-protected types would work well with Hibernate ORM, so I suppose we can ignore this.

Comment on lines +550 to +549
// We explicitly consider package-private fields as not visible, as the classes
// might have the same package name but be loaded by different class loaders.
// (see https://hibernate.atlassian.net/browse/HHH-19784)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we don't have a test for that, correct? That's fine, but I just wanted to check that it's simply because it's too hard to set up.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are correct, it's quite hard to test mappings in different EARs or even EJB jars using separate class loaders - we tried in the past and didn't get anywhere. We might give it another try, but it might be much simpler to do in something like a Wildfly integration test.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In case it helps, I believe the attempt to simulate an EAR deploying with Hibernate ORM was defeated by the test framework library loading the test entity classes before they could be loaded by (EAR like) test classloader.

@mbellade mbellade force-pushed the pacakge-private-6.2 branch 2 times, most recently from 84c64a0 to 53573c7 Compare September 18, 2025 18:21
@mbellade mbellade marked this pull request as ready for review September 22, 2025 14:18
@mbellade mbellade merged commit a563384 into hibernate:6.2 Sep 22, 2025
27 of 29 checks passed
@mbellade mbellade deleted the pacakge-private-6.2 branch September 22, 2025 16:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants