question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

EnvironmentVariable - An illegal reflective access operation

See original GitHub issue

On

openjdk version "11.0.9" 2020-10-20
OpenJDK Runtime Environment (build 11.0.9+11)
OpenJDK 64-Bit Server VM (build 11.0.9+11, mixed mode)

and

openjdk version "15.0.1" 2020-10-20
OpenJDK Runtime Environment (build 15.0.1+9)
OpenJDK 64-Bit Server VM (build 15.0.1+9, mixed mode, sharing)

we have

[ERROR] WARNING: An illegal reflective access operation has occurred
[ERROR] WARNING: Illegal reflective access by org.junitpioneer.jupiter.EnvironmentVariableUtils (file:/..../.m2/repository/org/junit-pioneer/junit-pioneer/1.1.0/junit-pioneer-1.1.0.jar) to field java.util.Collections$UnmodifiableMap.m
[ERROR] WARNING: Please consider reporting this to the maintainers of org.junitpioneer.jupiter.EnvironmentVariableUtils
[ERROR] WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
[ERROR] WARNING: All illegal access operations will be denied in a future release

It is warning message - tests pass as expected

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

3reactions
nipafxcommented, Dec 19, 2020

Hi @slawekjaranowski,

I assume you’re using Pioneer’s @ClearEnvironmentVariable or @SetEnvironmentVariable, correct? If so, please see the warning in the documentation:

Java considers environment variables to be immutable, so this extension uses reflection to change them. This requires that the SecurityManager allows modifications and can potentially break on different operating systems and Java versions. Be aware that this is a fragile solution and consider finding a better one for your specific situation. If you’re running on Java 9 or later, you may have to add --add-opens=java.base/java.util=ALL-UNNAMED to your test execution to prevent warnings or even errors.

The warning you describe is the result of the reflective operation that changes environment variables. As far as I know, there’s no way for Pioneer to suppress these warnings and even if there were, I would oppose implementing it because this is a fragile operation that deserves a warning 😉 , so I’m inclined to close with issue as works as intended.

If you’re not using these annotations or otherwise disagree, let me know and we can follow up.

2reactions
nipafxcommented, Dec 22, 2020

I want to reopen the issue to discuss whether we’re already doing our best to inform users of what’s going on. At the moment, there’s the paragraph in the documentation that I quoted above and we publish a report entry saying “This extension uses reflection to mutate JDK-internal state, which is fragile. Check the Javadoc or documentation for more details.”

Additionally, we could:

  • print that warning to System.out or System.err
  • include the specific warning in the documentation, so search engines lead users to it

Anything else?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to set environment variable in Java without 'illegal ...
To verify that your application is ready for a future version of the JDK, run it with --illegal-access=deny along with any necessary --add-opens ......
Read more >
illegal reflective access operation - webcompere/system-stubs
I'm testing a command line application based on the https://picocli.info framework. While doing so, I encountered an illegal reflective access ...
Read more >
Java 9 Illegal Reflective Access Warning - Baeldung
In this tutorial, we'll inspect the relationship between the module system and reflection. 2. Modular System and Reflection.
Read more >
How to fix “an illegal reflective access operation has occurred”
The "an illegal reflective access operation has occurred" warning message is related to the unauthorized access to parts of the JDK made by ......
Read more >
IDEA-272921 - JetBrains YouTrack
This should fix the An illegal reflective access operation has occurred warnings (https://issues.apache.org/jira/browse/GROOVY-8339).
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found