'Unable to make field static final java.lang.invoke.MethodHandles$Lookup java.lang.invoke.MethodHandles$Lookup.IMPL_LOOKUP
I have a Spring Feign client which is sending POJO object to remote endpoint using POST and my application start-up fails with below exceptions.
java.lang.reflect.InaccessibleObjectException: Unable to make field static final java.lang.invoke.MethodHandles$Lookup java.lang.invoke.MethodHandles$Lookup.IMPL_LOOKUP accessible: module java.base does not "opens java.lang.invoke" to unnamed module @420a85c4
Below the dependencies I am using in my application.
java version: 17
spring boot version: 2.5.3
spring boot cloud version: 2020.0.3
spring boot starter openfeign version: 2.2.8.RELEASE
As recommended in https://github.com/OpenFeign/feign/issues/935, I had tried
workaround solution: Adding this jvm option '--add-opens java.base/java.lang.invoke=ALL-
UNNAMED' worked.
Any other alternative suggestion other than jvm argument are most welcome.
Solution 1:[1]
Force OpenFeign version to at least 11.7, which has this issue solved.
If you are using Spring Dependency Management plugin, then you can do it like this (Gradle example):
dependencyManagement {
dependencies {
dependencySet(group: 'io.github.openfeign', version: '11.7') {
entry 'feign-core'
entry 'feign-jackson'
entry 'feign-slf4j'
entry 'feign-soap'
entry 'feign-jaxb'
}
}
}
Solution 2:[2]
For me it worked to add the following JVM Option:
--add-opens java.base/java.lang.invoke=ALL-UNNAMED
Solution 3:[3]
For JDK 9+, if you use the JVM options to fix the problem, add another = into the JVM options:
e.g.
--add-opens=java.base/java.lang.invoke=ALL-UNNAMED
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Infeligo |
| Solution 2 | michaeak |
| Solution 3 | David Vu |
