posted 17 years ago
[Henry]: Hmmm... Thinking about this a bit more. Autoboxing would require that the intValue() method be called. I don't think the specification would ever allow a method to be called and still be considered a constant. (I don't know. Just thinking out loud here)
That's correct, at least as far as what the current spec says. It's possible to imagine that they could, if they wanted to, add some special rules to incorporate Number wrappers as part of compile-time constant expressions. But I don't think there's really much need for this in any event. Any time you've got an Integer whose value is known at compile time, you could easily replace it with an int, after all. I suspect that the number of times people have had any real problems because of this is very small indeed. I doubt it's worth spending the time to rewrite those rules and modify the compiler accordingly.
"I'm not back." - Bill Harding, Twister