-
CSR
-
Resolution: Approved
-
P4
-
None
-
behavioral
-
low
-
some class file processors could detect additional, and unexpected, information in some cases. When inspected by Reflection API for all Java versions since 8, these executables will produce different, but correct, parameter information with correct flags.
-
Other
Summary
Javac is not marking method parameters as synthetic
or mandated
by default, when applicable, as mandated by the JLS in section 13.1. The compiler should be synchronized with the spec.
Problem
Javac is marking method parameters as synthetic
or mandated
only if the -parameters
option is passed. The JLS states that a Java compiler should mark all method parameters as synthetic
or mandated
when applicable.
Solution
The proposed fix is to mark all method parameters as synthetic
or mandated
when applicable by emitting the MethodParameters attribute in the class file. This applies to all release / target versions since 8, when the MethodParameters attribute was added.
Specification
The related specification section is JLS 18 § 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).
- csr of
-
JDK-8292275 javac does not emit SYNTHETIC and MANDATED flags for parameters by default
-
- Resolved
-