openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1757320 - /openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/meta/AnnotationProcessor6.java
Date Tue, 23 Aug 2016 07:57:38 GMT
Author: rmannibucau
Date: Tue Aug 23 07:57:38 2016
New Revision: 1757320

URL: http://svn.apache.org/viewvc?rev=1757320&view=rev
Log:
OPENJPA-2300 avoid warnings due to annotation processor

Modified:
    openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/meta/AnnotationProcessor6.java

Modified: openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/meta/AnnotationProcessor6.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/meta/AnnotationProcessor6.java?rev=1757320&r1=1757319&r2=1757320&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/meta/AnnotationProcessor6.java
(original)
+++ openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/meta/AnnotationProcessor6.java
Tue Aug 23 07:57:38 2016
@@ -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.Proce
 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.ut
                     "openjpa.header",
                     "openjpa.metamodel"
                   })
-@SupportedSourceVersion(RELEASE_6)
 
 public class AnnotationProcessor6 extends AbstractProcessor {
     private SourceAnnotationHandler handler;
@@ -113,6 +110,7 @@ public class AnnotationProcessor6 extend
     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 extend
             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 extend
         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();



Mime
View raw message