Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix
package-info.java
identification on Windows
A colleague using Windows reported the issue discussed in #1652, even though we use (a fork of) Error Prone 2.7.1, which contains a fix for said issue. The problem appears to be that `UnnecessarilyFullyQualified` looks for a forward slash in `compilationUnitTree.getSourceFile().getName()`, though `FileObject#getName()` says: ```java /** * Returns a user-friendly name for this file object. The exact * value returned is not specified but implementations should take * care to preserve names as given by the user. For example, if * the user writes the filename {@code "BobsApp\Test.java"} on * the command line, this method should return {@code * "BobsApp\Test.java"} whereas the {@linkplain #toUri toUri} * method might return {@code * file:///C:/Documents%20and%20Settings/UncleBob/BobsApp/Test.java}. * * @return a user-friendly name */ ``` I found a similar bit of code in the `PackageInfo` check. This change replaces the forward slash with `File.separatorChar`. An alternative (presumably slightly less performant) fix is to rely on `FileObject#toUri` instead. Let me know if you prefer that approach. I'll update our fork with this change and ask my colleague to test the fix. Fixes #2404 COPYBARA_INTEGRATE_REVIEW=#2404 from PicnicSupermarket:bugfix/windows-package-info-detection e928dae PiperOrigin-RevId: 381954227
- Loading branch information