Skip to content

Commit

Permalink
Annotate Mockito#{mock,spy}(T... reified) with @SafeVarargs (#2866)
Browse files Browse the repository at this point in the history
This avoids "Unchecked generics array creation for varargs parameter"
warnings at the call site.
  • Loading branch information
Stephan202 committed Jan 14, 2023
1 parent adf528d commit acddbbc
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/main/java/org/mockito/Mockito.java
Original file line number Diff line number Diff line change
Expand Up @@ -1932,6 +1932,7 @@ public class Mockito extends ArgumentMatchers {
* @return mock object
* @since 4.9.0
*/
@SafeVarargs
public static <T> T mock(T... reified) {
if (reified.length > 0) {
throw new IllegalArgumentException(
Expand Down Expand Up @@ -2161,6 +2162,7 @@ public static <T> T spy(Class<T> classToSpy) {
* @return spy object
* @since 4.9.0
*/
@SafeVarargs
public static <T> T spy(T... reified) {
if (reified.length > 0) {
throw new IllegalArgumentException(
Expand Down

0 comments on commit acddbbc

Please sign in to comment.