Leoreoreo / myBlog

My blog to keep track of my learning process.
MIT License
0 stars 0 forks source link

Unable to make field private final byte[] java.lang.String.value accessible: module java.base does not "opens java.lang" to unnamed module @... #35

Open Leoreoreo opened 4 months ago

Leoreoreo commented 4 months ago

Debug

Running Java Program on IntelliJ IDEA

Issue

java.lang.reflect.InaccessibleObjectException: Unable to make field private final byte[] java.lang.String.value accessible: module java.base does not "opens java.lang" to unnamed module @xxxx

Reason

java.lang package not opened to the Flink module

Solution 1

In IntelliJ IDEA:

Run -> Edit Configurations -> Build and Run (Modify Options) -> Add VM Options

--add-opens java.base/java.lang=ALL-UNNAMED
--add-opens java.base/java.lang.reflect=ALL-UNNAMED

Apply -> OK

Solution 2

Change JDK to Java8

File -> Project Structure -> Project -> SDK -> choose 1.8

Run -> Edit Configurations -> Build and Run -> choose 1.8 and (Modify Options) -> Disable VM options

GeoffreyStemys commented 3 days ago

solution 1 is great !