Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-7003550

Loosen modeling requirements for annotation processing erroneous code

XMLWordPrintable

    • b123
    • generic
    • generic
    • Not verified

      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.

            darcy Joe Darcy
            darcy Joe Darcy
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: