my dog learned polymorphism
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
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

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 ... ...

I agree. Here's the link:
subject: Overloading with Widen-and-Box - Sierra & Bates
It's not a secret anymore!