-
Notifications
You must be signed in to change notification settings - Fork 60
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
Inaccessible Object Exception in Unit Test #837
Comments
Please create a sample app with a reproducer. |
I have made necessary changes for micraonut4 version in build.gradle which I m using in my project |
@dstepanov , Any Update on this issue as our code is breaking after upgrade |
I'm sorry, this has nothing to do with Micronaut. The problem is with |
Expected Behavior
Unit test should not be affected after change from Micronaut 3 to micronaut 4
Actual Behaviour
I have switched from micraonut 3 to Micronaut 4, so I have to use java. 17 now as per documentation and earlier I was using java 14.
So Ideally all the test should pass, but what I can see that wherever I m using withEnvVariable function in unit test, it is failing with execution Inaccessible Object Exception
Steps To Reproduce
public void EnvironmentVariablesTest {
@test
public void setEnvironmentVariable() {
String value = withEnvironmentVariable("name", "value")
.execute(() -> System.getenv("name"));
assertEquals("value", value);
}
}
when I tried to run this sample unit test only getting issue "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 @7549926"
After going through google search I found that this issue is of java17 which microanut 4 is also using
I tries adding this in build.gradle
test {
jvmArgs ["–add-opens java.base/java.lang=ALL-UNNAMED"]
systemProperty 'add-opens', 'java.base/java.lang=ALL-UNNAMED'
systemProperty 'add-opens', 'java.base/java.util=ALL-UNNAMED'
}
but still same issue
Environment Information
Mac
java 17.0.8
Example Application
No response
Version
4.0.1
The text was updated successfully, but these errors were encountered: