Skip to content

TypeElementImpl.getEnclosingElement() does not return package element for top-level types #8

Description

@raner

The javadoc for javax.lang.model.element.TypeElement.getEnclosingElement() states that the method returns "the package of a top-level type, the immediately lexically enclosing element for a nested type."
However, when calling the method on a java-types TypeElement for a top-level type, an exception is thrown:

java.lang.UnsupportedOperationException: getEnclosingElement() not supported for top-level classes.
	at net.florianschoppmann.java.reflect.TypeElementImpl.getEnclosingElement(TypeElementImpl.java:119)
	at net.florianschoppmann.java.reflect.TypeElementImpl.getEnclosingElement(TypeElementImpl.java:16)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions