6906748: Project Coin: Minor strings in switch cleanup

Reviewed-by: jjg
This commit is contained in:
Joe Darcy 2009-12-03 14:03:53 -08:00
parent fe7ec80761
commit 3229a1bbc6
2 changed files with 14 additions and 6 deletions

View File

@ -110,9 +110,6 @@ public enum Source {
}
/** Allow encoding errors, giving only warnings. */
public boolean allowStringsInSwitch() {
return compareTo(JDK1_7) >= 0;
}
public boolean allowEncodingErrors() {
return compareTo(JDK1_6) < 0;
}
@ -168,6 +165,9 @@ public enum Source {
public boolean allowUnderscoresInLiterals() {
return compareTo(JDK1_7) >= 0;
}
public boolean allowStringsInSwitch() {
return compareTo(JDK1_7) >= 0;
}
public static SourceVersion toSourceVersion(Source source) {
switch(source) {
case JDK1_2:

View File

@ -3117,7 +3117,6 @@ public class Lower extends TreeTranslator {
tree.cases = translateCases(tree.cases);
if (enumSwitch) {
result = visitEnumSwitch(tree);
patchTargets(result, tree, result);
} else if (stringSwitch) {
result = visitStringSwitch(tree);
} else {
@ -3146,7 +3145,9 @@ public class Lower extends TreeTranslator {
cases.append(c);
}
}
return make.Switch(selector, cases.toList());
JCSwitch enumSwitch = make.Switch(selector, cases.toList());
patchTargets(enumSwitch, tree, enumSwitch);
return enumSwitch;
}
public JCTree visitStringSwitch(JCSwitch tree) {
@ -3187,7 +3188,14 @@ public class Lower extends TreeTranslator {
* of String is the same in the compilation environment as
* in the environment the code will run in. The string
* hashing algorithm in the SE JDK has been unchanged
* since at least JDK 1.2.
* since at least JDK 1.2. Since the algorithm has been
* specified since that release as well, it is very
* unlikely to be changed in the future.
*
* Different hashing algorithms, such as the length of the
* strings or a perfect hashing algorithm over the
* particular set of case labels, could potentially be
* used instead of String.hashCode.
*/
ListBuffer<JCStatement> stmtList = new ListBuffer<JCStatement>();