Merge remote-tracking branch 'MSTR/master' into 3x.merge

Signed-off-by: jansupol <jan.supol@oracle.com>
diff --git a/.travis.yml b/.travis.yml
index f746552..62d6276 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -10,7 +10,7 @@
 jdk:
   - oraclejdk8
   - openjdk11
-  - openjdk15
+  - openjdk16
 
 cache:
   directories:
diff --git a/connectors/jdk-connector/pom.xml b/connectors/jdk-connector/pom.xml
index 48a2a34..15b8cdc 100644
--- a/connectors/jdk-connector/pom.xml
+++ b/connectors/jdk-connector/pom.xml
@@ -87,6 +87,28 @@
                 <surefire.security.argline>-Djdk.tls.server.protocols=TLSv1.2</surefire.security.argline>
             </properties>
         </profile>
+        <profile>
+            <id>disable_tls1and11</id>
+            <!-- TLS 1 and TLS 1.1 are disabled for JDK 16 -->
+            <activation>
+                <jdk>[16,)</jdk>
+            </activation>
+            <build>
+                <plugins>
+                    <plugin>
+                        <groupId>org.apache.maven.plugins</groupId>
+                        <artifactId>maven-surefire-plugin</artifactId>
+                        <configuration>
+                            <reuseForks>false</reuseForks>
+                            <excludes>
+                                <exclude>**/SslFilterTLS1Test.java</exclude>
+                                <exclude>**/SslFilterTLS11Test.java</exclude>
+                            </excludes>
+                        </configuration>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
     </profiles>
 
 </project>
diff --git a/core-client/pom.xml b/core-client/pom.xml
index 887b305..7639c19 100644
--- a/core-client/pom.xml
+++ b/core-client/pom.xml
@@ -119,6 +119,14 @@
         </dependency>
 
         <dependency>
+            <!-- not to warn about missing activation -->
+            <groupId>com.sun.activation</groupId>
+            <artifactId>jakarta.activation</artifactId>
+            <version>${jakarta.activation.version}</version>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>
             <scope>test</scope>
@@ -132,7 +140,7 @@
 
         <dependency>
             <groupId>org.mockito</groupId>
-            <artifactId>mockito-all</artifactId>
+            <artifactId>mockito-core</artifactId>
             <scope>test</scope>
         </dependency>
 
diff --git a/core-client/src/test/java/org/glassfish/jersey/client/ClientRequestTest.java b/core-client/src/test/java/org/glassfish/jersey/client/ClientRequestTest.java
index 7011672..b432d91 100644
--- a/core-client/src/test/java/org/glassfish/jersey/client/ClientRequestTest.java
+++ b/core-client/src/test/java/org/glassfish/jersey/client/ClientRequestTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2021 Oracle and/or its affiliates. All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v. 2.0, which is available at
@@ -32,14 +32,14 @@
 import org.glassfish.jersey.message.MessageBodyWorkers;
 
 import org.hamcrest.core.Is;
+import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
-import org.junit.runner.RunWith;
 import org.mockito.Mock;
 import org.mockito.Mockito;
 import org.mockito.MockitoAnnotations;
-import org.mockito.runners.MockitoJUnitRunner;
+
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNull;
@@ -53,7 +53,7 @@
  *
  * @author Marek Potociar
  */
-@RunWith(MockitoJUnitRunner.class)
+//@RunWith(MockitoJUnitRunner.class)
 public class ClientRequestTest {
 
     @Mock
@@ -61,9 +61,16 @@
     @Mock
     private GenericType<?> entityType;
 
+    private AutoCloseable mockito;
+
     @Before
     public void initMocks() {
-        MockitoAnnotations.initMocks(this);
+        mockito = MockitoAnnotations.openMocks(this);
+    }
+
+    @After
+    public void closeMocks() throws Exception {
+        mockito.close();
     }
 
     /**
diff --git a/core-common/pom.xml b/core-common/pom.xml
index 8d7d508..44a3801 100644
--- a/core-common/pom.xml
+++ b/core-common/pom.xml
@@ -218,7 +218,7 @@
         </dependency>
         <dependency>
             <groupId>org.mockito</groupId>
-            <artifactId>mockito-all</artifactId>
+            <artifactId>mockito-core</artifactId>
             <scope>test</scope>
         </dependency>
         <dependency>
diff --git a/core-common/src/test/java/org/glassfish/jersey/logging/LoggingInterceptorTest.java b/core-common/src/test/java/org/glassfish/jersey/logging/LoggingInterceptorTest.java
index f12e2eb..796faec 100644
--- a/core-common/src/test/java/org/glassfish/jersey/logging/LoggingInterceptorTest.java
+++ b/core-common/src/test/java/org/glassfish/jersey/logging/LoggingInterceptorTest.java
@@ -150,8 +150,8 @@
 
     private Answer<?> chunk(int size, char filler) {
         return invocation -> {
-            byte[] buf = invocation.getArgumentAt(0, byte[].class);
-            int offset = invocation.getArgumentAt(1, Integer.class);
+            byte[] buf = invocation.getArgument(0, byte[].class);
+            int offset = invocation.getArgument(1, Integer.class);
             Arrays.fill(buf, offset, offset + size, (byte) filler);
             return size;
         };
diff --git a/core-common/src/test/resources/surefire.policy b/core-common/src/test/resources/surefire.policy
index 530db3c..850e4b3 100644
--- a/core-common/src/test/resources/surefire.policy
+++ b/core-common/src/test/resources/surefire.policy
@@ -38,6 +38,7 @@
   permission java.lang.RuntimePermission "accessDeclaredMembers";
   permission java.lang.RuntimePermission "accessClassInPackage.sun.reflect";
   permission java.lang.RuntimePermission "reflectionFactoryAccess";
+  permission java.lang.RuntimePermission "getProtectionDomain"; // mockito for JDK<16
 };
 
 grant codebase "file:${project.build.directory}/classes/-" {
diff --git a/examples/helloworld-spring-annotations/pom.xml b/examples/helloworld-spring-annotations/pom.xml
index 0d43098..2bbe96c 100644
--- a/examples/helloworld-spring-annotations/pom.xml
+++ b/examples/helloworld-spring-annotations/pom.xml
@@ -32,13 +32,13 @@
         </dependency>
         <dependency>
             <groupId>org.glassfish.jersey.ext</groupId>
-            <artifactId>jersey-spring4</artifactId>
+            <artifactId>jersey-spring5</artifactId>
             <version>${project.version}</version>
         </dependency>
         <dependency>
             <groupId>org.springframework</groupId>
             <artifactId>spring-web</artifactId>
-            <version>${spring4.version}</version>
+            <version>${spring5.version}</version>
             <scope>compile</scope>
         </dependency>
         <dependency>
diff --git a/examples/osgi-helloworld-webapp/functional-test/src/test/java/org/glassfish/jersey/examples/helloworld/test/AbstractWebAppTest.java b/examples/osgi-helloworld-webapp/functional-test/src/test/java/org/glassfish/jersey/examples/helloworld/test/AbstractWebAppTest.java
index b8ae63c..4817e60 100644
--- a/examples/osgi-helloworld-webapp/functional-test/src/test/java/org/glassfish/jersey/examples/helloworld/test/AbstractWebAppTest.java
+++ b/examples/osgi-helloworld-webapp/functional-test/src/test/java/org/glassfish/jersey/examples/helloworld/test/AbstractWebAppTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2021 Oracle and/or its affiliates. All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Distribution License v. 1.0, which is available at
@@ -135,7 +135,7 @@
                 // jakarta.annotation must go first!
                 mavenBundle().groupId("jakarta.annotation").artifactId("jakarta.annotation-api").versionAsInProject(),
                 // pax exam dependencies
-                mavenBundle("org.ops4j.pax.url", "pax-url-mvn"),
+                // mavenBundle("org.ops4j.pax.url", "pax-url-mvn"),
                 junitBundles(), // adds junit classes to the OSGi context
 
                 // HK2
diff --git a/examples/osgi-http-service/functional-test/pom.xml b/examples/osgi-http-service/functional-test/pom.xml
index 32cbea4..025527c 100644
--- a/examples/osgi-http-service/functional-test/pom.xml
+++ b/examples/osgi-http-service/functional-test/pom.xml
@@ -99,6 +99,12 @@
             <artifactId>pax-web-extender-war</artifactId>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>org.ops4j.pax.url</groupId>
+            <artifactId>pax-url-mvn</artifactId>
+            <version>1.3.7</version>
+            <scope>test</scope>
+        </dependency>
 
         <dependency>
             <groupId>junit</groupId>
diff --git a/examples/osgi-http-service/functional-test/src/test/java/org/glassfish/jersey/examples/osgihttpservice/test/AbstractHttpServiceTest.java b/examples/osgi-http-service/functional-test/src/test/java/org/glassfish/jersey/examples/osgihttpservice/test/AbstractHttpServiceTest.java
index 497e8c0..ad4d28a 100644
--- a/examples/osgi-http-service/functional-test/src/test/java/org/glassfish/jersey/examples/osgihttpservice/test/AbstractHttpServiceTest.java
+++ b/examples/osgi-http-service/functional-test/src/test/java/org/glassfish/jersey/examples/osgihttpservice/test/AbstractHttpServiceTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2021 Oracle and/or its affiliates. All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Distribution License v. 1.0, which is available at
@@ -100,7 +100,7 @@
                 // jakarta.annotation has to go first!
                 mavenBundle().groupId("jakarta.annotation").artifactId("jakarta.annotation-api").versionAsInProject(),
 
-                mavenBundle("org.ops4j.pax.url", "pax-url-mvn"),
+                mavenBundle("org.ops4j.pax.url", "pax-url-mvn").versionAsInProject(),
                 junitBundles(),
 
                 // HK2
diff --git a/examples/reload/src/main/java/org/glassfish/jersey/examples/reload/App.java b/examples/reload/src/main/java/org/glassfish/jersey/examples/reload/App.java
index 5d527b6..10441f3 100644
--- a/examples/reload/src/main/java/org/glassfish/jersey/examples/reload/App.java
+++ b/examples/reload/src/main/java/org/glassfish/jersey/examples/reload/App.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2019 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2021 Oracle and/or its affiliates. All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Distribution License v. 1.0, which is available at
@@ -15,6 +15,7 @@
 import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStreamReader;
+import java.lang.reflect.Field;
 import java.net.URI;
 import java.nio.file.FileSystems;
 import java.nio.file.Path;
@@ -40,8 +41,6 @@
 
 import org.glassfish.grizzly.http.server.HttpServer;
 
-import com.sun.nio.file.SensitivityWatchEventModifier;
-
 /**
  * Reload example application.
  * <p/>
@@ -116,7 +115,7 @@
                     new WatchEvent.Kind[]{
                             StandardWatchEventKinds.ENTRY_MODIFY
                     },
-                    SensitivityWatchEventModifier.HIGH);
+                    /* SensitivityWatchEventModifier.HIGH */ getWatchEventModifiers());
         }
 
         private void reloadApp(final File configFile) {
@@ -125,6 +124,21 @@
             App.container.reload(rc);
         }
 
+        /**
+         * @return sensitivity watch event modifier
+         */
+        private static WatchEvent.Modifier[] getWatchEventModifiers() {
+            String className = "com.sun.nio.file.SensitivityWatchEventModifier";
+            try {
+                Class<?> c = Class.forName(className);
+                Field f = c.getField("HIGH");
+                WatchEvent.Modifier modifier = WatchEvent.Modifier.class.cast(f.get(c));
+                return new WatchEvent.Modifier[] {modifier};
+            } catch (Exception e) {
+                return new WatchEvent.Modifier[] {};
+            }
+        }
+
     }
 
     private static ResourceConfig createResourceConfig(File configFile) {
diff --git a/ext/bean-validation/src/main/java/org/glassfish/jersey/server/validation/internal/ValidationInterceptorExecutor.java b/ext/bean-validation/src/main/java/org/glassfish/jersey/server/validation/internal/ValidationInterceptorExecutor.java
index ebeb3cd..7309f2d 100644
--- a/ext/bean-validation/src/main/java/org/glassfish/jersey/server/validation/internal/ValidationInterceptorExecutor.java
+++ b/ext/bean-validation/src/main/java/org/glassfish/jersey/server/validation/internal/ValidationInterceptorExecutor.java
@@ -82,8 +82,8 @@
     @Override
     public void setArgs(final Object[] args) {
         if (args.length == this.args.length) {
-          // Replace the original arguments with the new ones
-          System.arraycopy(args, 0, this.args, 0, args.length);
+            // Replace the original arguments with the new ones
+            System.arraycopy(args, 0, this.args, 0, args.length);
         } else {
             this.args = args;
         }
diff --git a/ext/cdi/jersey-cdi1x-validation/src/main/java/org/glassfish/jersey/ext/cdi1x/validation/internal/CdiInterceptorWrapper.java b/ext/cdi/jersey-cdi1x-validation/src/main/java/org/glassfish/jersey/ext/cdi1x/validation/internal/CdiInterceptorWrapper.java
index 835e0ca..7219c48 100644
--- a/ext/cdi/jersey-cdi1x-validation/src/main/java/org/glassfish/jersey/ext/cdi1x/validation/internal/CdiInterceptorWrapper.java
+++ b/ext/cdi/jersey-cdi1x-validation/src/main/java/org/glassfish/jersey/ext/cdi1x/validation/internal/CdiInterceptorWrapper.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2021 Oracle and/or its affiliates. All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v. 2.0, which is available at
diff --git a/ext/cdi/jersey-cdi1x-validation/src/main/java/org/glassfish/jersey/ext/cdi1x/validation/internal/CdiInterceptorWrapperExtension.java b/ext/cdi/jersey-cdi1x-validation/src/main/java/org/glassfish/jersey/ext/cdi1x/validation/internal/CdiInterceptorWrapperExtension.java
index fd77465..a02e829 100644
--- a/ext/cdi/jersey-cdi1x-validation/src/main/java/org/glassfish/jersey/ext/cdi1x/validation/internal/CdiInterceptorWrapperExtension.java
+++ b/ext/cdi/jersey-cdi1x-validation/src/main/java/org/glassfish/jersey/ext/cdi1x/validation/internal/CdiInterceptorWrapperExtension.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2021 Oracle and/or its affiliates. All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v. 2.0, which is available at
@@ -178,10 +178,6 @@
     }
 
     /* package */ Cache<Class<?>, Boolean> getJaxRsResourceCache() {
-        /* CDI injection hack */
-        if (jaxRsResourceCache == null) {
-            jaxRsResourceCache = new Cache<>(clazz -> Resource.from(clazz) != null);
-        }
         return jaxRsResourceCache;
     }
 }
diff --git a/ext/microprofile/mp-rest-client/pom.xml b/ext/microprofile/mp-rest-client/pom.xml
index c3c6021..e90137c 100644
--- a/ext/microprofile/mp-rest-client/pom.xml
+++ b/ext/microprofile/mp-rest-client/pom.xml
@@ -77,7 +77,7 @@
         <dependency>
             <groupId>jakarta.enterprise</groupId>
             <artifactId>jakarta.enterprise.cdi-api</artifactId>
-<!--            <version>2.0</version>-->
+            <scope>provided</scope>
         </dependency>
         <dependency>
             <groupId>org.glassfish</groupId>
diff --git a/ext/microprofile/mp-rest-client/src/main/java/org/glassfish/jersey/microprofile/restclient/ReflectionUtil.java b/ext/microprofile/mp-rest-client/src/main/java/org/glassfish/jersey/microprofile/restclient/ReflectionUtil.java
index a39df56..1acfa66 100644
--- a/ext/microprofile/mp-rest-client/src/main/java/org/glassfish/jersey/microprofile/restclient/ReflectionUtil.java
+++ b/ext/microprofile/mp-rest-client/src/main/java/org/glassfish/jersey/microprofile/restclient/ReflectionUtil.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2019, 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2019, 2021 Oracle and/or its affiliates. All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v. 2.0, which is available at
@@ -16,8 +16,15 @@
 
 package org.glassfish.jersey.microprofile.restclient;
 
+import org.glassfish.jersey.internal.util.JdkVersion;
+import org.glassfish.jersey.internal.util.collection.LazyUnsafeValue;
+import org.glassfish.jersey.internal.util.collection.UnsafeValue;
+import org.glassfish.jersey.internal.util.collection.Values;
+
 import java.lang.invoke.MethodHandles;
 import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
 import java.lang.reflect.Proxy;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
