Mandated/implicit parameters

Hannes Greule hannesgreule at
Tue May 24 06:27:53 UTC 2022

I came across an oddity when using the Parameter#isImplicit()[1] method. 
According to its documentation, it returns true if the parameter is implicitly
declared in source code. The JLS 13.1 point 12[2] says "A construct emitted by
a Java compiler must be marked as *mandated* if it corresponds to a formal
parameter declared implicitly in source code" with a list of such parameters.
However, it seems like the information is only embedded when compiling
with the -parameters flag.

>From my understanding of the given section in the JLS, the mandated flag
should *always* be emitted. Is this a bug, or am I missing something?

Looking into it a bit deeper, it also seems like the parameters of a compact
constructor for records are never marked as mandated, even when compiling with
the -parameters flag (but the MethodParameters attribute is always written 
or record constructors).

I collected some code and outputs here[3] to show the differences between
compiling with and without the -parameters flag for cases that shouldn't
be different from my understanding.

If those two observations are bugs, I'd like to try contributing fixes for
them (I already spent a fair amount of time on it). As I did not contribute
to the JDK before, I'd probably need some assistance. I got two experimental
fixes for each of the problems here[4][5].



More information about the compiler-dev mailing list