Unrecognized java vm option ignored

`Unrecognized VM option ‘CMSClassUnloadingEnabled’` after switching to java 17

After changing the Java version to 17 I can’t build the Gradle project. I am using Gradle 7.3.1 version and have the following line in Gradle properties:

org.gradle.jvmargs=-Dfile.encoding=UTF-8 -Xms1g -Xmx4g -XX:+UseG1GC -XX:+CMSClassUnloadingEnabled 
Unrecognized VM option 'CMSClassUnloadingEnabled' Error: Could not create the Java Virtual Machine. Error: A fatal exception has occurred. Program will exit. 
Unable to make field private int java.lang.reflect.Field.modifiers accessible: module java.base does not "opens java.lang.reflect" to unnamed module @1b9ee3e0 

The «Unrecognized VM option ‘CMSClassUnloadingEnabled'» arises because in Java 14 the CMS garbage collector was removed and the options specific to that garbage collector (like «CMSClassUnloadingEnabled») are illegal for Java 14 and later. If you add this option the JVM refuses to start.

The second error «Unable to make field private int java.lang.reflect.Field.modifiers accessible» happens because Java 17 drastically restricted access to internal fields. However, since Gradle 7.3 is compatible with Java 17 it must be an error reported from some third party plugin or from your code. Without further context this cannot be decided.

A typical case of esoteric command line options. The option -XX:+CMSClassUnloadingEnabled is, as the name indicates, specific to the CMS garbage collector and hence, never made any sense in combination with -XX:+UseG1GC , an entirely different garbage collector. So, now that the CMS collector has been removed, options related to CMS cause an error, but these options had no effect anyway when you were using G1GC. Since G1GC is the default in JDK 17, you can even remove the -XX:+UseG1GC option.

Читайте также:  Archicad java runtime environment

1 Answer 1

Unable to make field private int java.lang.reflect.Field.modifiers accessible: module java.base does not "opens java.lang.reflect" to unnamed module @1b9ee3e0 

Yeah you are right that’s because of AspectJ

Assuming that you are using AspectJ load-time weaving (LTW) rather than compile-time weaving, maybe you ought to read the AspectJ release notes for each version since 1.9.7, supporting Java 16+:

Use LTW on Java 16+

Please note that if you want to use load-time weaving on Java 16+, the weaving agent collides with JEP 396 (Strongly Encapsulate JDK Internals by Default) and related subsequent JEPs. Therefore, you need to set the JVM parameter —add-opens java.base/java.lang=ALL-UNNAMED in order to enable aspect weaving. This is due to the fact that the weaver uses internal APIs for which we have not found an adequate replacement yet when defining classes in different classloaders.

Источник

Java 17 with Maven Wrapper results in Unrecognized VM option ‘MaxPermSize=512m’

I use OpenJDK 17 with Maven Wrapper 3.8.2 from Spring Initializr (Maven project, JAR packaging, Java 17, Spring Boot 2.6.0). No additional dependencies.

user@DESKTOP-U2OU5HG MINGW64 /c/Projects/my-project (master) $ java -version openjdk version "17" 2021-09-14 OpenJDK Runtime Environment (build 17+35-2724) OpenJDK 64-Bit Server VM (build 17+35-2724, mixed mode, sharing) 

Upon running any of ./mvnw.cmd -version or ./mvnw.cmd clean install , I always get the following message:

Unrecognized VM option 'MaxPermSize=512m' Error: Could not create the Java Virtual Machine. Error: A fatal exception has occurred. Program will exit. 

Switching to OpenJDK 16.0.2 resolves the issue, however, I need to work with Java 17. How to get it run? There is nowhere MaxPermSize=512m set.

Isn’t this answers your question, stackoverflow.com/questions/47112412/… . After Java9 it seems MaxPermSize=512m is removed.

Читайте также:  Php display fatal errors

Yes. The newer JVM does not like a command option which comes from somewhere. You may want to single step your mvnw script.

1 Answer 1

Indeed -XX:MaxPermSize=size is labelled as follows according to Java® Development Kit Version 16/17 Tool Specifications (see the links):

The Maven Wrapper in the mvnw.cmd script, however, aside from the required JAVA_HOME , uses also a bunch of optional environment variables such as M2_HOME and these starting with MAVEN_ prefix.

The important one is MAVEN_OPTS where such a removed Java option can appear causing the inability to start the JVM on the newer version. In my case, I had something like:

MAVEN_OPTS="-Xmx4g -XX:MaxPermSize=512m -Dfile.encoding=UTF-8" 

The solution is either to remove the option from the environment variables or add this line to the Maven Wrapper script to override the MAVEN_OPTS value, In the minimal form:

Источник

How to fix «Unrecognized VM option ‘UseConcMarkSweepGC'» error?

I have followed the instructions for getting started with codenameone in IntelliJ, yet when I set up my first project, based on the sample app I get this error:

"C:\Program Files\Java\jdk-15.0.1\bin\java.exe" -Xms128m -Xmx1014m -XX:ReservedCodeCacheSize=512m -XX:+UseConcMarkSweepGC -XX:SoftRefLRUPolicyMSPerMB=50 -XX:CICompilerCount=2 -XX:+HeapDumpOnOutOfMemoryError -XX:-OmitStackTraceInFastThrow -ea -Dsun.io.useCanonCaches=false -Djdk.http.auth.tunneling.disabledSchemes=\"\" -Djdk.attach.allowAttachSelf=true -Djdk.module.illegalAccess.silent=true -Dkotlinx.coroutines.debug=off "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA 2020.3.1\lib\idea_rt.jar=61544:C:\Program Files\JetBrains\IntelliJ IDEA 2020.3.1\bin" -Dfile.encoding=UTF-8 -classpath "C:\Users\reinp\OneDrive - beuthhs\beuth\Patterns und Frameworks\justtrivia\out\production\justtrivia;C:\Users\reinp\OneDrive - beuthhs\beuth\Patterns und Frameworks\justtrivia\src;C:\Users\reinp\OneDrive - beuthhs\beuth\Patterns und Frameworks\justtrivia\lib\CodenameOne.jar;C:\Users\reinp\OneDrive - beuthhs\beuth\Patterns und Frameworks\justtrivia\JavaSE.jar;native\internal_tmp;lib\impl\cls" com.codename1.impl.javase.Simulator com.patrickreinbold.justtrivia.JustTrivia Unrecognized VM option 'UseConcMarkSweepGC' Error: Could not create the Java Virtual Machine. Error: A fatal exception has occurred. Program will exit. Process finished with exit code 1 

I saw that this has to do with Java 8 but in the IntelliJ instructions it says nothing about using Java 8. Is Java 8 always necessary or can codenameone run with Java 15, too? EDIT: I have now got it to open by simply copying the first line with the java command and removing the UseConcMarkSweepGC flag, then running it in terminal. But I am still not sure if that is «the correct way» to do it or if something could break along the way now.

Читайте также:  Http ordjonikidzovsky bkr sudrf ru modules php

Источник

Unrecognized JVM GC options when using JAVA 11

Platform notice: Server and Data Center only. This article only applies to Atlassian products on the server and data center platforms .

Summary

When using Java 11, some JVM parameters previously applied to Tomcat are now unrecognized.

Environment

Diagnosis

When using Java 11 with Confluence, if you still have JVM options from a previous Java 8 installation you may find the application will not start and the following or similar messages are printed in the logs:

Unrecognized VM option 'UseGCLogFileRotation' Error: Could not create the Java Virtual Machine. Error: A fatal exception has occurred. Program will exit.

Cause

In Java 11 some JVM flags including those used in Java 8 for Garbage Collection Logging have been removed.

If these are still contained in the JVM flags specified in the setenv.sh or setenv.bat the JVM will not be able to start.

It’s known that the following options are unrecognized in Java 11:

  • -d64
  • PrintGCTimeStamps
  • PrintGCDateStamps
  • PrintTenuringDistribution
  • PrintGCCause
  • PrintGCDetails
  • UseGCLogFileRotation
  • NumberOfGCLogFiles
  • GCLogFileSize

In Java 11, these GCLog options are now handled by Xlog, there is a conversion table below:

More information about this change can be found in the following Stackoverflow article:

Solution

Either add the following JVM option to the setenv.sh or setenv.bat file (option 1), or convert the GC options to the new Xlog format (option 2). For option 2, be sure to remove the unrecognized options for Java 11 from the list above.

XX:+IgnoreUnrecognizedVMOptions
CATALINA_OPTS="-Xlog:gc*:file=$LOGBASEABS/logs/gc-%t.log:tags,time,uptime,level:filecount=5,filesize=2M $"

Источник

Оцените статью