@@ -47,10 +54,9 @@
                 Thread.currentThread().getContextClassLoader(),
                 new Class[] {restClientClass},
                 (proxy, m, args) -> {
-                    Constructor<MethodHandles.Lookup> constructor = MethodHandles.Lookup.class
-                            .getDeclaredConstructor(Class.class);
-                    constructor.setAccessible(true);
-                    return constructor.newInstance(restClientClass)
+                    final MethodHandles.Lookup lookup = JdkVersion.getJdkVersion().getMajor() > 1
+                            ? privateLookupJDK11(restClientClass) : privateLookupJDK8(restClientClass);
+                    return lookup
                             .in(restClientClass)
                             .unreflectSpecial(m, restClientClass)
                             .bindTo(proxy)
@@ -58,4 +64,21 @@
                 }));
     }
 
+    private static LazyUnsafeValue<Method, Exception> privateLookup = Values.lazy((UnsafeValue<Method, Exception>)
+        () -> MethodHandles.class.getMethod("privateLookupIn", Class.class, MethodHandles.Lookup.class)
+    );
+
+    private static MethodHandles.Lookup privateLookupJDK11(Class<?> restClientClass)
+            throws Exception {
+        return (MethodHandles.Lookup) privateLookup.get().invoke(null, restClientClass, MethodHandles.lookup());
+    }
+
+    private static MethodHandles.Lookup privateLookupJDK8(Class<?> restClientClass)
+            throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
+        final Constructor<MethodHandles.Lookup> constructor = MethodHandles.Lookup.class
+                .getDeclaredConstructor(Class.class);
+        constructor.setAccessible(true); //JEP 396 issue
+        return constructor.newInstance(restClientClass);
+    }
+
 }
diff --git a/ext/spring4/pom.xml b/ext/spring4/pom.xml
index 9e7b5c7..50fea09 100644
--- a/ext/spring4/pom.xml
+++ b/ext/spring4/pom.xml
@@ -203,5 +203,23 @@
                 </plugins>
             </build>
         </profile>
+        <profile>
+            <id>ignore.on.jdk16</id>
+            <!-- Spring 4 does not support JDK 16 at the moment, and it is superseded by Spring 5.2-5.3 -->
+            <activation>
+                <jdk>[16,)</jdk>
+            </activation>
+            <build>
+                <plugins>
+                    <plugin>
+                        <groupId>org.apache.maven.plugins</groupId>
+                        <artifactId>maven-surefire-plugin</artifactId>
+                        <configuration>
+                            <skipTests>true</skipTests>
+                        </configuration>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
     </profiles>
 </project>
diff --git a/incubator/declarative-linking/pom.xml b/incubator/declarative-linking/pom.xml
index c7cdc27..0fa4aa0 100644
--- a/incubator/declarative-linking/pom.xml
+++ b/incubator/declarative-linking/pom.xml
@@ -128,6 +128,24 @@
                 </dependency>
             </dependencies>
         </profile>
+        <profile>
+            <id>InaccessibleObjectException</id>
+            <activation><jdk>[16,)</jdk></activation>
+            <build>
+                <plugins>
+                    <plugin>
+                        <groupId>org.apache.maven.plugins</groupId>
+                        <artifactId>maven-surefire-plugin</artifactId>
+                        <configuration>
+                            <argLine>
+                                --add-opens java.base/java.util.zip=ALL-UNNAMED
+                                --add-opens java.base/java.util=ALL-UNNAMED
+                            </argLine>
+                        </configuration>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
     </profiles>
 
     <build>
diff --git a/inject/cdi2-se/src/main/java/org/glassfish/jersey/inject/cdi/se/injector/JerseyInjectionTarget.java b/inject/cdi2-se/src/main/java/org/glassfish/jersey/inject/cdi/se/injector/JerseyInjectionTarget.java
index 879e0a8..8073f4c 100644
--- a/inject/cdi2-se/src/main/java/org/glassfish/jersey/inject/cdi/se/injector/JerseyInjectionTarget.java
+++ b/inject/cdi2-se/src/main/java/org/glassfish/jersey/inject/cdi/se/injector/JerseyInjectionTarget.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2021 Oracle and/or its affiliates. All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v. 2.0, which is available at
diff --git a/inject/hk2/src/test/java/org/glassfish/jersey/inject/hk2/SupplierProxyTest.java b/inject/hk2/src/test/java/org/glassfish/jersey/inject/hk2/SupplierProxyTest.java
index 379775d..2604d27 100644
--- a/inject/hk2/src/test/java/org/glassfish/jersey/inject/hk2/SupplierProxyTest.java
+++ b/inject/hk2/src/test/java/org/glassfish/jersey/inject/hk2/SupplierProxyTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, 2018 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2021 Oracle and/or its affiliates. All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v. 2.0, which is available at
@@ -58,8 +58,8 @@
         });
 
         Conversation conversation = injectionManager.getInstance(Conversation.class);
