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

Types.asElement() returns null for ErrorType

    Details

      Description

      The specs for the utility method javax.lang.model.util.Types.asElement(TypeMirror) says:
      -----------------------------------------------------------------------------------
      Returns the element corresponding to a type.
      The type may be a DeclaredType or TypeVariable.
      Returns null if the type is not one with a corresponding element.
      -----------------------------------------------------------------------------------

      However the method returns null if invoked with the ErrorType instance.

      Such behavior looks contradicting to the specs because:
      1. ErrorType extends DeclaredType
      2. ErrorType does have a corresponding element which can be retrieved using:

              if (typeMirror.getKind() == TypeKind.ERROR) {
                  element = ((ErrorType) typeMirror).asElement();
              }

        Attachments

          Activity

            People

            • Assignee:
              jjg Jonathan Gibbons
              Reporter:
              ashusher Alexander Shusherov (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported:
                Indexed: