Upgrade java mockito from version 1.x to version 5 (#2781)

* use mockito 5

* remove unnecessary flag

* fix java annotation test file name
diff --git a/lib/java/gradle.properties b/lib/java/gradle.properties
index 917b24b..4256dbd 100644
--- a/lib/java/gradle.properties
+++ b/lib/java/gradle.properties
@@ -31,7 +31,7 @@
 servlet.version=4.0.1
 tomcat.embed.version=9.0.43
 junit.version=5.8.2
-mockito.version=1.10.19
+mockito.version=5.3.0
 javax.annotation.version=1.3.2
 commons-lang3.version=3.12.0
 
diff --git a/lib/java/gradle/environment.gradle b/lib/java/gradle/environment.gradle
index f25f3e6..cb61c05 100644
--- a/lib/java/gradle/environment.gradle
+++ b/lib/java/gradle/environment.gradle
@@ -68,6 +68,6 @@
     implementation "org.apache.commons:commons-lang3:${commonsLang3Version}"
 
     testImplementation "org.junit.jupiter:junit-jupiter:${junitVersion}"
-    testImplementation "org.mockito:mockito-all:${mockitoVersion}"
+    testImplementation "org.mockito:mockito-core:${mockitoVersion}"
     testRuntimeOnly "org.slf4j:slf4j-log4j12:${slf4jVersion}"
 }
diff --git a/lib/java/gradle/generateTestThrift.gradle b/lib/java/gradle/generateTestThrift.gradle
index 0506aa6..301812f 100644
--- a/lib/java/gradle/generateTestThrift.gradle
+++ b/lib/java/gradle/generateTestThrift.gradle
@@ -88,7 +88,7 @@
     thriftCompile(it, 'EnumContainersTest.thrift')
     thriftCompile(it, 'JavaBinaryDefault.thrift')
     thriftCompile(it, 'VoidMethExceptionsTest.thrift')
-    thriftCompile(it, 'AnnotationTest.thrift')
+    thriftCompile(it, 'JavaAnnotationTest.thrift')
     thriftCompile(it, 'partial/thrift_test_schema.thrift')
 }
 
diff --git a/lib/java/gradle/unitTests.gradle b/lib/java/gradle/unitTests.gradle
index 1e7481b..4f06fcf 100644
--- a/lib/java/gradle/unitTests.gradle
+++ b/lib/java/gradle/unitTests.gradle
@@ -65,8 +65,6 @@
         outputs.upToDateWhen { false }
     }
 
-    // This is required for Mockito to run under Java 17
-    jvmArgs '--add-opens=java.base/java.lang=ALL-UNNAMED'
     include '**/Test*.class'
     exclude '**/Test*\$*.class'
 
diff --git a/lib/java/src/test/java/org/apache/thrift/TestMultiplexedProcessor.java b/lib/java/src/test/java/org/apache/thrift/TestMultiplexedProcessor.java
index efd1882..b3c4cb2 100644
--- a/lib/java/src/test/java/org/apache/thrift/TestMultiplexedProcessor.java
+++ b/lib/java/src/test/java/org/apache/thrift/TestMultiplexedProcessor.java
@@ -20,7 +20,7 @@
 package org.apache.thrift;
 
 import static org.junit.jupiter.api.Assertions.assertThrows;
-import static org.mockito.Matchers.any;
+import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;