jQuery in Action, 3rd edition
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Overloading with Widen-and-Box - Sierra & Bates Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Overloading with Widen-and-Box - Sierra & Bates" Watch "Overloading with Widen-and-Box - Sierra & Bates" New topic
Author

Overloading with Widen-and-Box - Sierra & Bates

Jim Hoglund
Ranch Hand

Joined: Jan 09, 2008
Posts: 525
Below, to find a signature match, the compiler first widens the 'boy' value all the way to double.
Its second choice is to box it into a Byte. If this fails, the Byte object is "widened" to type Object
("Is-A" test). The compiler then gives up; it doesn't widen and then box 'boy' into a Short object.
The S&B book simply says, "This is just too much for the compiler." My question is for clarification. I don't see a conceptual problem with trying to find an override match
by looking across the wrapper classes. Why was it decided that this should not be done? Was it to
avoid the processing required?

Jim ... ...


BEE MBA PMP SCJP-6
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Overloading with Widen-and-Box - Sierra & Bates
 
jQuery in Action, 3rd edition