java-types icon indicating copy to clipboard operation
java-types copied to clipboard

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

Open raner opened this issue 3 years ago • 1 comments

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)

raner avatar Sep 18 '22 04:09 raner

您的邮件已经收到,此邮件是收到邮件成功后由系统自动发送的,本人在阅读到邮件后会第一时间给您回复邮件的

ahange avatar Sep 18 '22 04:09 ahange