gwt-plugin compile-error with JDK-17: Unable to make private final sun.util.calendar.BaseCalendar$Date java.util.Date.getCalendarDate() accessible

Viewed 28

I try to upgrade my large java-application from jdk-11 to jdk-17. On jdk-11 all is ok.

We use the following gwt-plugin (version 1.0.1) to compile:

     <plugin>
       <groupId>net.ltgt.gwt.maven</groupId>
       <artifactId>gwt-maven-plugin</artifactId>
       <configuration>
         <moduleName>xxxxxxxxxxxxx</moduleName>
         <jvmArgs>
           <jvmArg>-showversion</jvmArg>
           <jvmArg>-Xmx2048M</jvmArg>
         </jvmArgs>
       </configuration>
       <executions>
         <execution>
           <goals>
             <goal>compile</goal>
           </goals>
         </execution>
       </executions>
     </plugin>

but the compile complains with:

[INFO] --- gwt-maven-plugin:1.0.1:compile (default-cli) @ xxxxxxx ---
[WARNING] openjdk version "17.0.2" 2022-01-18 LTS
[WARNING] OpenJDK Runtime Environment Zulu17.32+13-CA (build 17.0.2+8-LTS)
[WARNING] OpenJDK 64-Bit Server VM Zulu17.32+13-CA (build 17.0.2+8-LTS, mixed mode, sharing)
[INFO] Compiling module xxxxxxxx
...
[INFO] java.lang.reflect.InaccessibleObjectException: Unable to make private final sun.util.calendar.BaseCalendar$Date java.util.Date.getCalendarDate() accessible: module java.base does not "opens java.util" to unnamed module @145f66e3
[INFO]  at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354)
[INFO]  at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
[INFO]  at java.base/java.lang.reflect.Method.checkCanSetAccessible(Method.java:199)
[INFO]  at java.base/java.lang.reflect.Method.setAccessible(Method.java:193)
[INFO]  at org.hibernate.validator.util.privilegedactions.SetAccessibility.run(SetAccessibility.java:39)
[INFO]  at org.hibernate.validator.util.ReflectionHelper.setAccessibility(ReflectionHelper.java:354)
[INFO]  at org.hibernate.validator.metadata.BeanMetaDataImpl.addMethodMetaConstraint(BeanMetaDataImpl.java:474)
[INFO]  at org.hibernate.validator.metadata.BeanMetaDataImpl.initMethodConstraints(BeanMetaDataImpl.java:654)
[INFO]  at org.hibernate.validator.metadata.BeanMetaDataImpl.initClass(BeanMetaDataImpl.java:546)
[INFO]  at org.hibernate.validator.metadata.BeanMetaDataImpl.createMetaData(BeanMetaDataImpl.java:540)
[INFO]  at org.hibernate.validator.metadata.BeanMetaDataImpl.<init>(BeanMetaDataImpl.java:209)
[INFO]  at org.hibernate.validator.metadata.BeanMetaDataImpl.<init>(BeanMetaDataImpl.java:163)
[INFO]  at org.hibernate.validator.engine.ValidatorImpl.getBeanMetaData(ValidatorImpl.java:1211)
[INFO]  at org.hibernate.validator.engine.ValidatorImpl.getConstraintsForClass(ValidatorImpl.java:251)
[INFO]  at com.google.gwt.validation.rebind.BeanHelperCache.doCreateHelper(BeanHelperCache.java:113)

If I add the add-opens parameter like this:

     <plugin>
       <groupId>net.ltgt.gwt.maven</groupId>
       <artifactId>gwt-maven-plugin</artifactId>
       <configuration>
         <moduleName>xxxxxxxxxxxxx</moduleName>
         <jvmArgs>
           <jvmArg>-showversion</jvmArg>
           <jvmArg>-Xmx2048M</jvmArg>
           <jvmArg>--add-opens java.base/java.util=ALL-UNNAMED</jvmArg>
         </jvmArgs>
       </configuration>
       <executions>
         <execution>
           <goals>
             <goal>compile</goal>
           </goals>
         </execution>
       </executions>
     </plugin>

then, I get the following error:

[INFO] --- gwt-maven-plugin:1.0.1:compile (default-cli) @ xxxxxx ---
[WARNING] Unrecognized option: --add-opens java.base/java.util=ALL-UNNAMED
[WARNING] Error: Could not create the Java Virtual Machine.
[WARNING] Error: A fatal exception has occurred. Program will exit.

Above the log stated, that I use a jdk-17.

How do I need to set the add-opens parameter ?

Do you see any other workaround?

1 Answers

The comment from Stuart solved my issue. Thanks a lot.

The following configuration worked for me:

  <plugin>
    <groupId>net.ltgt.gwt.maven</groupId>
    <artifactId>gwt-maven-plugin</artifactId>
    <configuration>
      <moduleName>xxxxxxxx</moduleName>
      <jvmArgs>
        <jvmArg>-showversion</jvmArg>
        <jvmArg>-Xmx2048M</jvmArg>
        <jvmArg>--add-opens</jvmArg>
        <jvmArg>java.base/java.util=ALL-UNNAMED</jvmArg>
      </jvmArgs>
    </configuration>
    <executions>
      <execution>
        <goals>
          <goal>compile</goal>
        </goals>
      </execution>
    </executions>
  </plugin>
Related