Skip to content
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

[java10] An illegal reflective access operation #64

Closed
dfa1 opened this issue Jun 30, 2018 · 3 comments
Closed

[java10] An illegal reflective access operation #64

dfa1 opened this issue Jun 30, 2018 · 3 comments

Comments

@dfa1
Copy link

dfa1 commented Jun 30, 2018

First of all thanks for this nice and well written library.

Running a test suite using system-rules 1.18 in JDK10 in macosx outputs:

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.junit.contrib.java.lang.system.EnvironmentVariables (file:/Users/dfa/.m2/repository/com/github/stefanbirkner/system-rules/1.18.0/system-rules-1.18.0.jar) to field java.util.Collections$UnmodifiableMap.m
WARNING: Please consider reporting this to the maintainers of org.junit.contrib.java.lang.system.EnvironmentVariables
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
@stefanbirkner
Copy link
Owner

Thanks for the information but AFAIK there is no way to modify environment variables without using this illegal reflective access.

@dfa1
Copy link
Author

dfa1 commented Jul 3, 2018

I didn't noticed that getenv() is a view on the actual system env.

@dfa1 dfa1 closed this as completed Jul 3, 2018
@souravs17031999
Copy link

@stefanbirkner I upgraded to jdk-17 and now I am blocked by this since I am getting this error

java.lang.reflect.InaccessibleObjectException: Unable to make field private final java.util.Map java.util.Collections$UnmodifiableMap.m accessible: module java.base does not "opens java.util" to unnamed module @2f4551e6
15:57:31  	at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354)
15:57:31  	at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
15:57:31  	at java.base/java.lang.reflect.Field.checkCanSetAccessible(Field.java:178)
15:57:31  	at java.base/java.lang.reflect.Field.setAccessible(Field.java:172)
15:57:31  	at org.junit.contrib.java.lang.system.EnvironmentVariables.getFieldValue(EnvironmentVariables.java:188)
15:57:31  	at org.junit.contrib.java.lang.system.EnvironmentVariables.getEditableMapOfVariables(EnvironmentVariables.java:150)
15:57:31  	at org.junit.contrib.java.lang.system.EnvironmentVariables.access$200(EnvironmentVariables.java:49)
15:57:31  	at org.junit.contrib.java.lang.system.EnvironmentVariables$EnvironmentVariablesStatement.restoreOriginalVariables(EnvironmentVariables.java:134)
15:57:31  	at org.junit.contrib.java.lang.system.EnvironmentVariables$EnvironmentVariablesStatement.evaluate(EnvironmentVariables.java:125)
15:57:31  	at org.junit.rules.RunRules.evaluate(RunRules.java:20)
15:57:31  	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
15:57:31  	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
15:57:31  	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
15:57:31  	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
15:57:31  	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
15:57:31  	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
15:57:31  	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
15:57:31  	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
15:57:31  	at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
15:57:31  	at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
15:57:31  	at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
15:57:31  	at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
15:57:31  	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
15:57:31  	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
15:57:31  	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
15:57:31  	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
15:57:31  	at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
15:57:31  	at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
15:57:31  	at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
15:57:31  	at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
15:57:31  	at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
15:57:31  

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

No branches or pull requests

3 participants