JDK-6402506 : JSR 269: Add ProcessingEnvironment.getSourceVersion
  • Type: Bug
  • Component: core-libs
  • Sub-Component: javax.annotation.processing
  • Affected Version: 6
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2006-03-23
  • Updated: 2017-05-16
  • Resolved: 2006-04-29
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6
6 b83Fixed
Related Reports
Relates :  
Description
JSR 269 includes a getSupportedSourceVersion method on the Processor interface to allow the processor to declare to the tool the latest source level it supports.  This implies a processor should accept inputs from earlier source levels too.  However, if an earlier source level is in effect, a processor should be able to query what the *output* source level is so it can raise an error or output appropriate source and/or class files.

Comments
SUGGESTED FIX src/share/classes/javax/annotation/processing>sccs sccsdiff -r1.2 -r1.3 ProcessingEnvironment.java ------- ProcessingEnvironment.java ------- 11a12 > import javax.lang.model.SourceVersion; 80a82,92 > > /** > * Returns the source version to which generated {@linkplain > * Filer#createSourceFile source} and {@linkplain > * Filer#createClassFile class} files should conform to. > * > * @return the source version to which generated source and class > * files should conform to > * @see Processor#getSupportedSourceVersion > */ > SourceVersion getSourceVersion(); src/share/classes/javax/annotation/processing>sccs sccsdiff -r1.5 -r1.6 Processor.java ------- Processor.java ------- 153a154 > * @see ProcessingEnvironment#getSourceVersion src/share/classes/javax/annotation/processing>sccs sccsdiff -r1.2 -r1.3 Filer.java ------- Filer.java ------- 57a58,62 > * <p>To avoid subsequent errors, the contents of the source file > * should be compatible with the {@linkplain > * ProcessingEnvironment#getSourceVersion source version} being used > * for this run. > * 72a78,82 > * <p>To avoid subsequent errors, the contents of the class file > * should be compatible with the {@linkplain > * ProcessingEnvironment#getSourceVersion source version} being used > * for this run. > * src/share/classes/com/sun/tools/javac/processing>sccs sccsdiff -r1.14 -r1.15 JavacProcessingEnvironment.java ------- JavacProcessingEnvironment.java ------- 375a376 > SourceVersion actualSourceVersion = Source.toSourceVersion(source); 377c378 < if (procSourceVersion.ordinal() < (source.ordinal() + 2)) { --- > if (procSourceVersion.compareTo(actualSourceVersion) < 0 ) { 1036a1038,1041 > public SourceVersion getSourceVersion() { > return Source.toSourceVersion(source); > } > src/share/classes/com/sun/tools/javac/code>sccs sccsdiff -r1.41 -r1.42 Source.java ------- Source.java ------- 14a15,16 > import javax.lang.model.SourceVersion; > import static javax.lang.model.SourceVersion.*; 134a137,152 > public static SourceVersion toSourceVersion(Source source) { > switch(source) { > case JDK1_2: > return RELEASE_2; > case JDK1_3: > return RELEASE_3; > case JDK1_4: > return RELEASE_4; > case JDK1_5: > return RELEASE_5; > case JDK1_6: > return RELEASE_6; > default: > return null; > } > }
18-04-2006

EVALUATION The new method should be added.
23-03-2006