Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Allow to provide source file java language version

Open
#975 0 comments 1 reaction 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
38/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
java
Domain
tooling

Research direction

Start by tracing how google-java-format accepts parser and command-line options, then review the JLS Section 3.8 discussion of version-sensitive reserved identifiers. Determine whether source or release is the appropriate user-facing option, and verify that formatting older Java source with identifiers such as var, yield, or record succeeds while current-source formatting remains unchanged.

Written by the indexing model from the issue text.

Description

When formatting files with google-java-format, the parser uses the same source version as its own runtime version (running google-java-format on JDK X implies that that Java source files are conformant with JDK X), but this is actually not necessary true and files may be aiming for a different (older) Java version. Nowadays it is a common pattern to use --release flag to compiler for a specific older version of the language using a newer JDK.

Unfortunately Java language is not fully backward compatible and some features have introduced breaking changes like reserved identifiers var, with, yieldorrecord` (see current list in JLS Section 3.8)

For files who were designed to compile with an older Java version and who are using now reserved identifiers, this cause their processing with google-java-format using a recent JDK version to fail.

A solution would be to allow to pass either the source or the release option to the java parser to adapt its own parsing to the java version used by the file.

Dominant language
Java
Stars
6.2k
Forks
936
Avg merge
6m
Merged PRs (30d)
3

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from google/google-java-format

All issues in google/google-java-format

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.