JDK-8304995 : Release Note: Detection for Output File Clashes
  • Type: Sub-task
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 21
  • Priority: P4
  • Status: Resolved
  • Resolution: Delivered
  • Submitted: 2023-03-27
  • Updated: 2023-07-28
  • Resolved: 2023-03-31
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 21
21Resolved
Description
A new compiler lint flag, `output-file-clash`, enables detection of output file clashes. An output file clash is when the compiler intends to write two different output files, but due to the behavior of the operating system, these files end up being written to the same underlying file.

This usually happens due to case-insensitive file systems. For example, a class like this would cause two class files to be written to the same file, `Test$Inner.class`:

```java
public class Test {
    class Inner {
    }
    class INNER {
    }
}
```
However, this problem can also happen when the file system "normalizes" file names. For example, on macOS, compiling this class will generate such a clash:
```java
public class Test {
    interface Cafe\u0301 {
    }
    interface Caf\u00e9 {
    }
}
```
The reason is that `\u0301` is the Unicode character "Combining Acute Accent" which means "add an accent over the previous character". MacOS normalizes the letter `e` followed by a `\u0301` into a Unicode `\u00e9`, that is, `é`. However, the Java language treats these the two names, `Cafe\u0301` and `Caf\u00e9`, as distinct.

Compiling the example above on macOS with `-Xlint:output-file-clash` will now generate a warning like this:
```
    warning: [output-file-clash] output file written more than once: /home/test/Test$Café.class
```