OPENJPA-2300 avoid warnings due to annotation processor

git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@1757320 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Romain Manni-Bucau 2016-08-23 07:57:38 +00:00
parent f85e0347d6
commit 5faf53c036
1 changed files with 19 additions and 5 deletions

View File

@ -18,8 +18,6 @@
*/
package org.apache.openjpa.persistence.meta;
import static javax.lang.model.SourceVersion.RELEASE_6;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
@ -38,7 +36,7 @@ import javax.annotation.processing.ProcessingEnvironment;
import javax.annotation.processing.RoundEnvironment;
import javax.annotation.processing.SupportedAnnotationTypes;
import javax.annotation.processing.SupportedOptions;
import javax.annotation.processing.SupportedSourceVersion;
import javax.lang.model.SourceVersion;
import javax.lang.model.element.Element;
import javax.lang.model.element.TypeElement;
import javax.lang.model.type.TypeKind;
@ -103,7 +101,6 @@ import org.apache.openjpa.persistence.util.SourceCode;
"openjpa.header",
"openjpa.metamodel"
})
@SupportedSourceVersion(RELEASE_6)
public class AnnotationProcessor6 extends AbstractProcessor {
private SourceAnnotationHandler handler;
@ -113,6 +110,7 @@ public class AnnotationProcessor6 extends AbstractProcessor {
private List<String> header = new ArrayList<String>();
private boolean active;
private static Localizer _loc = Localizer.forPackage(AnnotationProcessor6.class);
private SourceVersion supportedSourceVersion;
/**
* Category of members as per JPA 2.0 type system.
@ -183,7 +181,15 @@ public class AnnotationProcessor6 extends AbstractProcessor {
return TypeCategory.MAP;
return TypeCategory.ATTRIBUTE;
}
@Override
public SourceVersion getSupportedSourceVersion() {
if (supportedSourceVersion != null) {
return supportedSourceVersion;
}
return SourceVersion.latestSupported();
}
/**
* Initialization.
*/
@ -193,6 +199,14 @@ public class AnnotationProcessor6 extends AbstractProcessor {
active = "true".equalsIgnoreCase(getOptionValue("openjpa.metamodel"));
if (!active)
return;
final String supported = getOptionValue("openjpa.processor.supportedversion");
if (supported != null) {
supportedSourceVersion = SourceVersion.valueOf(supported);
} else { // default to ensure we don't log a false warning for every compilation, see OPENJPA-2300
supportedSourceVersion = SourceVersion.latestSupported();
}
processingEnv.getMessager().printMessage(Diagnostic.Kind.NOTE, _loc.get("mmg-tool-banner").toString());
logger = new CompileTimeLogger(processingEnv, getOptionValue("openjpa.log"));
setSourceVersion();