JDK-8308450 : Release Note: Emit `synthetic` and `mandated` Flags for Parameters by Default
  • Type: Sub-task
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 21
  • Priority: P4
  • Status: Resolved
  • Resolution: Delivered
  • Submitted: 2023-05-19
  • Updated: 2023-07-28
  • Resolved: 2023-06-01
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 21
21Resolved
Description
Prior to JDK 21, the `javac` compiler did not always mark method parameters as `synthetic` or `mandated` when applicable. Starting with JDK 21, the `javac` compiler emits the `MethodParameters` attribute in the class file when applicable. This attribute stores information on whether or not parameters are `synthetic` or `mandated`. This change applies to all release and target versions supported by `javac`  since all currently supported releases and targets have the `MethodParameters` attribute defined.

This change is justified by JLS § 13.1, in particular:

    A binary representation for a class or interface must also contain all of the following: 

    [...]

    11. A construct emitted by a Java compiler must be marked as synthetic if it does not
        correspond to a construct declared explicitly or implicitly in source code, unless
        the emitted construct is a class initialization method (JVMS §2.9).
    12. A construct emitted by a Java compiler must be marked as mandated if it corresponds
        to a formal parameter declared implicitly in source code (§8.8.1, §8.8.9, §8.9.3,
        §15.9.5.1).