JDK Enhancement Proposal (JEP) 216 was issued as a fix to javac in regard to how import statements are processed. Prior to Java 9, there were instances where the order of import statements would impact if the source code was accepted or not.
When we develop applications in Java, we typically add import statements as we need them, resulting in an unordered list of import statements. IDEs do a great job of color-coding import statements that are not used, as well as informing us of import statements we need, but that has not been included. It should not matter what order the import statements are in; there is no applicable hierarchy.
javac compiles classes in two primary steps. Specific to handling import statements, these steps are as follows:
- Type resolution: The type resolution consists of a review of the abstract syntax tree to identify declarations...