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

Jan Lahoda jlahoda at openjdk.java.net
Thu Mar 18 09:17:58 UTC 2021

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.


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

Changes: https://git.openjdk.java.net/jdk/pull/3069/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=3069&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8263432
  Stats: 108 lines in 2 files changed: 103 ins; 0 del; 5 mod
  Patch: https://git.openjdk.java.net/jdk/pull/3069.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/3069/head:pull/3069

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

More information about the compiler-dev mailing list