Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #15083

Re: case strings

From Lew <noone@lewscanon.com>
Newsgroups comp.lang.java.programmer
Subject Re: case strings
Date 2012-06-05 23:53 -0700
Organization albasani.net
Message-ID <jqmuo8$il0$1@news.albasani.net> (permalink)
References <robns7d4t1tn9g0q8i1g0rph1g36cnk7ko@4ax.com> <YVPyr.3287$At.402@newsfe23.iad> <0mips7l4ste07c530h6lqkvvk5ie5rie98@4ax.com>

Show all headers | View raw


Roedy Green wrote:
> If I were to learn string labels were handled it some clever way it
> would give me great pleasure.


Joseph D. Darcy's Oracle Weblog
<https://blogs.oracle.com/darcy/entry/project_coin_string_switch_anatomy>
"... com.sun.tools.javac.comp.Lower, the compiler phase which translates away 
syntactic sugar, lowering structures to trees implementing the formerly 
sugar-coated functionality. For example, Lower already had a method to 
translate enum switches into a switch on an integer value retrieved from an 
enum → int map. The initial strings in switch implementation uses a similar 
technique: a single string switch in source code is lowered into a series of 
two switches. The first switch is a new synthesized switch on the string's 
hash code, which gets mapped to a label's ordinal position on the list of case 
statements. The second switch is structurally identical to the original string 
switch from the source except that the string case labels are replaced by 
integer positions and the computed position from the synthesized switch is the 
expression being switched on."

and about the compliance tests:

"The new tests verify that the proper structural checks are enforced for 
string switches as well as verify that the proper execution paths are taken on 
different inputs for switches with a variety of control flow shapes, including 
multiple case labels, case labels with colliding hash codes, and nested switches."

N.b., this article links to
<http://blogs.sun.com/darcy/entry/how_to_cross_compile_for>
"... make sure to set the bootclasspath!"

Thanks for the chance to flex my google-fu.

> It would be sort of like everyone being issued a Ferrari powered
> electrically.

That would be a Tesla.

-- 
Lew
Honi soit qui mal y pense.
http://upload.wikimedia.org/wikipedia/commons/c/cf/Friz.jpg

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

case strings Roedy Green <see_website@mindprod.com.invalid> - 2012-06-03 11:40 -0700
  Re: case strings Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-06-03 13:37 -0700
    Re: case strings markspace <-@.> - 2012-06-03 19:19 -0700
    Re: case strings Roedy Green <see_website@mindprod.com.invalid> - 2012-06-04 07:53 -0700
      Re: case strings Lew <noone@lewscanon.com> - 2012-06-05 23:53 -0700
  Re: case strings Roedy Green <see_website@mindprod.com.invalid> - 2012-06-04 07:57 -0700
    Re: case strings "Mike Schilling" <mscottschilling@hotmail.com> - 2012-06-04 08:18 -0700
    Re: case strings Joshua Cranmer <Pidgeot18@verizon.invalid> - 2012-06-04 11:30 -0400
      Re: case strings Lew <noone@lewscanon.com> - 2012-06-06 00:15 -0700

csiph-web