When I run sbt, I get the below. I am still able to keep working but the warning/error annoys me and clutters my terminal. Any idea how I resolve this?
java.lang.reflect.InaccessibleObjectException: Unable to make field private static final java.util.HashMap java.lang.ProcessEnvironment.theEnvironment accessible: module java.base does not "opens java.lang" to unnamed module @43016
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354)
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
at java.base/java.lang.reflect.Field.checkCanSetAccessible(Field.java:178)
at java.base/java.lang.reflect.Field.setAccessible(Field.java:172)
at au.com.onegeek.sbtdotenv.DirtyEnvironmentHack$.$anonfun$setEnv$1(DirtyEnvironmentHack.scala:42)
at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
at scala.util.Try$.apply(Try.scala:213)
at au.com.onegeek.sbtdotenv.DirtyEnvironmentHack$.setEnv(DirtyEnvironmentHack.scala:38)
at au.com.onegeek.sbtdotenv.SbtDotenv$.configureEnvironment(SbtDotenv.scala:71)
at au.com.onegeek.sbtdotenv.SbtDotenv$autoImport$.$anonfun$dotEnv$1(SbtDotenv.scala:42)
at scala.Function1.$anonfun$compose$1(Function1.scala:49)
at scala.Function1.$anonfun$compose$1(Function1.scala:49)
at scala.Function1.$anonfun$compose$1(Function1.scala:49)
at scala.Function1.$anonfun$compose$1(Function1.scala:49)
at scala.Function1.$anonfun$compose$1(Function1.scala:49)
at scala.Function1.$anonfun$compose$1(Function1.scala:49)
at scala.Function1.$anonfun$compose$1(Function1.scala:49)
at sbt.Project$.setProject(Project.scala:501)
The problem is coming from sbt-dotenv
.
At the root folder of your project, just create a .jvmopts
file containing the following lines:
--add-opens=java.base/java.util=ALL-UNNAMED
--add-opens=java.base/java.lang=ALL-UNNAMED
The stack trace mentions "au.com.onegeek.sbtdotenv", so apparently this is coming from https://github.com/mefellows/sbt-dotenv.
You could try upgrading to the latest version of that plugin and see if the problem goes away.
If it doesn't, you could report the issue to the maintainer.
In that repo's README, there is a section about similar errors: https://github.com/mefellows/sbt-dotenv#illegal-reflective-access-warnings
It isn't clear to me if that's the same or different.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With