The Modifier for Exports in the java doc states that
MANDATEDThe export was implicitly declared in the source of the module declaration.
SYNTHETICThe export was not explicitly or implicitly declared in the source of the module declaration.
Looking at few module-info.classes, I can see that there are generally two types of usages:
module java.base {
...
exports java.util; // type 1
exports java.util.concurrent;
exports java.util.concurrent.atomic;
exports jdk.internal to jdk.jfr; // type 2
exports jdk.internal.jmod to
jdk.compiler,
jdk.jlink;
...
}
The Qualified Exports do describe these two types but there is no reference to the enum types. Are these the different types referred in the docs?
Q1. In general SYNTHETIC and MANDATED are modifiers used as in Exports, ModuleDescriptor, Opens and Requires. What is the difference between these two and is one preferred over another in practice?
Q2. Whats an example of a Synthetic Modifier anyway if not declared in the source of the module?
Difference in Synthetic and Mandated modifiers is simple - mandate was implicitly declared and synthetic was not implicitly or explicitly declared. There were good articles on that and java specification has detailed explanation about synthetic modifier which was earlier introduced to java. Below details related to the synthetic was extracted from those because of the completeness of the details. Please find the references at the end.
Synthetic:
Mandated:
References: