Queries and patch for JDK-8034854: outer_class_info_index of synthetic class is not zero
jan.lahoda at oracle.com
Wed Feb 19 04:34:11 PST 2014
I have a few questions about JDK-8034854 and a possible patch/fix for
it. The bug URL:
The problem is that while JVMS 7, 4.7.6. (The InnerClasses Attribute)
If a class file has a version number that is greater than or equal to
51.0, and has an InnerClasses attribute in its attributes table, then
for all entries in the classes array of the InnerClasses attribute,
the value of the outer_class_info_index item must be zero if the value
of the inner_name_index item is zero.
javac in some cases produces non-zero "outer_class_info_index" even if
"inner_name_index" is zero. This happens for synthetically generated
auxiliary classes. These classes are generated for a number of reasons,
for example to be used as tags when accessing private constructors. The
synthetic classes internally have an empty name, so the generated
"inner_name_index" is zero, but their owner is a class, so they get the
I've sketched out a simple fix for this problem, which ensures that
"outer_class_info_index" is zero for classes that have empty name:
After this change, the generated synthetic classes look a lot like
anonymous classes defined in an initializer of the given class (based on
the InnerClasses attribute and the EnclosingMethod attribute). That
seems reasonable to me.
My questions are:
-does the fix above make sense?
-the change affects all target levels. It seems to me that the new
behavior makes sense even for pre-7 classfiles, but I'll gladly limit
the new behavior to only some minimal target level if desired.
Any comments welcome.
More information about the compiler-dev