Generation of synthesized parameters (original) (raw)
Alex Buckley alex.buckley at oracle.com
Tue Jan 29 17:14:07 PST 2013
- Previous message: Generation of synthesized parameters
- Next message: Generation of synthesized parameters
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
I have been looking into the JLS treatment of the constructs mentioned below, with an eye to clarifying matters in JLS8.
I think a construct emitted by javac should be marked as synthesized if it corresponds to a construct declared implicitly in source code. Constructs declared implicitly in source code are:
- default constructors (8.8.9)
- the initial parameters of constructors for non-private inner member classes and anonymous classes (13.1, 15.9.5.1)
- the values and valueOf methods of enums (8.9.2)
- certain public fields of enums (8.9.2)
- certain public methods of interfaces (9.2)
So for the purpose of this thread, only the second item need be marked synthesized.
Alex
On 1/29/2013 12:14 PM, Joe Darcy wrote:
Hello,
On 1/29/2013 11:40 AM, Eric McCorkle wrote: In order to facilitate writing tests for the MethodParameters feature, I'd like to get a complete list of all the cases when javac can generate synthesized parameters.
Here is a list I've put together from email discussions and comments in JBS: 1) outer "this" parameters Arguably, some outer this parameters would be synthesized with others would be synthetic. Inner classes that are also member classes, (see diagram in "Nested, Inner, Member, and Top-Level Classes," https://blogs.oracle.com/darcy/entry/nestedinnermemberandtop), are potentially callable from outside of the enclosing class and are required to have an outer this parameter as the first parameter so that code from different compilers can call each other. The other this parameter in this case is synthesized as it is mandated or implied by the JLS. On the other hand, named inner classes defined inside a method or constructor as well as anonymous classes only need to obey a compiler-internal contract and any extra parameters in this case are synthetic. (Not all anonymous classes have an outer; an anonymous class created inside a static initializer block does not.) 2) extra values passed to constructor for enum values Such parameters are synthetic, they are a javac implementation artifact not mandated or implied by the JLS. 3) hidden values passed to constructors of inner classes for final variables You'll can check the JLS regarding whether these are synthesized or synthetic, but I would assume they are synthetic. 4) JLS mandated public no-arg constructors added by the compiler to classes with no declared constructor: synthesized This is not a parameter, but another language structure. HTH, -Joe 5) The two parameters pre-ended to enum constructors by javac
Does this capture everything, or does it miss something? Ideally, I would like to put together a complete list of all cases that should generate synthesized parameters. (If one already exists, then that's great). Thanks, Eric
- Previous message: Generation of synthesized parameters
- Next message: Generation of synthesized parameters
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]