-        assertTrue(conversation.greeting.getClass().getName().startsWith("com.sun.proxy"));
-        assertFalse(conversation.greetingSupplier.getClass().getName().startsWith("com.sun.proxy"));
+        assertTrue(conversation.greeting.getClass().getName().contains(".proxy"));
+        assertFalse(conversation.greetingSupplier.getClass().getName().contains(".proxy"));
         injectionManager.shutdown();
     }
 
@@ -78,8 +78,9 @@
         });
 
         Conversation conversation = injectionManager.getInstance(Conversation.class);
-        assertTrue(conversation.greeting.getClass().getName().startsWith("com.sun.proxy"));
-        assertFalse(conversation.greetingSupplier.getClass().getName().startsWith("com.sun.proxy"));
+
+        assertTrue(conversation.greeting.getClass().getName().contains(".proxy"));
+        assertFalse(conversation.greetingSupplier.getClass().getName().contains(".proxy"));
         injectionManager.shutdown();
     }
 }
diff --git a/pom.xml b/pom.xml
index 52388a6..36bf2f4 100644
--- a/pom.xml
+++ b/pom.xml
@@ -629,7 +629,7 @@
                 <plugin>
                     <groupId>org.apache.maven.plugins</groupId>
                     <artifactId>maven-war-plugin</artifactId>
-                    <version>2.4</version>
+                    <version>3.3.1</version>
                     <configuration>
                         <failOnMissingWebXml>false</failOnMissingWebXml>
                     </configuration>
@@ -1517,6 +1517,12 @@
             </dependency>
 
             <dependency>
+                <groupId>jakarta.enterprise</groupId>
+                <artifactId>jakarta.enterprise.cdi-api</artifactId>
+                <version>${cdi2.api.version}</version>
+            </dependency>
+
+            <dependency>
                 <groupId>jakarta.transaction</groupId>
                 <artifactId>jakarta.transaction-api</artifactId>
                 <version>${jta.api.version}</version>
@@ -1877,6 +1883,11 @@
                 <artifactId>weld-se-core</artifactId>
                 <version>${weld.version}</version>
             </dependency>
+            <dependency>
+                <groupId>org.jboss.weld.servlet</groupId>
+                <artifactId>weld-servlet</artifactId>
+                <version>${weld.version}</version>
+            </dependency>
 
             <dependency>
                 <groupId>jakarta.validation</groupId>
@@ -1953,7 +1964,7 @@
             </dependency>
             <dependency>
                 <groupId>org.mockito</groupId>
-                <artifactId>mockito-all</artifactId>
+                <artifactId>mockito-core</artifactId>
                 <version>${mockito.version}</version>
                 <scope>test</scope>
             </dependency>
@@ -1967,7 +1978,7 @@
             <dependency>
                 <groupId>org.apache.felix</groupId>
                 <artifactId>org.apache.felix.framework</artifactId>
-                <version>6.0.3</version>
+                <version>7.0.0</version>
                 <scope>test</scope>
             </dependency>
 
@@ -2077,7 +2088,7 @@
         <jmockit.version>1.44</jmockit.version>
         <junit5.version>5.6.0</junit5.version>
         <kryo.version>4.0.1</kryo.version>
-        <mockito.version>1.10.19</mockito.version>
+        <mockito.version>3.9.0</mockito.version> <!-- CQ 17673 -->
         <mustache.version>0.8.17</mustache.version>
         <netty.version>4.1.43.Final</netty.version>
         <nexus-staging.mvn.plugin.version>1.6.7</nexus-staging.mvn.plugin.version>
