Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why auto-boxing marked as a warning?

I understand that auto un-boxing should be done with care because the reference that is being un-boxed can be null. Why is auto-boxing marked as warning as well? Are there some pitfalls I am missing here?

like image 483
Artium Avatar asked Nov 23 '11 19:11

Artium


2 Answers

I was going to disable this Eclipse warning but the following article made me consider not to. I'm still not completely sure but it looks to me like those might be good reasons to just avoid autoboxing.

https://effective-java.com/2010/05/the-advantages-and-traps-of-autoboxing/

like image 153
SantiBailors Avatar answered Oct 06 '22 20:10

SantiBailors


If you don't expect performance issues (in terms of micro-optimization) you can safely disable this warning. It is just an indication in case you're not aware that auto-boxing happends here. In business-logic code where you have I/O overhead (due to DB transactions or disc access) auto-boxing hardly becomes a performance issue.

like image 32
stacker Avatar answered Oct 06 '22 18:10

stacker