Skip to content

Decrease usage of deprecated elements #572

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

Merged
merged 1 commit into from
Jun 17, 2025

Conversation

jozic
Copy link
Contributor

@jozic jozic commented Jun 15, 2025

@TimvdLippe
i would like to add support for Scala 3, but i also like baby steps, so this is one of the steps towards Scala 3 (and cleaner build). The only usages of deprecated elements left (and suppressed) are from mockito-core, like

    /**
     * @deprecated Not used by Mockito but by mockito-scala
     */
    @Deprecated
    public RealMethod getRealMethod() {
        return realMethod;
    }

all other deprecated warnings are fixed and compiler will not let add new ones without explicitly suppressing them

@jozic jozic force-pushed the decrease-deprecated-usages branch from 5ee3638 to 46a561c Compare June 15, 2025 21:46
@jozic jozic marked this pull request as ready for review June 15, 2025 23:10
@jozic jozic force-pushed the decrease-deprecated-usages branch from 46a561c to 5445f05 Compare June 16, 2025 00:09
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.

These all look good, thanks for cleaning these up! I only have one clarifying question if we are not accidentally dropping JVM 11 support.

@@ -120,39 +114,6 @@ object ReflectionUtils {
}

def setFinalStatic(field: Field, newValue: AnyRef): Unit =
if (JavaVersion < 17)
Copy link
Contributor

Choose a reason for hiding this comment

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

We still support Java 11. Why is this code no longer required to be checked?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's still good as you can see from checks - we run it in JDK 11 as well.
The old code was also working for versions lower than 11, which we don't need to support now, as 11 is the lowest we support

Copy link
Contributor

Choose a reason for hiding this comment

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

Right, but my confusion is as to why the check here is for Java 17 and lower, not 11. Isn't this code still relevant for Java 11 til 16?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess that was my mistake as I added that when trying to make it work with JDK 17, this the naming. But it seems like that works fine for JDK 11 as well. At least it runs fine on my local and on CI.

Copy link
Contributor

Choose a reason for hiding this comment

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

Okay, let's merge this and hopefully CI coverage is sufficient. If not, we revert the removal when users do run into it after all.

@TimvdLippe TimvdLippe merged commit 35beeb7 into mockito:release/2.x Jun 17, 2025
5 checks passed
@jozic jozic deleted the decrease-deprecated-usages branch June 17, 2025 10:12
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.

2 participants