diff --git a/test-framework/maven/custom-enforcer-rules/pom.xml b/test-framework/maven/custom-enforcer-rules/pom.xml
index 0db1348..8956e02 100644
--- a/test-framework/maven/custom-enforcer-rules/pom.xml
+++ b/test-framework/maven/custom-enforcer-rules/pom.xml
@@ -46,7 +46,7 @@
         <dependency>
             <groupId>commons-io</groupId>
             <artifactId>commons-io</artifactId>
-            <version>2.2</version>
+            <version>2.7</version>
         </dependency>
 
         <dependency>
diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/wadl/WadlResourceTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/wadl/WadlResourceTest.java
index 59748c8..7237128 100644
--- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/wadl/WadlResourceTest.java
+++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/wadl/WadlResourceTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2021 Oracle and/or its affiliates. All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v. 2.0, which is available at
@@ -1237,8 +1237,13 @@
             final Resource resource =
                     (Resource) application.getResources().get(0).getResource().get(0).getMethodOrResource().get(0);
 
-            assertThatMethodContainsRR(resource, "myMethod1", 0);
-            assertThatMethodContainsRR(resource, "myMethod2", 1);
+            try {
+                assertThatMethodContainsRR(resource, "myMethod1", 0);
+                assertThatMethodContainsRR(resource, "myMethod2", 1);
+            } catch (AssertionError e) {
+                assertThatMethodContainsRR(resource, "myMethod1", 1);
+                assertThatMethodContainsRR(resource, "myMethod2", 0);
+            }
 
         }
 
diff --git a/tests/integration/cdi-integration/cdi-beanvalidation-webapp/pom.xml b/tests/integration/cdi-integration/cdi-beanvalidation-webapp/pom.xml
index f590678..18950ce 100644
--- a/tests/integration/cdi-integration/cdi-beanvalidation-webapp/pom.xml
+++ b/tests/integration/cdi-integration/cdi-beanvalidation-webapp/pom.xml
@@ -50,7 +50,7 @@
                 <!-- Remove ancient jakarta.el that causes problems with Hibernate -->
                 <exclusion>
                     <groupId>jakarta.el</groupId>
-                    <artifactId>el-api</artifactId>
+                    <artifactId>jakarta.el-api</artifactId>
                 </exclusion>
             </exclusions>
         </dependency>
diff --git a/tests/integration/cdi-integration/cdi-beanvalidation-webapp/src/main/java/org/glassfish/jersey/tests/cdi/bv/CdiValidationInterceptor.java b/tests/integration/cdi-integration/cdi-beanvalidation-webapp/src/main/java/org/glassfish/jersey/tests/cdi/bv/CdiValidationInterceptor.java
index 5fe2dac..88ab648 100644
--- a/tests/integration/cdi-integration/cdi-beanvalidation-webapp/src/main/java/org/glassfish/jersey/tests/cdi/bv/CdiValidationInterceptor.java
+++ b/tests/integration/cdi-integration/cdi-beanvalidation-webapp/src/main/java/org/glassfish/jersey/tests/cdi/bv/CdiValidationInterceptor.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2021 Oracle and/or its affiliates. All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v. 2.0, which is available at
diff --git a/tests/integration/cdi-integration/context-inject-on-server/pom.xml b/tests/integration/cdi-integration/context-inject-on-server/pom.xml
index a5775da..db43dcc 100644
--- a/tests/integration/cdi-integration/context-inject-on-server/pom.xml
+++ b/tests/integration/cdi-integration/context-inject-on-server/pom.xml
@@ -44,7 +44,6 @@
         <dependency>
             <groupId>jakarta.enterprise</groupId>
             <artifactId>jakarta.enterprise.cdi-api</artifactId>
-            <version>${cdi.api.version}</version>
             <scope>provided</scope>
         </dependency>
         <dependency>
@@ -65,8 +64,6 @@
         <dependency>
             <groupId>org.jboss.weld.se</groupId>
             <artifactId>weld-se-core</artifactId>
-            <!-- latest 3.x -->
-            <version>${weld.version}</version>
             <scope>test</scope>
         </dependency>
         <dependency>
diff --git a/tests/integration/jersey-4003/pom.xml b/tests/integration/jersey-4003/pom.xml
index 4959480..4c4d4f1 100644
--- a/tests/integration/jersey-4003/pom.xml
+++ b/tests/integration/jersey-4003/pom.xml
@@ -39,7 +39,7 @@
 
         <dependency>
             <groupId>org.mockito</groupId>
-            <artifactId>mockito-all</artifactId>
+            <artifactId>mockito-core</artifactId>
             <scope>test</scope>
         </dependency>
     </dependencies>
diff --git a/tests/integration/jersey-4697/pom.xml b/tests/integration/jersey-4697/pom.xml
index 88e62a1..3251401 100644
--- a/tests/integration/jersey-4697/pom.xml
+++ b/tests/integration/jersey-4697/pom.xml
@@ -37,7 +37,7 @@
         </dependency>
         <dependency>
             <groupId>org.mockito</groupId>
-            <artifactId>mockito-all</artifactId>
+            <artifactId>mockito-core</artifactId>
             <scope>test</scope>
         </dependency>
     </dependencies>
diff --git a/tests/integration/microprofile/rest-client/pom.xml b/tests/integration/microprofile/rest-client/pom.xml
index a682366..6d3b5e8 100644
--- a/tests/integration/microprofile/rest-client/pom.xml
+++ b/tests/integration/microprofile/rest-client/pom.xml
@@ -40,7 +40,6 @@
         <dependency>
             <groupId>jakarta.enterprise</groupId>
             <artifactId>jakarta.enterprise.cdi-api</artifactId>
-<!--            <version>2.0</version>-->
         </dependency>
         <dependency>
             <groupId>org.jboss.weld.se</groupId>
@@ -52,6 +51,12 @@
             <artifactId>smallrye-config</artifactId>
             <version>1.3.6</version>
             <scope>test</scope>
+            <exclusions>
+                <exclusion>
+                    <groupId>javax.enterprise</groupId>
+                    <artifactId>cdi-api</artifactId>
+                </exclusion>
+            </exclusions>
         </dependency>
         <dependency>
             <groupId>org.eclipse.microprofile.rest.client</groupId>
@@ -90,7 +95,7 @@
         <dependency>
             <groupId>org.jboss.arquillian.container</groupId>
             <artifactId>arquillian-weld-embedded</artifactId>
-            <version>2.0.1.Final</version>
+            <version>2.1.0.Final</version>
             <scope>test</scope>
         </dependency>
         <dependency>
diff --git a/tests/integration/spring4/pom.xml b/tests/integration/spring4/pom.xml
index 6a2700a..bbc0cc0 100644
--- a/tests/integration/spring4/pom.xml
+++ b/tests/integration/spring4/pom.xml
@@ -144,5 +144,23 @@
                 </plugins>
             </build>
         </profile>
+        <profile>
+            <id>ignore.on.jdk16</id>
+            <!-- Spring 4 does not support JDK 16 at the moment, and it is superseded by Spring 5.2-5.3 -->
+            <activation>
+                <jdk>[16,)</jdk>
+            </activation>
+            <build>
+                <plugins>
+                    <plugin>
+                        <groupId>org.apache.maven.plugins</groupId>
+                        <artifactId>maven-failsafe-plugin</artifactId>
+                        <configuration>
+                            <skipTests>true</skipTests>
+                        </configuration>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
     </profiles>
 </project>
diff --git a/tests/stress/src/test/java/org/glassfish/jersey/server/internal/monitoring/MultiThreadingAggregatedReservoirTest.java b/tests/stress/src/test/java/org/glassfish/jersey/server/internal/monitoring/MultiThreadingAggregatedReservoirTest.java
index 973d453..eed30f7 100644
--- a/tests/stress/src/test/java/org/glassfish/jersey/server/internal/monitoring/MultiThreadingAggregatedReservoirTest.java
+++ b/tests/stress/src/test/java/org/glassfish/jersey/server/internal/monitoring/MultiThreadingAggregatedReservoirTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2021 Oracle and/or its affiliates. All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v. 2.0, which is available at
@@ -51,7 +51,7 @@
     /*
      * Note that more than 5 seconds may require more than 1G heap memory.
      */
-    private static final int TEST_DURATION_MILLIS = 5_000;
+    private static final int TEST_DURATION_MILLIS = 1_000;
     private static final int SHUTDOWN_TIMEOUT_SECONDS = 120;
     private static final double DELTA = 0.0001;