Supported source version RELEASE_6 from annotation

2020-02-28 00:46发布

问题:

I have an enterprise application running in the following environment.

  • Mojarra 2.2.7
  • PrimeFaces 5.0 final
  • PrimeFaces Extension 2.0 final
  • OmniFaces 1.8.1
  • EclipseLink 2.5.2 having JPA 2.1
  • GlashFish 4.0
  • NetBeans IDE 8.0
  • JDK 1.7

I have changed the source levels to 1.7 from 1.6 in the project.properties file under nbproject in all three modules (Java EE module, EJB module and WAR module) to have support for Java EE 7. It is not a Maven project.

  • j2ee.platform=1.7
  • javac.source=1.7
  • javac.target=1.7

Earlier they all were 1.6.


After these changes, the following warning appears while cleaning the project.

warning: Supported source version 'RELEASE_6' from annotation processor 'org.eclipse.persistence.internal.jpa.modelgen.CanonicalModelProcessor' less than -source '1.7'

I'm using EclipseLink metamodel generator 1.3.0 final to generate a static metamodel.

Is there a way to get rid of this warning other than downgrading the source level to 1.6? Is there any incompatibility with this warning?


Update :

This warning is no longer reproducible in EclipseLink 2.6.1 (available since Thursday, October 15, 2015) with the respective metamodel generator provided by the bundle - org.eclipse.persistence.jpa.modelgen_2.6.1.v20150916-55dc7c3.jar.

Currently tested using EclipseLink 2.6.1 (JPA 2.1) and JDK 8u45 on GlassFish 4.1 / Java EE 7.

I assume it is fixed.

回答1:

According to the Java API specification, the @SupportedSourceVersion annotation (which is the origin of the log) specifies "the latest source version an annotation processor supports", not the minimum.

Reading a discussion on the NetBeans forum on this topic, it suggests you have few solutions. I guess the only solution is to change the code in CanonicalModelProcessor:

In order for the EclipseLink runtime to be compliant with Java 6, you have @SupportedSourceVersion(RELEASE_6)

To be properly adapted for a Java 7 compilation, you should have @SupportedSourceVersion(RELEASE_7)

But as I understand you are not compiling EclipseLink on your own. The main problem (and the reason of the warning) is that the software provider (i.e. the Eclipse foundation) guarantees a proper processing of the code in a Java SE 6 environment.

The problem was reported as a JDK bug. The conclusion is that there is no other clear workaround.

The solution would be to specify the RELEASE7 constant (at least according to what the API says). But if EclipseLink team do, they can't compile in a Java 6 environment.

So whether you compile EclipseLink on your own with the proper constant, whether you live with the warning...