JDK-8057919 Class.getSimpleName() should work for non-JLS compliant class names
Vladimir Ivanov
vladimir.x.ivanov at oracle.com
Mon Jun 15 16:04:30 UTC 2015
Jochen,
> plus... it would be really really nice if someone could tell me how a
> non-anonymous class in a method has to look like with javap, so that I
> can know from there if it is no anonymous and finally fix he flags for
> Groovy's class generation.
Every entry in InnerClass attribute contains 4 fields:
(1) inner_class_info_index;
(2) outer_class_info_index;
(3) inner_name_index;
(4) inner_class_access_flags.
The following InnerClass attribute is generated for your test case:
InnerClasses:
#2; // class test$_run_closure1
It corresponds to the following entry in InnerClass attribute:
inner_class_info = #2 // class test$_run_closure1
outer_class_info_index = #0
inner_name_index = #0
inner_class_access_flags = 0
According to JVMS [1], it corresponds to an anonymous class:
"
4.7.6. The InnerClasses Attribute
...
outer_class_info_index
If C is not a member of a class or an interface (that is, if C is ... an
anonymous class (JLS §15.9.5)), the value of the outer_class_info_index
item must be zero.
...
inner_name_index
If C is anonymous (JLS §15.9.5), the value of the inner_name_index item
must be zero.
...
"
In order to make the class non-anonymous again, you have to specify
inner_name_index and, optionally, outer_class_info_index.
Best regards,
Vladimir Ivanov
[1]
https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.7.6
More information about the core-libs-dev
mailing list