Integrated: 8263432: javac may report an invalid package/class clash on case insensitive filesystems

Jan Lahoda jlahoda at openjdk.java.net
Tue Apr 27 08:59:35 UTC 2021


On Thu, 18 Mar 2021 09:12:07 GMT, Jan Lahoda <jlahoda at openjdk.org> wrote:

> To implement the package/class clash check as per JLS 7.1, javac creates "phantom" packages with the same names as the classes and checks if these packages exist (implemented as a check if it has seen a source or class file in the corresponding directory). Every package created (phantom or not) gets registered to its enclosing `ModuleSymbol`, and when `ModuleSymbol.getEnclosedElements()` is called, the package is completed (i.e. its directory is listed).
> 
> This can cause an invalid package/class clash error to be reported in specific cases if there is a package and a class with names differing only in letter cases (like `org.jruby.runtime.callsite` and `org.jruby.runtime.CallSite`). What happens here is: the phantom package for the `org.jruby.runtime.CallSite` package is created, the package/class clash check is performed and passes (no errors). Then annotation processing calls `ModuleSymbol.getEnclosedElements()`, the phantom package's directory (`org/jruby/runtime/CallSite`) is listed from the filesystem, and contains some source files, so appears non-empty/existing (due to the case insensitive filesystem, the content of `org/jruby/runtime/callsite` directory is listed in fact). Then another round of annotation processing happens, and the package/class clash check is performed again. This time, the package appears to exist, and hence the check fails.
> 
> The proposal here is to avoid creating of the phantom packages (and hence registering them into `ModuleSymbol`) for the package/class clash check. That should prevent listing the package with the wrong name unnecessarily/unintentionally.

This pull request has now been integrated.

Changeset: 0a4c3382
Author:    Jan Lahoda <jlahoda at openjdk.org>
URL:       https://git.openjdk.java.net/jdk/commit/0a4c3382
Stats:     108 lines in 2 files changed: 103 ins; 0 del; 5 mod

8263432: javac may report an invalid package/class clash on case insensitive filesystems

Reviewed-by: vromero

-------------

PR: https://git.openjdk.java.net/jdk/pull/3069


More information about the compiler-dev mailing list