rewrite-static-analysis icon indicating copy to clipboard operation
rewrite-static-analysis copied to clipboard

Migrate from `java.io.File` to `java.nio.Path`

Open Pankraz76 opened this issue 8 months ago • 4 comments

Migrate from java.io.File to java.nio.Path.

It would be nice to have a migration for this massive task. Its might be a little complex but doable and highly aprechiated.

Basically we would like to automate something like this:

Image

https://github.com/checkstyle/checkstyle/pull/16861#discussion_r2042437612

https://docs.openrewrite.org/recipes/java/migrate/nio/file

Pankraz76 avatar Apr 15 '25 06:04 Pankraz76

Thanks for the suggestion; copying an earlier reply here:

it's a little more involved because we have to evaluate the flow leading into this whether all usages can be replaced, and whether that'd constitute a clear improvement. We do similar work when it comes to replacing JodaTime with the JDK classes, but there it's a little more clear cut that it's an improvement.

timtebeek avatar Apr 15 '25 07:04 timtebeek

This issue is about reviewing the use of MethodMatcher to improve the accuracy of static analysis in the OpenRewrite project. The author suggests evaluating whether MethodMatcher.matches() should be used instead of MethodInvocationMatcher.matches().

Hi! I took a look and it makes sense to align usage with MethodMatcher.matches() for more consistency across analysis cases, especially when working with method signatures in complex type hierarchies. I’d be happy to experiment with this change and submit a PR if you think it's the right direction. Let me know your thoughts!

hadiseShaaban avatar Apr 16 '25 05:04 hadiseShaaban

  • tests: https://github.com/openrewrite/rewrite-migrate-java/pull/705

Pankraz76 avatar Apr 16 '25 14:04 Pankraz76

This issue is stale because it has not had any activity for 60 days. Remove question label or comment or this will be closed in two weeks. Issues may be reopened when there is renewed interest.

github-actions[bot] avatar Jul 28 '25 11:07 github-actions[bot]