Support primitives in GenericArrayReturnType.#3753
Conversation
|
Sorry, I did not think of a good way to add tests. The new Primitives logic is trivial and maybe doesn't need a test. The |
TimvdLippe
left a comment
There was a problem hiding this comment.
You can add some tests here: https://github.com/mockito/mockito/tree/main/mockito-integration-tests/android-tests/src/test/java/org/mockitousage/androidtest We prefer to use full integration tests rather than unit tests here. Therefore, you can copy the example as mentioned in your issue and put that in the test suite
|
Thanks, added an integration test. I confirmed the test fails without the changes in |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3753 +/- ##
============================================
+ Coverage 86.44% 86.46% +0.01%
- Complexity 2987 2988 +1
============================================
Files 341 341
Lines 9032 9041 +9
Branches 1112 1113 +1
============================================
+ Hits 7808 7817 +9
+ Misses 943 942 -1
- Partials 281 282 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
### What changes were proposed in this pull request? This PR aims to upgrade `mockito` to 5.21.0 for Apache Spark K8s Operator `v0.7`. ### Why are the changes needed? To bring the latest features and bug fixes. - https://github.com/mockito/mockito/releases/tag/v5.21.0 - mockito/mockito#3758 - mockito/mockito#3752 - mockito/mockito#3753 - mockito/mockito#3759 - mockito/mockito#3731 ### Does this PR introduce _any_ user-facing change? No behavior change. ### How was this patch tested? Pass the CIs. ### Was this patch authored or co-authored using generative AI tooling? No. Closes #425 from dongjoon-hyun/SPARK-54672. Authored-by: Dongjoon Hyun <[email protected]> Signed-off-by: Dongjoon Hyun <[email protected]>
Fixes #3752
In my testing, for a method returning
byte[],Method#getGenericReturnType()on a normal JVM returns aClass, the same asbyte[].class.On Android, the implementation is completely different than OpenJDK's. Code ref:
https://cs.android.com/android/platform/superproject/main/+/main:libcore/ojluni/src/main/java/java/lang/reflect/Method.java;l=175-177;bpv=0;bpt=1
It uses Android-specific reflection APIs under the hood, and this returns a
GenericArrayTypewith component typebyte.class.This is my attempt to handle this scenario, by adding primitive support to
GenericArrayReturnType.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
./gradlew spotlessApplyfor auto-formatting)Fixes #<issue number>in the description if relevantFixes #<issue number>if relevant