eclipse-jdt / eclipse-jdt/eclipse.jdt.ui

Incorrect Java 9+ Code Generation in Java 7/8 Projects

Open
#2,819 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
59
Forks
127
Avg merge
23h 30m
Merged PRs (30d)
35

Description

Bug: Incorrect Java 9+ Code Generation in Java 7/8 Projects
Problem:
In the Eclipse Clean Up settings (under Java > Code Style > Clean Up > Java Feature > Section "Java 7"), there are two options that incorrectly generate Java 9+ code:

Convert 'java.version' to Runtime.version().toString()

Convert 'java.specification.version' to Runtime.version().feature()

The Issue:
**Although these settings are categorized under "Java 7", the method java.lang.Runtime.version() was not introduced until Java 9.**

If these options are active (e.g., in Save Actions), Eclipse automatically replaces stable System.getProperty calls with code that will not compile in projects targeting Java 7 or Java 8 (Common for legacy systems or Synology NAS environments).

Impact:

Breaks build compatibility for Java 8 and older.

Causes Compilation Error or NoSuchMethodError at runtime.

Misleads developers into thinking the new API is safe for Java 7+.

Solution/Workaround:
Disable both checkboxes in the Clean Up profile or use Project Specific Settings to prevent Eclipse from "modernizing" code for environments that don't support the Java 9 Module System API.

by gemini and Thomas Gürber

Contributor guide

Open the contributing guide

Research direction

Start in the Eclipse Clean Up settings under Java > Code Style > Clean Up > Java Feature > Java 7 and inspect the two options named in the issue. Verify the generated replacements against Java 7 and Java 8 compatibility, then confirm that the cleanup no longer emits Runtime.version() for those targets.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.