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)