简体   繁体   English

JDK-17 的 gwt-plugin 编译错误:无法使私有最终 sun.util.calendar.BaseCalendar$Date java.util.Date.getCalendarDate() 可访问

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

I try to upgrade my large java-application from jdk-11 to jdk-17.我尝试将我的大型 java 应用程序从 jdk-11 升级到 jdk-17。 On jdk-11 all is ok.在 jdk-11 上一切正常。

We use the following gwt-plugin (version 1.0.1) to compile:我们使用下面的gwt-plugin(1.0.1版本)来编译:

     <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:如果我像这样添加add-opens参数:

     <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.上面的日志说,我使用的是 jdk-17。

How do I need to set the add-opens parameter?如何设置add-opens参数?

Do you see any other workaround?您是否看到任何其他解决方法?

The comment from Stuart solved my issue. Stuart 的评论解决了我的问题。 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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM