JDK-7003550 : Loosen modeling requirements for annotation processing erroneous code
  • Type: Bug
  • Component: core-libs
  • Sub-Component: javax.lang.model
  • Affected Version: 7
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2010-11-30
  • Updated: 2022-08-10
  • Resolved: 2011-05-18
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 7
7 b123Fixed
Related Reports
Relates :  
Description
From the package specification of javax.lang.model:

"During annotation processing, operating on incomplete or erroneous programs is necessary; however, there are fewer guarantees about the nature of the resulting model. If the source code is not syntactically well-formed, a model may or may not be provided as a quality of implementation issue. If a program is syntactically valid but erroneous in some other fashion, the returned model must have no less information than if all the method bodies in the program were replaced by |"throw new RuntimeException();"|. If a program refers to a missing type XYZ, the returned model must contain no less information than if the declaration of type XYZ were assumed to be |"class XYZ {}"|, |"interface XYZ {}"|, |"enum XYZ {}"|, or |"@interface XYZ {}"|. If a program refers to a missing type |XYZ<K1, ... ,Kn>|, the returned model must contain no less information than if the declaration of XYZ were assumed to be |"class XYZ<T1, ... ,Tn> {}"| or |"interface XYZ<T1, ... ,Tn> {}" 

When modeling erroneous types that *cannot* be corrected via annotation processing, it may be better to have the specification say:

" "If the source code is syntactically ill-formed or has some other irrecoverable error that could not be removed by the generated of new types, a model may or may not be provided as a quality of implementation issue." "

This allows an implementation to fail faster on known-bad code without requiring that behavior.

Comments
EVALUATION http://hg.openjdk.java.net/jdk7/build/langtools/rev/23fc45d3a572
25-12-2010

SUGGESTED FIX --- old/src/share/classes/javax/lang/model/element/package-info.java 2010-12-08 21:19:02.000000000 -0800 +++ new/src/share/classes/javax/lang/model/element/package-info.java 2010-12-08 21:19:02.000000000 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -66,12 +66,14 @@ * <p>During annotation processing, operating on incomplete or * erroneous programs is necessary; however, there are fewer * guarantees about the nature of the resulting model. If the source - * code is not syntactically well-formed, a model may or may not be - * provided as a quality of implementation issue. If a program is - * syntactically valid but erroneous in some other fashion, the - * returned model must have no less information than if all the method - * bodies in the program were replaced by {@code "throw new - * RuntimeException();"}. If a program refers to a missing type XYZ, + * code is not syntactically well-formed or has some other + * irrecoverable error that could not be removed by the generation of + * new types, a model may or may not be provided as a quality of + * implementation issue. + * If a program is syntactically valid but erroneous in some other + * fashion, any returned model must have no less information than if + * all the method bodies in the program were replaced by {@code "throw + * new RuntimeException();"}. If a program refers to a missing type XYZ, * the returned model must contain no less information than if the * declaration of type XYZ were assumed to be {@code "class XYZ {}"}, * {@code "interface XYZ {}"}, {@code "enum XYZ {}"}, or {@code
09-12-2010

PUBLIC COMMENTS See http://hg.openjdk.java.net/jdk7/tl/langtools/rev/23fc45d3a572
09-12-2010

EVALUATION A fine idea.
03-12-2010