Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes 2947: correct visibility check to respect nestmates #2948

Merged
merged 1 commit into from Mar 25, 2023

Conversation

raphw
Copy link
Member

@raphw raphw commented Mar 25, 2023

Since Java 11, subclasses can invoke private constructors if they are nested classes and the access right is registered in the nestmate property of both classes. Without recognizing such rights, Mockito cannot create a synthetic constructor hierarchy that sets fields for spies as the constructor generation is skipped due to a missing super constructor that is considered valid.

@raphw raphw force-pushed the visibility-check-nestmates branch 2 times, most recently from 0e2890c to 50457b3 Compare March 25, 2023 10:47
…asses can invoke private constructors if they are nested classes.
Copy link
Contributor

@TimvdLippe TimvdLippe left a comment

Choose a reason for hiding this comment

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

Nice!

@codecov-commenter
Copy link

codecov-commenter commented Mar 25, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.02 🎉

Comparison is base (568c829) 85.68% compared to head (90de7e6) 85.70%.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #2948      +/-   ##
============================================
+ Coverage     85.68%   85.70%   +0.02%     
- Complexity     2864     2865       +1     
============================================
  Files           325      325              
  Lines          8696     8696              
  Branches       1074     1074              
============================================
+ Hits           7451     7453       +2     
+ Misses          967      966       -1     
+ Partials        278      277       -1     
Impacted Files Coverage Δ
.../internal/creation/bytebuddy/MockMethodAdvice.java 81.94% <100.00%> (ø)

... and 1 file with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@TimvdLippe TimvdLippe merged commit 5486617 into main Mar 25, 2023
13 checks passed
@TimvdLippe TimvdLippe deleted the visibility-check-nestmates branch March 25, 2023 12:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants