Discussion:
Error in JLS for module-info.class
(too old to reply)
Luke Hutchison
2018-10-19 23:09:13 UTC
Permalink
In JLS section 4.1 ("The ClassFile structure") for SE 11, it states:

super_class

For a class, the value of the super_class item either must be zero or must
be a valid index into the constant_pool table. If the value of the
super_class item is nonzero, the constant_pool entry at that index must be
a CONSTANT_Class_info structure representing the direct superclass of the
class defined by this class file. Neither the direct superclass nor any of
its superclasses may have the ACC_FINAL flag set in the access_flags item
of its ClassFile structure.

If the value of the super_class item is zero, then this class file must
represent the class Object, the only class or interface without a direct
superclass.
This is incorrect -- the value of super_class is also zero for
module-info.class files.
Alex Buckley
2018-10-19 23:53:06 UTC
Permalink
You mean JVMS, not JLS. See the text under Table 4.1-B: "The ACC_MODULE
flag indicates that this class file defines a module, not a class or
interface. If the ACC_MODULE flag is set, then special rules apply to
the class file which are given at the end of this section. If the
ACC_MODULE flag is not set, then the rules immediately below the current
paragraph apply to the class file."

The rules at the end of the section mandate that super_class is zero for
an ACC_MODULE class file.

Alex
Luke Hutchison
2018-10-20 00:45:35 UTC
Permalink
Ah, thanks for clarifying, I missed those exceptions.
Post by Alex Buckley
You mean JVMS, not JLS. See the text under Table 4.1-B: "The ACC_MODULE
flag indicates that this class file defines a module, not a class or
interface. If the ACC_MODULE flag is set, then special rules apply to
the class file which are given at the end of this section. If the
ACC_MODULE flag is not set, then the rules immediately below the current
paragraph apply to the class file."
The rules at the end of the section mandate that super_class is zero for
an ACC_MODULE class file.
Alex
Loading...