Style Guide: OpenJDK Java Style Guidelines v6 (cached page)
Coverage Page: src/site/xdoc/openjdk_style.xml
Config File: src/main/resources/openjdk_checks.xml
Context
The infrastructure for the New OpenJDK Java Style Guide coverage page (openjdk_style.xml) and embedded config (openjdk_checks.xml) has been created. The config currently contains only 1 check (OneStatementPerLine). We need to add checks for each rule in the style guide and complete all ??? entries in the coverage page - similar to how it is done for Google's Java Style Checkstyle Coverage.
All sections and rules are already listed in the coverage page. Rows marked with ??? need to be completed.
How to contribute
-
Pick a subsection from the tracking list below, comment "I am working on §X.Y - <Subsection Name>" on this issue, and create a child issue referencing this parent issue.
- Title format:
Add checks for OpenJDK Style §X.Y - <Subsection Name>
- In the child issue, list all the rules and corresponding checks that will enforce that rule(see example child issue).
- Add a checklist in the child issue to track progress per rule.
-
Wait for the issue to get approved before starting work to avoid unnecessary iterations on PRs.
-
Make one PR per check/rule. If a subsection has multiple rules and needs multiple checks to enforce them, do NOT put them all in one PR. Submit a separate PR for each check so it is easy to review and merge.
-
In each PR clearly mention:
- Which rule it covers (e.g., "Source files must be encoded in 7-bit ASCII")
- Which check is being added
- Reference the child issue
-
Each PR should include:
- The check added to
src/main/resources/openjdk_checks.xml with proper configuration
- The corresponding
??? row updated in src/site/xdoc/openjdk_style.xml, following the format used in google_style.xml
- Integration tests following the folder structure below
-
Update your child issue checklist as PRs are raised.
Example Child Issue : #19619
Integration test structure
Tests must follow the same section-based folder structure used by Google style tests. The existing structure is:
src/it/resources/com/openjdk/checkstyle/test/chapter{N}{description}/rule{NNN}{description}/Input*.java
src/it/java/com/openjdk/checkstyle/test/chapter{N}{description}/rule{NNN}{description}/*Test.java
Use src/it/resources/com/google/checkstyle/test/ as the reference for how test input files and test classes are organized by chapter and rule.
Note: For the integration tests, we will not follow modulewise testing. We will follow chapterwise testing like Google style, one test class per section, not per check. The existing OneStatementPerLineTest will also be refactored into the chapterwise format. Please follow the Google style test structure as reference.
Reference
Subsection tracking
2 - Java Source Files
| Subsection |
Child Issue |
Status |
| §2 - Java Source Files |
#19617 |
|
| §2.1 - Special Characters |
#19617 |
|
3 - Formatting
| Subsection |
Child Issue |
Status |
| §3.1 - Copyright notice |
|
|
| §3.2 - Package declaration |
#19622 |
|
| §3.3 - Import statements |
#19623 |
|
| §3.3.1 - Wildcard Imports |
#19734 |
|
| §3.4 - Class Structure |
#19624 |
|
| §3.4.1 - Order of Constructors and Overloaded Methods |
|
|
| §3.5 - Modifiers |
#19629 |
|
| §3.6 - Braces |
#19670 |
|
| §3.6.1 - Short Forms |
#19670 |
|
| §3.7 - Indentation |
#19619 |
☑️ |
| §3.8 - Wrapping Lines |
|
|
| §3.8.1 - Wrapping Class Declarations |
#19743 |
|
| §3.8.2 - Wrapping Method Declarations |
|
|
| §3.8.3 - Wrapping Expressions |
|
|
| §3.9 - Whitespace |
|
|
| §3.9.1 - Vertical Whitespace |
|
|
| §3.9.2 - Horizontal Whitespace |
|
|
| §3.10 - Variable Declarations |
#19641 |
|
| §3.11 - Annotations |
|
|
| §3.12 - Lambda Expressions |
#19662 |
|
| §3.13 - Redundant Parentheses |
|
|
| §3.14 - Literals |
#19620 |
|
| §3.15 - Javadoc |
|
|
4 - Naming
| Subsection |
Child Issue |
Status |
| §4.1 - Package Names |
#19640 |
|
| §4.2 - Class, Interface and Enum Names |
|
|
| §4.3 - Method Names |
|
|
| §4.4 - Variables |
|
|
| §4.5 - Type Variables |
|
|
| §4.6 - Constants |
|
|
5 - Programming Practices
| Subsection |
Child Issue |
Status |
| §5 - Programming Practices |
|
|
| §5.1 - Commenting Code |
|
|
Style Guide: OpenJDK Java Style Guidelines v6 (cached page)
Coverage Page:
src/site/xdoc/openjdk_style.xmlConfig File:
src/main/resources/openjdk_checks.xmlContext
The infrastructure for the New OpenJDK Java Style Guide coverage page (
openjdk_style.xml) and embedded config (openjdk_checks.xml) has been created. The config currently contains only 1 check (OneStatementPerLine). We need to add checks for each rule in the style guide and complete all???entries in the coverage page - similar to how it is done for Google's Java Style Checkstyle Coverage.All sections and rules are already listed in the coverage page. Rows marked with
???need to be completed.How to contribute
Pick a subsection from the tracking list below, comment "I am working on §X.Y -
<Subsection Name>" on this issue, and create a child issue referencing this parent issue.Add checks for OpenJDK Style §X.Y - <Subsection Name>Wait for the issue to get approved before starting work to avoid unnecessary iterations on PRs.
Make one PR per check/rule. If a subsection has multiple rules and needs multiple checks to enforce them, do NOT put them all in one PR. Submit a separate PR for each check so it is easy to review and merge.
In each PR clearly mention:
Each PR should include:
src/main/resources/openjdk_checks.xmlwith proper configuration???row updated insrc/site/xdoc/openjdk_style.xml, following the format used ingoogle_style.xmlUpdate your child issue checklist as PRs are raised.
Example Child Issue : #19619
Integration test structure
Tests must follow the same section-based folder structure used by Google style tests. The existing structure is:
Use
src/it/resources/com/google/checkstyle/test/as the reference for how test input files and test classes are organized by chapter and rule.Note: For the integration tests, we will not follow modulewise testing. We will follow chapterwise testing like Google style, one test class per section, not per check. The existing OneStatementPerLineTest will also be refactored into the chapterwise format. Please follow the Google style test structure as reference.
Reference
google_style.xmlandgoogle_checks.xmlas the formatting and structure reference.Subsection tracking
2 - Java Source Files
3 - Formatting
4 - Naming
5 - Programming Practices