kohsuke / metainf-services

Generates META-INF/services files automatically
http://metainf-services.kohsuke.org/
69 stars 26 forks source link

No SupportedSourceVersion annotation found (with fix) #3

Closed lorenzleutgeb closed 11 years ago

lorenzleutgeb commented 12 years ago

Hello,

I got the following warnings during compilation:

warning: No SupportedSourceVersion annotation found on org.kohsuke.metainf_services.AnnotationProcessorImpl, returning RELEASE_6.
warning: Supported source version 'RELEASE_6' from annotation processor 'org.kohsuke.metainf_services.AnnotationProcessorImpl' less than -source '1.7'

It somehow seems strange (why would the default value be RELEASE_6 when I'm compiling with javac 1.7.0_03?) but the fix was very simple:

Just three lines (two imports and an annotation in org.kohsuke.metainf_services.AnnotationProcessorImpl):

$ diff AnnotationProcessorImpl.old.java AnnotationProcessorImpl.java
30a31,32
> import javax.annotation.processing.SupportedSourceVersion;
> import javax.lang.model.SourceVersion;
56a59
> @SupportedSourceVersion(SourceVersion.RELEASE_7)

I was too lazy to fork and do a pull request :D

Best regards, Lorenz

jglick commented 12 years ago

That would just make it impossible to build (and perhaps use) the project on JDK 6, which I suppose is still supported.

javac just issues this warning in case it cannot confirm that the processor is able to handle the current source level. In this case it can handle it, but there is no way to tell javac that since RELEASE_7 is only available in 7+ platform APIs, and JSR 269 APIs are not currently available in standalone form (though I have suggested it on compiler-dev@openjdk.java.net).

https://netbeans.org/bugzilla/show_bug.cgi?id=210286 is another example of the same annoyance.

jglick commented 12 years ago

BTW I fixed the No SupportedSourceVersion annotation found warning.

jglick commented 12 years ago

http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7184902 (to appear soon) requests an -Xlint category.

jglick commented 11 years ago

Rejected; and the resubmitted JDK-8037955 was again rejected, suggesting a reflective implementation of getSupportedSourceVersion.

jglick commented 11 years ago

Note that the originally proposed change should produce a build error, but MANIMALSNIFFER-27 means it does not.

jhrussell commented 10 years ago

Is there a maven release published somewhere that contains this fix?

jglick commented 10 years ago

Does not look that way; up to @kohsuke to release 1.6.