From fbe762374cdf13d865cf2c50ec6267b5f9ac7337 Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Thu, 25 Sep 2014 22:05:41 -0500 Subject: [PATCH] NullUsageProcessor supports Java 6 through 8 (fixes #487) --- .../v4/runtime/misc/NullUsageProcessor.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/runtime/JavaAnnotations/src/org/antlr/v4/runtime/misc/NullUsageProcessor.java b/runtime/JavaAnnotations/src/org/antlr/v4/runtime/misc/NullUsageProcessor.java index 4343dc1fe..4dba946d4 100644 --- a/runtime/JavaAnnotations/src/org/antlr/v4/runtime/misc/NullUsageProcessor.java +++ b/runtime/JavaAnnotations/src/org/antlr/v4/runtime/misc/NullUsageProcessor.java @@ -33,7 +33,6 @@ package org.antlr.v4.runtime.misc; import javax.annotation.processing.AbstractProcessor; import javax.annotation.processing.RoundEnvironment; import javax.annotation.processing.SupportedAnnotationTypes; -import javax.annotation.processing.SupportedSourceVersion; import javax.lang.model.SourceVersion; import javax.lang.model.element.AnnotationMirror; import javax.lang.model.element.Element; @@ -83,7 +82,6 @@ import java.util.Set; * @author Sam Harwell */ @SupportedAnnotationTypes({NullUsageProcessor.NotNullClassName, NullUsageProcessor.NullableClassName}) -@SupportedSourceVersion(SourceVersion.RELEASE_6) public class NullUsageProcessor extends AbstractProcessor { public static final String NotNullClassName = "org.antlr.v4.runtime.misc.NotNull"; public static final String NullableClassName = "org.antlr.v4.runtime.misc.Nullable"; @@ -94,6 +92,22 @@ public class NullUsageProcessor extends AbstractProcessor { public NullUsageProcessor() { } + @Override + public SourceVersion getSupportedSourceVersion() { + SourceVersion latestSupported = SourceVersion.latestSupported(); + + if (latestSupported.ordinal() <= 6) { + return SourceVersion.RELEASE_6; + } + else if (latestSupported.ordinal() <= 8) { + return latestSupported; + } + else { + // this annotation processor is tested through Java 8 + return SourceVersion.values()[8]; + } + } + @Override public boolean process(Set annotations, RoundEnvironment roundEnv) { if (!checkClassNameConstants()) {