--- a/langtools/src/share/classes/com/sun/tools/javac/code/Source.java Mon Nov 23 19:58:05 2009 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Source.java Thu Dec 03 14:03:53 2009 -0800
@@ -110,9 +110,6 @@
}
/** 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 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:
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java Mon Nov 23 19:58:05 2009 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java Thu Dec 03 14:03:53 2009 -0800
@@ -3117,7 +3117,6 @@
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 @@
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 @@
* 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>();