Skip to content

#2118: replace java.io.File usages with java.nio.file.Path#2120

Open
maybeec wants to merge 3 commits into
devonfw:mainfrom
maybeec:feature/2118-replace-file-with-nio-path
Open

#2118: replace java.io.File usages with java.nio.file.Path#2120
maybeec wants to merge 3 commits into
devonfw:mainfrom
maybeec:feature/2118-replace-file-with-nio-path

Conversation

@maybeec

@maybeec maybeec commented Jul 6, 2026

Copy link
Copy Markdown
Member

This PR fixes #2118

Implemented changes:

Removed all remaining java.io.File imports in favor of the java.nio.file.Path / Files API as required by the coding conventions ("Obsolete APIs": java.io.File → use java.nio.file.Path). These were latent violations because CI Checkstyle only runs on changed files.

  • PipRepositoryMock, MvnRepositoryMock, NpmRepositoryMock (test): File.separatorCharFileSystems.getDefault().getSeparator() (NIO-native separator accessor).
  • EclipseWorkspaceLockChecker (main): isLocked(File)isLocked(Path), new File(args[0])Path.of(...), isFile()Files.isRegularFile(...); RandomAccessFile is fed via inline .toFile(). Also replaced the pre-existing System.out usage message (a Checkstyle violation surfaced by editing the file) with the SLF4J logger.
  • EclipseWorkspaceLockCheckerTest (test): File.createTempFileFiles.createTempFile, new FilePath.of, .delete()Files.deleteIfExists.
  • Eclipse.java (main): fixed stale {@link File} javadoc on isLocked(Path) (parameter was already Path) 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.pathSeparatorCharSystem.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=*.java returns nothing.


Testing instructions

  1. Run mvn clean test — all tests pass. Affected tests were verified individually: SystemPathTest, EclipseWorkspaceLockCheckerTest, MvnRepositoryTest, MvnTest, NpmTest, PipTest (cli) and ProjectManagerTest (gui).
  2. Run Checkstyle on the changed files, e.g. mvn checkstyle:check — 0 violations; in particular no IllegalImport for java.io.File.
  3. Confirm no illegal import remains: grep -rn "import java.io.File;" --include=*.java returns nothing.

Checklist for this PR

  • When running mvn clean test locally all tests pass and build is successful
  • PR title is of the form #«issue-id»: «brief summary» (e.g. #921: fixed setup.bat). If no issue ID exists, title only.
  • PR top-level comment summarizes what has been done and contains link to addressed issue(s)
  • PR and issue(s) have suitable labels
  • Issue is set to In Progress and assigned to you or there is no issue (might happen for very small PRs)
  • You followed all coding conventions
  • You have added the issue implemented by your PR in CHANGELOG.adoc unless issue is labeled with internalinternal cleanup, no CHANGELOG entry needed
  • You have formulated clear instructions on how to test your contribution under "Testing instructions"

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
@github-project-automation github-project-automation Bot moved this to 🆕 New in IDEasy board Jul 6, 2026
@maybeec maybeec added the enhancement New feature or request label Jul 6, 2026
@maybeec maybeec moved this from 🆕 New to Team Review in IDEasy board Jul 6, 2026
@maybeec maybeec added the internal Nothing to be added to CHANGELOG, only internal story label Jul 6, 2026
@coveralls

coveralls commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

Coverage Report for CI Build 28849024574

Coverage increased (+0.03%) to 72.096%

Details

  • Coverage increased (+0.03%) from the base build.
  • Patch coverage: No coverable lines changed in this PR.
  • 23 coverage regressions across 3 files.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

23 previously-covered lines in 3 files lost coverage.

File Lines Losing Coverage Coverage
com/devonfw/tools/ide/locking/EclipseWorkspaceLockChecker.java 8 39.29%
com/devonfw/tools/ide/tool/eclipse/Eclipse.java 8 63.29%
com/devonfw/tools/ide/common/SystemPath.java 7 89.07%

Coverage Stats

Coverage Status
Relevant Lines: 16559
Covered Lines: 12437
Line Coverage: 75.11%
Relevant Branches: 7434
Covered Branches: 4861
Branch Coverage: 65.39%
Branches in Coverage %: Yes
Coverage Strength: 3.18 hits per line

💛 - Coveralls

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request internal Nothing to be added to CHANGELOG, only internal story

Projects

Status: Team Review

Development

Successfully merging this pull request may close these issues.

Replace non-compliant java.io.File usages with java.nio.file.Path per coding conventions

2 participants