Closed dfa1 closed 6 years ago
Thanks for the information but AFAIK there is no way to modify environment variables without using this illegal reflective access.
I didn't noticed that getenv() is a view on the actual system env.
@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
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: