-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Reflection compatibility issues with Java 9 #1295
Labels
Comments
Please use mockito-core version 2.13.0 which should not have this issue.
…On Mon, 22 Jan 2018, 11:15 marat-gainullin, ***@***.***> wrote:
The following warnings occur while runnting tests on Java 9:
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by
org.mockito.cglib.core.ReflectUtils$2
(file:/C:/Users/mg/.gradle/caches/modules-2/files-2.1/org.mockito/mockito-all/2.0.2-beta/3e24f450275812fb354d29a58b66b8f26e13002f/mockito-all-2.0.2-beta.jar)
to method
java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
WARNING: Please consider reporting this to the maintainers of
org.mockito.cglib.core.ReflectUtils$2
WARNING: Use --illegal-access=warn to enable warnings of further illegal
reflective access operations
WARNING: All illegal access operations will be denied in a future release
when running th following example:
package com.mockitotest;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.mockito.Mockito;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Collections;
import java.util.Set;
public class MockitoJava9ExampleTest {
private static volatile ServletConfig config;
@BeforeClass
public static void setup() {
ServletContext servletContext = Mockito.mock(ServletContext.class);
Mockito.when(servletContext.getServletContextName()).thenReturn("mockito-java9");
Mockito.when(servletContext.getInitParameterNames()).thenReturn(Collections.enumeration(Set.of(
"p1",
"p2",
"p3",
"p4"
)));
Mockito.when(servletContext.getInitParameter("p1")).thenReturn("v1");
Mockito.when(servletContext.getInitParameter("p2")).thenReturn("v2");
Mockito.when(servletContext.getInitParameter("p3")).thenReturn("v3");
Mockito.when(servletContext.getInitParameter("p4")).thenReturn("v4");
Mockito.when(servletContext.getInitParameter("p5")).thenReturn("v5");
config = Mockito.mock(ServletConfig.class);
Mockito.when(config.getServletContext()).thenReturn(servletContext);
}
@afterclass
public static void tearDown() {
config = null;
}
@test
public void runOnlyTest() {
Mockito.mock(HttpServletRequest.class);
Mockito.mock(HttpServletResponse.class);
}
}
Environment :
Windows 10, Java 9, Mockito dependency:
'org.mockito:mockito-all:2.0.2-beta'
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#1295>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AFrDb4DlIe0ebWcRb5GxPH7nKIxnO4bbks5tNF-ugaJpZM4Rmbv6>
.
|
Closing per above comment. Feel free to reopen if you are still encountering this issue with the latest version of Mockito. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The following warnings occur while runnting tests on Java 9:
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.mockito.cglib.core.ReflectUtils$2 (file:/C:/Users/mg/.gradle/caches/modules-2/files-2.1/org.mockito/mockito-all/2.0.2-beta/3e24f450275812fb354d29a58b66b8f26e13002f/mockito-all-2.0.2-beta.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
WARNING: Please consider reporting this to the maintainers of org.mockito.cglib.core.ReflectUtils$2
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
when running th following example:
Environment :
Windows 10, Java 9, Mockito dependency: 'org.mockito:mockito-all:2.0.2-beta'
The text was updated successfully, but these errors were encountered: