#2118: replace java.io.File usages with java.nio.file.Path#2120
Open
maybeec wants to merge 3 commits into
Open
#2118: replace java.io.File usages with java.nio.file.Path#2120maybeec wants to merge 3 commits into
maybeec wants to merge 3 commits into
Conversation
Remove all remaining java.io.File imports in favor of the NIO Path API as
required by the coding conventions:
- pip/mvn/npm repository mocks: File.separatorChar -> FileSystems.getDefault().getSeparator()
- EclipseWorkspaceLockChecker.isLocked(File) -> isLocked(Path) (and its test)
- SystemPath: File.pathSeparatorChar -> System.getProperty("path.separator")
- Eclipse: fix stale {@link File} javadoc to {@link Path}
- ProjectManagerTest: use Files.createFile / Files.move instead of File
- EclipseWorkspaceLockChecker: replace System.out with SLF4J logger
Collaborator
Coverage Report for CI Build 28849024574Coverage increased (+0.03%) to 72.096%Details
Uncovered ChangesNo uncovered changes found. Coverage Regressions23 previously-covered lines in 3 files lost coverage.
Coverage Stats💛 - Coveralls |
8 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes #2118
Implemented changes:
Removed all remaining
java.io.Fileimports in favor of thejava.nio.file.Path/FilesAPI as required by the coding conventions ("Obsolete APIs":java.io.File→ usejava.nio.file.Path). These were latent violations because CI Checkstyle only runs on changed files.PipRepositoryMock,MvnRepositoryMock,NpmRepositoryMock(test):File.separatorChar→FileSystems.getDefault().getSeparator()(NIO-native separator accessor).EclipseWorkspaceLockChecker(main):isLocked(File)→isLocked(Path),new File(args[0])→Path.of(...),isFile()→Files.isRegularFile(...);RandomAccessFileis fed via inline.toFile(). Also replaced the pre-existingSystem.outusage message (a Checkstyle violation surfaced by editing the file) with the SLF4J logger.EclipseWorkspaceLockCheckerTest(test):File.createTempFile→Files.createTempFile,new File→Path.of,.delete()→Files.deleteIfExists.Eclipse.java(main): fixed stale{@link File}javadoc onisLocked(Path)(parameter was alreadyPath) and dropped the now-unused import.ProjectManagerTest(gui):File+createNewFile()→Files.createFile;File+renameTo()→Files.move(rename success is now asserted via target-exists / source-gone).SystemPath(main):File.pathSeparatorChar→System.getProperty("path.separator").charAt(0)(there is no NIO accessor for the PATH-list separator).After this change
grep -rn "import java.io.File;" --include=*.javareturns nothing.Testing instructions
mvn clean test— all tests pass. Affected tests were verified individually:SystemPathTest,EclipseWorkspaceLockCheckerTest,MvnRepositoryTest,MvnTest,NpmTest,PipTest(cli) andProjectManagerTest(gui).mvn checkstyle:check— 0 violations; in particular noIllegalImportforjava.io.File.grep -rn "import java.io.File;" --include=*.javareturns nothing.Checklist for this PR
mvn clean testlocally all tests pass and build is successful#«issue-id»: «brief summary»(e.g.#921: fixed setup.bat). If no issue ID exists, title only.In Progressand assigned to you or there is no issue (might happen for very small PRs)internal— internal cleanup, no CHANGELOG entry needed