gnodet commented on PR #1165:
URL: 
https://github.com/apache/maven-compiler-plugin/pull/1165#issuecomment-7394855834

   _Claude Code on behalf of Guillaume Nodet_
   
   **Classpath duplicate detection issue**: The check 
`existingCp.contains(outputDirectory)` may fail if paths are represented 
differently (relative vs absolute, symlinks, '..' segments).
   
   The `outputDirectory` is normalized to absolute (line 106 in 
GraphIncrementalBuild: `this.outputDir = outputDir.toAbsolutePath()`), but 
existing classpath paths may be relative.
   
   **Scenario**:
   - `outputDirectory = /Users/foo/project/target/classes` (absolute)
   - `existingCp` contains `target/classes` (relative)
   - `contains()` returns false
   - `outputDirectory` added again
   - Classpath has both `/Users/foo/project/target/classes` and `target/classes`
   - Class resolution ambiguity
   
   **Fix**: Normalize paths before comparison:
   ```java
   Path normalizedOutput = outputDirectory.toAbsolutePath().normalize();
   boolean alreadyPresent = existingCp.stream()
       .anyMatch(p -> {
           try {
               return Files.isSameFile(p, normalizedOutput);
           } catch (IOException e) {
               return p.toAbsolutePath().normalize().equals(normalizedOutput);
           }
       });
   if (!alreadyPresent) {
       existingCp.addFirst(outputDirectory);
   }
   ```
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to