Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Upgrading to a new Java version: code analysis

I was wandering if there is a code analysis tool able to suggest code changes when upgrading to a new Java version.

For example:

  • look for .close() calls for autocloseable resources when upgrading to Java 7
  • look for multiple catch clauses with the same body when upgrading to Java 7
  • look for unnecessary manual boxing and unboxing when upgrading to Java 5
  • ...

Are there specific tools or rules by existing ones (e.g., Checkstyle) that could help?

like image 820
Matteo Avatar asked Dec 06 '25 03:12

Matteo


1 Answers

IntelliJ has a set of inspections tagged as "Language migration", that can help you spot locations where you could benefit from new language structures such as the enhanced for loop.

It can even automatically apply such advices to your whole codebase at once - if it's a no-risk transformation of course.

like image 175
Olivier Croisier Avatar answered Dec 08 '25 18:12

Olivier Croisier



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!