RFR: JDK-8213103: RoundEnvironment.getElementsAnnotatedWith(Class) crashes with -source 8
joe.darcy at oracle.com
Thu Nov 1 17:20:13 UTC 2018
If we had considered this situation more careful during JSR 269, we
might have specified this condition to be an error. However, as you
point out, the long-standing behavior has been to return null so it is
probably best to preserve that.
I've filed a follow-up spec bug, JDK-8213256: "Clarify runtime vs
compile time annotations for
RoundEnvironment.getElementsAnnotatedWith(Class)", to make the
possibility of the Class -> TypeElement failing explicit.
For the annotation processor in the test file, consider subclassing
Looks good to me to push as-is or with a possible test update.
On 11/1/2018 5:34 AM, Jan Lahoda wrote:
> Hi Joe,
> Thanks for the comments. An updated webrev that uses Feature.MODULES
> instead of Elements.getAllModules, and also updates the copyright year
> as noted by Vicente, is here:
> (As a side note, Elements.getAllModules() should be OK
> performance-wise for this purpose, it basically reads an
> existing/pre-filed field.)
> For changing the method to throw IAE, while I agree this situation may
> point out an unintended difference between the compile- and run-time
> environments, sometimes the difference may be intentional (runtime
> dependencies need to be transitive, while compile time don't need to
> be) and may be benign, as is in the case where I've noticed this
> problem. So given the method didn't throw the exception in such cases
> before, I'd rather keep the behavior compatible.
More information about the compiler-dev