Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JDK14 can't run "java --add-opens"

I'm doing a small project to learn swagger-codegen. When I'm executing "mvn clean install" the next errors appear:

Unable to make public boolean java.util.Collections$EmptyMap.isEmpty() accessible: module java.base does not "opens java.util" to unnamed module @1e1b061

and then

Failed to execute goal io.swagger.codegen.v3:swagger-codegen-maven-plugin:3.0.18:generate (default) on project swgtst-api: Code generation failed. See above for the full exception.

When i'm trying to solve it with java --add-opens=java.base/java.util=ALL-UNNAMED as written here https://docs.oracle.com/javase/9/migrate/toc.htm#JSMIG-GUID-2F61F3A9-0979-46A4-8B49-325BA0EE8B66 Nothing happens, just java help is shown.

For sure the last command has problem with syntax, but I have no Idea what exactly... What am I doing wrong?

like image 592
kinderproc Avatar asked Nov 06 '22 02:11

kinderproc


1 Answers

That option doesn't do anything on its own, but rather it modifies the way that invocation of Java will run. You still need to add that option to the java that is invoked when you run mvn.

One way to do that, is to add the option to the Maven files (someone else can help with that or you can search for how to set Java options in Maven files).

I ran into a similar situation and instead used _JAVA_OPTIONS to pass it through. You may be able to do something similar by prefixing your invocation of mvn with _JAVA_OPTIONS, though it is possible that Maven will override those and you'll have to modify the file as described above.

For reference, here is the command I used successfully:

_JAVA_OPTIONS="--add-opens=java.base/java.util=ALL-UNNAMED" swagger-codegen3 generate --lang python --input-spec spec.yaml
like image 51
Drew Haven Avatar answered Nov 12 '22 16:11

Drew Haven