有没有办法如何在IntelliJ IDEA中禁用Java 5和6的自动装箱,以免开发人员在IDE中使用此功能?
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:
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.
You can't really disable autoboxing without making your Java a form of "not-Java"; however, you can reduce the impact of some of the worst autoboxing issues.
FindBugs , a code analyzer, has a few specific autoboxing rules to avoid circumstances where autoboxing becomes quite problematic.
They all start with the "Bx:" identifier:
You can integrate a Findbug report into your build, and depending on the build system you use, even have the build complain or fail based on the presence of issues found by FindBugs.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.