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
Switch the default mockmaker to the inline mockmaker on JDK 17+ #2834
Conversation
fdaa6da
to
f1f1eb0
Compare
Seems like there are a couple of test failures :( Some of these look cryptic with the missing MethodDispatcher file. We had that before and I thought we fixed that? Do we need the fix that we did for |
Thanks @TimvdLippe , yeah, I am looking into that but it seems like we have to change not only |
fd36f74
to
dd706d3
Compare
subprojects/module-test/src/test/java/org/mockito/moduletest/ReplicatingClassLoader.java
Show resolved
Hide resolved
src/main/java/org/mockito/internal/creation/bytebuddy/InlineBytecodeGenerator.java
Show resolved
Hide resolved
src/test/java/org/mockitousage/configuration/ClassCacheVersusClassReloadingTest.java
Outdated
Show resolved
Hide resolved
7047578
to
d8827a8
Compare
src/main/java/org/mockito/internal/configuration/plugins/DefaultMockitoPlugins.java
Show resolved
Hide resolved
b760c03
to
0852e08
Compare
src/main/java/org/mockito/internal/creation/bytebuddy/InlineBytecodeGenerator.java
Show resolved
Hide resolved
src/main/java/org/mockito/internal/util/reflection/InstrumentationMemberAccessor.java
Show resolved
Hide resolved
bdb7a29
to
8fbe904
Compare
@reta Thanks for all the work thus far! This is the last PR for Mockito 5, is there something I can help you out with? |
Thanks @TimvdLippe , I am slowly crunching over test cases (it takes time for me to troubleshoot some of them ) so far there are just few left in Mockito core, I hope to fix them in the next couple of days:
The real blocker it seems like is OSGi, where inline mock maker may not be used as a default: the issue is that Thank you! |
@raphw do you have some more context on the previous comment with regards to OSGi? |
Hmm, the only possible solution I see would be to move Alternatively, we could instrument all class loaders to always load the dispatcher class from the boot loader to possibly override any custom behavior. But this is rather intrusive. Maybe we could make this configurable? What do you think would be the best way forward? |
58ad80d
to
5106832
Compare
src/main/java/org/mockito/internal/util/reflection/InstrumentationMemberAccessor.java
Show resolved
Hide resolved
src/main/java/org/mockito/internal/stubbing/defaultanswers/ReturnsSmartNulls.java
Outdated
Show resolved
Hide resolved
3cd2419
to
32064e6
Compare
src/main/java/org/mockito/internal/exceptions/stacktrace/DefaultStackTraceCleaner.java
Show resolved
Hide resolved
b344a7f
to
d214680
Compare
@raphw I think this is the best option to try so far and should work with most (if not all) OSGi containters, luckily most OSGi runtimes support customization of boot classloader delegation, I was able to fix our test cases which are based of Eclipse Equinox (and boot loader classpath is altered by instrumentation):
|
8bd7625
to
733b5c8
Compare
…mockito#2589 Signed-off-by: Andriy Redko <drreta@gmail.com>
Codecov ReportBase: 84.88% // Head: 84.78% // Decreases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## main #2834 +/- ##
============================================
- Coverage 84.88% 84.78% -0.11%
+ Complexity 2875 2868 -7
============================================
Files 327 327
Lines 8761 8780 +19
Branches 1060 1068 +8
============================================
+ Hits 7437 7444 +7
- Misses 1047 1063 +16
+ Partials 277 273 -4
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 at Codecov. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have reviewed all of these changes and they LGTM. Massive work @reta, thank you so much!
I am a bit confused as to why some of the tests weren't previously failing in our mockmaker-inline CI branch (the mock-maker-inline
job in our matrix). However, that's not a problem for this PR and something later to figure out.
@raphw do you mind doing a full check as well, just to make sure everything looks okay from your side? Then we can merge this and publish Mockito 5 🎉
Thanks @TimvdLippe !
I think there is a gap in tests: the tests get mock maker instance (from environment setting) but not the member accessor it supposed to be used with. As such, the tests used reflection, not module accessor, all the time. Does it make sense? |
This looks very good to me, but I think the OSGi configuration deserves some explicit documentation. |
Signed-off-by: Andriy Redko <drreta@gmail.com>
@reta yes that makes sense! Let's fix that in a separate PR. This looks good to me, thank you so much again! |
Signed-off-by: Andriy Redko drreta@gmail.com
Fixes #2589
Checklist
including project members to get a better picture of the change
commit is meaningful and help the people that will explore a change in 2 years
Fixes #<issue number>
in the description if relevantFixes #<issue number>
if relevant