Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disabling auto-boxing for Java in IntelliJ IDEA

Is there a way how to disable auto-boxing for Java 5 and 6 in IntelliJ IDEA, to not allow a developer to use this feature in the IDE?

like image 428
ses Avatar asked Dec 04 '22 11:12

ses


1 Answers

I don't think you can disable auto-boxing outright while maintaining the target compile version - that's a feature of the specific Java version.

What you can do in IntelliJ is change the inspection level of Auto-boxing to "Error". To do that:

  • Go to Settings > Inspections, and type "boxing" into the search bar.
  • Click on "Auto-boxing".
  • Set the severity to "Error". This will cause the inspections test to report any occurrence of auto-boxing as an error. You should do the same for auto-unboxing as well.

Further down the line, you can add code inspections which run when testing the code (PMD, FindBugs, Cobertura, et. al.) which will fail the build if anything is being auto-boxed or auto-unboxed.

like image 182
Makoto Avatar answered Dec 11 '22 10:12

Makoto