RFR: 8354877: DirectClassBuilder default flags should include ACC_SUPER
Chen Liang
liach at openjdk.org
Fri Apr 25 15:03:45 UTC 2025
On Tue, 22 Apr 2025 23:55:54 GMT, Chen Liang <liach at openjdk.org> wrote:
> In the future value objects JEP, class files must have one of ACC_IDENTITY (now ACC_SUPER), ACC_ABSTRACT, and ACC_FINAL bits set, otherwise they are rejected. The current default flag has none of these bits set, meaning that it will not be suitable in the future. Currently, most class file generation in the JDK explicitly set ACC_SUPER for compatibility; we should also set this bit in the default flags, despite being no-op, in anticipation of future compatibility.
>
> The API specifications of ClassBuilder and AccessFlags already state that an unspecified default flag for class builders are chosen, so changing this flag should be fine without extra specification changes.
Currently, most of the sites in JDK and community bytecode generation that specify access flags for a class provide an explicit `ACC_SUPER`; it is always effectively enabled since Java 8 even when it is not set.
The alternative is in valhalla, we choose a different default when the flag is default and withVersion is called. I think that is overcomplicated, and we should better just set the consensual `ACC_SUPER` flag even if the behavior has already been on by default.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/24808#issuecomment-2830678906
More information about the core-libs-dev
mailing list