Repository navigation
Description
Issue Type: Bug
In the src folder of a Java Gradle project, there's the package structure:
projectRoot/
└── src/
├── main/
│ ├── java/
│ │ └── javasnap.domain/
│ │ └── cli/
│ │ └── ClStringArgs.java
└── test/
├── java/
│ └── javasnap.domain/
│ └── cli/
│ └── ClStringArgsTest.java
The ClStringArgs.java and ClStringArgsTest.java file contains the package declaration:
package javasnap.domain.cli;
Which is resulting in the package delcaration being highlighted as an error by VScode in both the test and production source file:
The declared package "javasnap.domain.cli" does not match the expected package "" Java(536871240)
It's also highlighting any reference to the class ClStringArgs in both the production and test source code with the following error:
ClStringArgs cannot be resolved to a type Java(16777218)
Splitting the directory name containing the dot character into two separate directories with one nested within the other causes this error to go away.
This package naming is valid for Gradle (and Java) to be able to compile and run source code. Attempting to add a directory to the Java Source Path via VScode results in the following message:
Unsupported operation. Please use build.gradle file to manage the source directories of gradle project.
Source: Language Support for Java(TM) by Red Hat (Extension)
This source directory structure is the default structuring of Gradle builds and this package naming convention is valid and used by multiple Java libraries. Can this bug get fixed or the feature of being able to resolve package names containing the dot character correctly be added to the roadmap?
Extension version: 0.60.0
VS Code version: Code 1.44.2 (ff915844119ce9485abfe8aa9076ec76b5300ddd, 2020-04-16T17:07:18.473Z)
OS version: Darwin x64 18.7.0
System Info
| Item | Value |
|---|---|
| CPUs | Intel(R) Core(TM) i7-3740QM CPU @ 2.70GHz (8 x 2700) |
| GPU Status | 2d_canvas: enabled flash_3d: enabled flash_stage3d: enabled flash_stage3d_baseline: enabled gpu_compositing: enabled metal: disabled_off multiple_raster_threads: enabled_on oop_rasterization: disabled_off protected_video_decode: unavailable_off rasterization: enabled skia_renderer: disabled_off_ok video_decode: enabled viz_display_compositor: enabled_on viz_hit_test_surface_layer: disabled_off_ok webgl: enabled webgl2: enabled |
| Load (avg) | 3, 3, 3 |
| Memory (System) | 16.00GB |
| Process Argv | . |
| Screen Reader | no |
| VM | 0% |
Activity
fbricon commentedon Apr 22, 2020
Please attach a sample project reproducing this issue
SnapperGee commentedon Apr 22, 2020
Since posting this issue I re-cloned the repo where the problem was occurring and that seemed to fix the issue. I even attempted making a new project and then manually re-creating the folder package structure with the dot notation in the name of one of the directories and it still appeared to be working. So whatever the issue was got fixed or was some odd thing in my environment. Either way, I'm going to close this issue for now, but I'm pretty sure i've seen this issue before with other projects so if it occurs again I'll reopen it and include a zip of the project.
fbricon commentedon Apr 22, 2020
It's actually a known limitation of the Eclipse compiler, but I'm trying to get more info about it
SnapperGee commentedon Apr 22, 2020
I was just about to say, the issue popped up again so I'm reopening it and including files. Here's what I did to recreate the issue. Essentially just made a default Gradle Java Library project, but since Gradle automatically creates nested directories when you use a dot character in the src package creation when it creates it, I manually go in and change the package structure:
And here's a zip of the entire project folder itself and my user settings.
project.zip
Ah, well I guess I'm somewhat relieved it's a known issue and possibly not some messed up environment setting.
I hope this helps and wish you luck in your research. Let me know if you need any more info!
Edit, add image of errors I'm seeing in VScode:

[-]Package containing dot character in Java Gradle project not being parsed correctly[/-][+]Package containing dot character not being parsed correctly[/+]tigerinus commentedon Nov 13, 2020
I encountered the same issue. I had to mv the ./x.y.z folder to ./x/y/z to work around the problem.
SnapperGee commentedon Nov 13, 2020
That's the issue though. It's a valid Java feature and offers greater flexibility when it comes to structuring a package or module with a structure and naming convention such as
./x.y/z. Restructuring the project so it's./x/y/zcan affect how it's implemented and is a work around for a bug that should be fixed.Thanks for the reply though! I appreciate it! :D
chris-sophos commentedon Jan 23, 2024
This is also an issue with directory names including a hyphen (
-), a keyword, or leading digits. By convention, these can be legalized with underscores, but the extension's error resolves into an empty package name.kamzata commentedon Feb 8, 2024
any news on this?
rgrunber commentedon Apr 11, 2024
There is work to support the
javaccompiler as an alternative that would feed its grammar model directly into the existing API we use (so nearly all features should be available as before). I think that work would resolve this issue, sincejavacwill compile such packages without issue.robstryker commentedon Oct 29, 2026
The java spec says how files are stored is up to the system. Javac doesn't actually validate where files are stored, but only tries to match a package name to some system path. To put it simply, allowing a "." in a physical folder name is not a first-class supported usecase, and javac happens to tolerate it, but there's no evidence in the spec or elsewhere it's "supported".
Unfortunately, our attempts at supporting the javac compiler instead of EJC are now dead. And we won't be reviving it.
And, since we're based on eclipse, and ECJ demands the dot to be a folder separator, we won't be fixing this unless someone volunteers to fix it up in ECJ.
Closing as wont-fix.