IntelliJ build failed but it works at second time - java

It is weird that when I build my code in IntelliJ IDEA. The first time always has an internal error.
It shows like :
"Internal error (java.lang.reflect.InaccessibleObjectException): Unable to make protected void java.util.ResourceBundle.setParent(java.util.ResourceBundle) accessible: module java.base does not "opens java.util" to unnamed module #6b4a4e18".
It will work for the second time. There is nothing wrong with my code because it is just a simple "hello, world". Is there anything I can do? It is so convenient I need to run twice every time.

Related

Import com.sun.media.sound into Eclipse

I am trying to resurrect, just for a brief moment, some very old Java 7 code in a modern Eclipse 2022-06 IDE. The software made extensive use of the com.sun.media.sound package, in particular WaveFileWriter. It did some manipulations at the numeric level to create sound effects, and I have no wish to go re-write the thing for something I only need to use once, for five minutes, and forget about it.
However, com.sun.media.sound now works very badly, and even opening the file gives me this error:
Exception in thread "main" java.lang.IllegalAccessError: class [DO THE STUFF] (in unnamed module #0x6615435c) cannot access class com.sun.media.sound.WaveFileWriter (in module java.desktop) because module java.desktop does not export com.sun.media.sound to unnamed module #0x6615435c
I am very confused by this-- Per this question, this error appears to be related to JDK9, but this code was written before JDK9, and the build path in Eclipse appears to be JDK7 as well.
I am certain something is misconfigured in Eclipse, but I have no idea what.

Getting error in the .print() of Flink in java in eclipse

While trying to execute a basic Flink program in eclipse, I'm getting error due to .print() called by datastream_name.print() for printing my datastream.
using Java8
ERROR
Exception in thread "main" 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 #776aec5c
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:180)
at java.base/java.lang.reflect.Field.setAccessible(Field.java:174)
at org.apache.flink.api.java.ClosureCleaner.clean(ClosureCleaner.java:106)
at org.apache.flink.api.java.ClosureCleaner.clean(ClosureCleaner.java:132)
at org.apache.flink.api.java.ClosureCleaner.clean(ClosureCleaner.java:132)
at org.apache.flink.api.java.ClosureCleaner.clean(ClosureCleaner.java:69)
at org.apache.flink.streaming.api.environment.StreamExecutionEnvironment.clean(StreamExecutionEnvironment.java:2139)
at org.apache.flink.streaming.api.datastream.DataStream.clean(DataStream.java:203)
at org.apache.flink.streaming.api.datastream.DataStream.addSink(DataStream.java:1243)
at org.apache.flink.streaming.api.datastream.DataStream.writeUsingOutputFormat(DataStream.java:1144)
at org.apache.flink.streaming.api.datastream.DataStream.writeAsText(DataStream.java:1004)
at orgname.testProjectFlink.App.main(App.java:19)
What is the flink version?
Beginning from flink1.15, the support of Java 8 is now deprecated and removed (FLINK-25247). The Flink community recommends all users migrate to Java 11.

java module access issue: "Class in a module cannot access class in unnamed module because module x does not read unnamed module y"

My source code compiles on java 7 and runs on java 11.
I am trying to integrate imperva RASP as a java agent in tomcat. However, when I start the tomcat server, it is throwing following exception:
Caused by: java.lang.IllegalAccessError: class sun.security.ec.ECDSASignature (in module jdk.crypto.ec) cannot access class com.imperva.rasp.AgentBridge (in unnamed module #0x66c61024) because module jdk.crypto.ec does not read unnamed module #0x66c61024
at jdk.crypto.ec/sun.security.ec.ECDSASignature.<init>(ECDSASignature.java:118)
at jdk.crypto.ec/sun.security.ec.ECDSASignature.<init>(ECDSASignature.java:106)
at jdk.crypto.ec/sun.security.ec.ECDSASignature$SHA1.<init>(ECDSASignature.java:214)
at jdk.crypto.ec/sun.security.ec.SunEC$ProviderService.newInstance(SunEC.java:102)
at java.base/java.security.Signature.isSpi(Signature.java:331)
The way I am passing java agent is:
JAVA_OPTS="-javaagent:$IMPERVA_JAR $JAVA_OPTS"
I went through multiple posts such as this one about --add-opens argument. Based on that, I am passing JDK_JAVA_OPTIONS="$JDK_JAVA_OPTIONS --add-opens=jdk.crypto.ec/sun.security.ec=ALL-UNNAMED"
I can see following statement in the logs:
Picked up JDK_JAVA_OPTIONS: --add-opens=jdk.crypto.ec/sun.security.ec=ALL-UNNAMED
Am I missing something here or is there any syntax error in the arguments that I am passing?
There is no any other configuration is done.
Any help is appreciated. Thank you.
Managed to solve it by using --add-reads instead of --add-opens.
JDK_JAVA_OPTIONS="$JDK_JAVA_OPTIONS --add-reads jdk.crypto.ec=ALL-UNNAMED"

Error in android development, gradle build failed

So, ever since I updated my repository from my group, I got this error, however, when I looked at the commits all that changes in the built-in files are the version of gradle and jdk. I've searched and done possible solution regarding the app:processDebugMainMAnifest and I just don't know how I can resolve this problem.
Execution failed for task ':app:processDebugMainManifest'.
Unable to make field private final java.lang.String java.io.File.path accessible: module java.base does not "opens java.io" to unnamed module #645de77a

Java's add-opens doesn't seem to make a package accessible

I am trying to access JavaFX's package-private class & public static method in it (javafx.scene.control.skin.TableSkinUtils.resizeColumnToFitContent), so that I can resize TableView's columns automatically.
However, I'm using the module system since it seems that JavaFX 11 requires my app to be a module. If I don't specify a module for my app, I get this error: Error: JavaFX runtime components are missing, and are required to run this application I'd actually prefer to not use the module system at all, is there a way?
Now, due to the module system, I get an exception when attempting to make the method TableSkinUtils.resizeColumnToFitContent accessible:
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make public static void javafx.scene.control.skin.TableSkinUtils.resizeColumnToFitContent(javafx.scene.control.skin.TableViewSkinBase,javafx.scene.control.TableColumnBase,int) accessible: module javafx.controls does not "opens javafx.scene.control.skin" to module Explorer
So, I tried to add this workaround: --add-opens javafx.controls/javafx.scene.control.skin=ALL-UNNAMED to Intellij's run configuration VM options.
However, with or without the above, I get the same exception.
What am I possibly doing wrong?

Categories

Resources