Strings in Switch
Paul Benedict
pbenedict at apache.org
Mon Dec 7 18:00:05 PST 2009
Joe,
On Mon, Dec 7, 2009 at 6:38 PM, Joseph D. Darcy <Joe.Darcy at sun.com> wrote:
> we are aware of the potential problem and are making a different judgment on
> the comfortability of the implementation strategy.
Have you thought about calculating the hash code, not as part of the
compiler's emitted bytecode, but when the class is loaded? Maybe it is
possible to desugar the code into a static { } so the compiler's
environment is taken out of the equation. However, this would mean
your double-switch would no longer be usable since case labels must be
constants, but there are no constant restrictions regarding if/else
chains.
Another possible strategy is to export the current String hashing
algorithm into some public method and make the JLS rely on that
method. Eh, I don't like it, but it's a theoretical option.
Paul
More information about the coin-dev
mailing list