redhat-developer / redhat-developer/vscode-java

Package error not reported with "java.jdt.ls.javac.enabled":"on"

Open
#4,414 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
TypeScript
Stars
2.3k
Forks
546
Avg merge
20h 1m
Merged PRs (30d)
11

Description

Describe the bug
When using "java.jdt.ls.javac.enabled":"on" on a unmanaged project, if the package does not match the folder hierarchy, no error is reported in VSCode interface

To Reproduce

  1. Unzip Demo25-javac-on.zip
  2. Open folder ... Demo25-javac-on
  3. Open file foo\bar\ex02.java -> The package is incorrect (bar instead of foo.bar) but no error is reported
  4. File ex01.java has the correct package
  5. File ex03.java has no package (compact source file)

Expected behavior
A package error should be reported for ex02.java and ex03.java . In fact, the class file are not placed in the correct folders in the workspace cache folder (see left side of the picture below). When javac is on, the class are placed in folders according to the package declared in the java file instead of the original folder hierarchy. So since the class file matches the package, no package error is reported. The correct behavior is to keep the class files in the same folders of the source java files like when javac is off (right side of picture below)

Screenshots
Image

Environment

  • Operating System: Debian 13
  • JDK version: 25
  • Visual Studio Code version: 1.121
  • Java extension version: 1.54.0

Additional Information
Maybe it is a problem in the JDT-LS from Eclipse?

Contributor guide

Open the contributing guide

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.

Research direction

Unzip Demo25-javac-on.zip and reproduce the issue with "java.jdt.ls.javac.enabled":"on" by comparing foo\bar\ex02.java with ex01.java and ex03.java. Inspect how package diagnostics and workspace-cache class-file paths are produced, then verify that ex02.java and ex03.java report package errors and that cached classes preserve their source folders.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, typescript, vscode
Domain
developer-experience, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.