i'm not sure how much performance loss is done, but even the people at Sun
themselves make a point of saying not to use autoboxing/unboxing for
high-performance apps.
i just wrote a little test program that loops through and performs a
single addition to an integer 10 million times.
using a primitive integer, the loop takes on average just about 100
milliseconds.
rewriting the program to represent the integer as an Integer object, then
leaving the rest of the loop as it is for the autoboxing/unboxing, the
loop now takes on average about 2000 milliseconds. thats 20x slower!
then i rewrote the program again to store the cumulative result back in
the original primitive type, but now i'm constantly to that primitive type
an Integer object. this experiment should test for unboxing, rather than
both. the average time is about 150 milliseconds.
this indicated that the boxing is what takes a long time. so... i wrote
one final program that only does the boxing by storing the results of an
operation with two primitive types into an Integer object. the results
were once again an average time of well over 1000 milliseconds.
so, the lesson from this is that unboxing is relatively cheap and easy and
can be used in your app even if performance is a consideration. if many
autoboxes are going to occur however, consider using primitive types
instead.
hope this helps a bit.
murat