Hello, While looking at https://bugs.openjdk.org/browse/JDK-8162500 and https://bugs.openjdk.org/browse/JDK-8162501 I realized that the static flag in InnerClasses attribute alone is not sufficient to check if an inner class is static; this flag is simply not emitted on local and anonymous classes.
A simple workaround would be to check the EnclosingMethod attribute and check if the enclosing method is static. However, this does not always work: Local/anonymous classes can be declared in an initializer block (instance or static) and anonymous classes can be declared in variable initialization statements. In this case, the EnclosingMethod attribute can only report the enclosing class, since the class appears in multiple methods (for <init>) or non-reflectable method (<clinit>), and simple attempts to guess will fail. Moreover, with the upcoming JEP 447 that adds a pre-initialization context, local/anonymous classes in the constructor may potentially be static before the super constructor call, and be instance after the super constructor call, which complicates the guessing problem. Thus, I suggest emitting static flags for the InnerClasses attribute of anonymous/local classes in static/pre-initialization contexts, in order to allow core reflection to reliably detect the receiver class of a local or anonymous class. It may also have a cascading effect on the nested classes within these local/anonymous classes, as shown in JDK-8162500. Chen Liang