Community
Participate
Working Groups
JVM Spec (2nd edn) - section 4.7.6 The Synthetic Attribute "A class member that does not appear in the source code must be marked using a Synthetic attribute." There is nothing in this section that says anything about compiler-generated default constructors, so one would assume that these must be marked synthetic too. This PR is to investigate whether we are in fact handling this properly in the compiler. What does javac do these days? Does the JCK have a test that covers this?
javac doesn't add the synthetic attribute for the default constructor. So do we.
jikes is not doing it as well.
We should run the JCK with a patched version of the batch compiler that sets the synthetic attribute for default constructor.
The synthetic attribute got added around innerclass extension. Default constructors did exist already, and were therefore not using it. For backward compatibility issues, this was never added very likely... I wouldn't change this assumption at this stage, unless this is officially coming from the language owner. Though it would ease our customer by allowing them to tell when using synthetic artifacts. Moving to later
From Neal Gafter, the answer is no. "No. The "synthetic" flag is for things that are an artifact of the implementaiton and do not affect the API. Default constructors are part of the API of a class." So the synthetic attribute will never be used for the default constructor. I guess we can close this bug as WONTFIX and update the javadoc of the isSynthetic() method.
I agree.
Close as WONTFIX.