diff --git a/common.ant.xml b/common.ant.xml
index 7f8244aea7d..f46245f7deb 100755
--- a/common.ant.xml
+++ b/common.ant.xml
@@ -54,7 +54,7 @@
-
+
diff --git a/dev/core/src/com/google/gwt/dev/jjs/impl/GwtAstBuilder.java b/dev/core/src/com/google/gwt/dev/jjs/impl/GwtAstBuilder.java
index 354d9cdb65a..6cf609c4f10 100644
--- a/dev/core/src/com/google/gwt/dev/jjs/impl/GwtAstBuilder.java
+++ b/dev/core/src/com/google/gwt/dev/jjs/impl/GwtAstBuilder.java
@@ -547,7 +547,13 @@ public void endVisit(YieldStatement x, BlockScope scope) {
try {
SourceInfo info = makeSourceInfo(x);
JExpression expression = pop(x.expression);
- push(new JYieldStatement(info, expression));
+ if (x.switchExpression == null) {
+ // This is an implicit 'yield' in a case with an arrow - synthesize a break instead and
+ // wrap with a block so that the child count in JDT and GWT matches.
+ push(new JBlock(info, expression.makeStatement(), new JBreakStatement(info, null)));
+ } else {
+ push(new JYieldStatement(info, expression));
+ }
} catch (Throwable e) {
throw translateException(x, e);
}
diff --git a/dev/core/test/com/google/gwt/dev/javac/GeneratedClassnameFinderTest.java b/dev/core/test/com/google/gwt/dev/javac/GeneratedClassnameFinderTest.java
index 65926826dc2..8a5c6de23f1 100644
--- a/dev/core/test/com/google/gwt/dev/javac/GeneratedClassnameFinderTest.java
+++ b/dev/core/test/com/google/gwt/dev/javac/GeneratedClassnameFinderTest.java
@@ -105,36 +105,39 @@ public void testEnum() {
assertEquals(0, new EnumTester().getGeneratedClasses().size());
}
+ /**
+ * This test requires a lot of care and feeding to keep track of which version of Java the test
+ * classes were built with, and what the current release version is.
+ */
public void testJavacWeirdness() {
List classNames = new JavacWeirdnessTester().getGeneratedClasses();
- if (classNames.size() == 4) {
- // javac8:
- // JavacWeirdnessTester$1
+ if (classNames.size() == 3) {
+ // javac 11 with --release=11:
+ // javac 17 with --release=11:
+ // javac 21 with --release=11:
// JavacWeirdnessTester$2
// JavacWeirdnessTester$2Foo
// JavacWeirdnessTester$3Foo
assertFalse(classNames.get(0) + " should not contain Foo",
classNames.get(0).contains("Foo"));
- assertFalse(classNames.get(1) + " should not contain Foo",
- classNames.get(1).contains("Foo"));
+ assertTrue(classNames.get(1) + " should contain Foo", classNames.get(1).contains("Foo"));
assertTrue(classNames.get(2) + " should contain Foo", classNames.get(2).contains("Foo"));
- assertTrue(classNames.get(3) + " should contain Foo", classNames.get(3).contains("Foo"));
} else if (classNames.size() == 5) {
- // javac22:
+ // javac 22 with --release=11:
// JavacWeirdnessTester$1
// JavacWeirdnessTester$2
// JavacWeirdnessTester$1Foo
// JavacWeirdnessTester$2Foo
// JavacWeirdnessTester$3Foo
assertFalse(classNames.get(0) + " should not contain Foo",
- classNames.get(0).contains("Foo"));
+ classNames.get(0).contains("Foo"));
assertFalse(classNames.get(1) + " should not contain Foo",
- classNames.get(1).contains("Foo"));
+ classNames.get(1).contains("Foo"));
assertTrue(classNames.get(2) + " should contain Foo", classNames.get(2).contains("Foo"));
assertTrue(classNames.get(3) + " should contain Foo", classNames.get(2).contains("Foo"));
assertTrue(classNames.get(4) + " should contain Foo", classNames.get(3).contains("Foo"));
} else {
- fail("Expected 4 or 5 classes, found " + classNames);
+ fail("Expected 3 classes, found " + classNames);
}
}
diff --git a/doc/build.xml b/doc/build.xml
index 3d0f89d353b..1b777b094ad 100644
--- a/doc/build.xml
+++ b/doc/build.xml
@@ -144,7 +144,7 @@
sourcepath="${gwt.root}/user/super/com/google/gwt/emul:${gwt.root}/dev/core/super/com/google/gwt/dev/jjs/intrinsic"
encoding="UTF-8"
access="public"
- source="${javac.release}"
+ source="8"
packagenames="${JAVA_PKGS}"
docletpath="${project.build}/../build_tools/doctool/bin"
doclet="com.google.doctool.custom.JavaEmulSummaryDoclet">
diff --git a/user/src/com/google/gwt/junit/JUnitShell.java b/user/src/com/google/gwt/junit/JUnitShell.java
index 53f67a7cb2f..842c1ad9794 100644
--- a/user/src/com/google/gwt/junit/JUnitShell.java
+++ b/user/src/com/google/gwt/junit/JUnitShell.java
@@ -60,6 +60,7 @@
import com.google.gwt.dev.util.arg.ArgHandlerScriptStyle;
import com.google.gwt.dev.util.arg.ArgHandlerSetProperties;
import com.google.gwt.dev.util.arg.ArgHandlerSourceLevel;
+import com.google.gwt.dev.util.arg.ArgHandlerStrict;
import com.google.gwt.dev.util.arg.ArgHandlerWarDir;
import com.google.gwt.dev.util.arg.ArgHandlerWorkDirOptional;
import com.google.gwt.junit.JUnitMessageQueue.ClientStatus;
@@ -299,6 +300,7 @@ public int handle(String[] args, int tagIndex) {
registerHandler(new ArgHandlerFilterJsInteropExports(options));
registerHandler(new ArgHandlerSetProperties(options));
registerHandler(new ArgHandlerClosureFormattedOutput(options));
+ registerHandler(new ArgHandlerStrict(options));
/*
* ----- Options specific to JUnitShell -----
diff --git a/user/src/com/google/gwt/uibinder/attributeparsers/FieldReferenceConverter.java b/user/src/com/google/gwt/uibinder/attributeparsers/FieldReferenceConverter.java
index 7902374e3f6..98d13ccb17e 100644
--- a/user/src/com/google/gwt/uibinder/attributeparsers/FieldReferenceConverter.java
+++ b/user/src/com/google/gwt/uibinder/attributeparsers/FieldReferenceConverter.java
@@ -65,7 +65,7 @@ public static class IllegalFieldReferenceException extends RuntimeException {
interface Delegate {
/**
* Returns the types any parsed field references are expected to return.
- * Multiple values indicates an overload. E.g., in either a
+ * Multiple values indicates an overload. E.g., in <a href={...}>
either a
* String or a SafeUri is allowed.
*/
JType[] getTypes();
diff --git a/user/src/com/google/gwt/user/client/Window.java b/user/src/com/google/gwt/user/client/Window.java
index 972f16d3107..1ec68214daa 100644
--- a/user/src/com/google/gwt/user/client/Window.java
+++ b/user/src/com/google/gwt/user/client/Window.java
@@ -853,7 +853,7 @@ static void onClosed() {
}
static String onClosing() {
- if (closeHandlersInitialized) {
+ if (beforeCloseHandlersInitialized) {
Window.ClosingEvent event = new Window.ClosingEvent();
fireEvent(event);
return event.getMessage();
diff --git a/user/test-super/com/google/gwt/dev/jjs/super/com/google/gwt/dev/jjs/test/Java17Test.java b/user/test-super/com/google/gwt/dev/jjs/super/com/google/gwt/dev/jjs/test/Java17Test.java
index fc238a981b6..90960b0a115 100644
--- a/user/test-super/com/google/gwt/dev/jjs/super/com/google/gwt/dev/jjs/test/Java17Test.java
+++ b/user/test-super/com/google/gwt/dev/jjs/super/com/google/gwt/dev/jjs/test/Java17Test.java
@@ -494,4 +494,50 @@ public void testInlinedStringConstantsInCase() {
};
assertEquals(4, value);
}
+
+ // https://github.com/gwtproject/gwt/issues/10044
+ public void testCaseArrowLabelsVoidExpression() {
+ // Each switch is extracted to its own method to avoid the early return bug.
+ assertEquals("success", arrowWithVoidExpr());
+
+ // Arrow with non-void expr
+ assertEquals("success", arrowWithStringExpr());
+ assertEquals("success", arrowWithIntExpr());
+
+ // Arrow with a statement - doesn't fail as part of this bug. This exists to verify
+ // that JDT won't give us a yield with a statement somehow.
+ assertEquals("success", arrowWithStatement());
+ }
+
+ private static String arrowWithVoidExpr() {
+ switch(0) {
+ case 0 -> assertTrue(true);
+ };
+ return "success";
+ }
+
+ private static String arrowWithStringExpr() {
+ switch(0) {
+ case 0 -> new Object().toString();
+ };
+ return "success";
+ }
+
+ private static String arrowWithIntExpr() {
+ switch(0) {
+ case 0 -> new Object().hashCode();
+ };
+ return "success";
+ }
+
+ private static String arrowWithStatement() {
+ switch(0) {
+ case 0 -> {
+ if (true) {
+ new Object().toString();
+ }
+ }
+ };
+ return "success";
+ }
}
diff --git a/user/test/com/google/gwt/dev/jjs/test/Java17Test.java b/user/test/com/google/gwt/dev/jjs/test/Java17Test.java
index 39e0253397c..844ff25c38c 100644
--- a/user/test/com/google/gwt/dev/jjs/test/Java17Test.java
+++ b/user/test/com/google/gwt/dev/jjs/test/Java17Test.java
@@ -121,6 +121,9 @@ public void testSwitchExprInlining() {
public void testInlinedStringConstantsInCase() {
assertFalse(isGwtSourceLevel17());
}
+ public void testCaseArrowLabelsVoidExpression() {
+ assertFalse(isGwtSourceLevel17());
+ }
private boolean isGwtSourceLevel17() {
return JUnitShell.getCompilerOptions().getSourceLevel().compareTo(SourceLevel.JAVA17) >= 0;
diff --git a/user/test/com/google/gwt/junit/JUnitShellTest.java b/user/test/com/google/gwt/junit/JUnitShellTest.java
index e5b8534d6e0..19695aaa89f 100644
--- a/user/test/com/google/gwt/junit/JUnitShellTest.java
+++ b/user/test/com/google/gwt/junit/JUnitShellTest.java
@@ -45,7 +45,7 @@ public void testDefaultModuleUrl() throws Exception {
public void testArgOptimize() throws Exception {
parseGoodArgs("-optimize", "8", "-XdisableInlineLiteralParameters",
"-XdisableRemoveDuplicateFunctions", "-XdisableClusterSimilarFunctions",
- "-XdisableOrdinalizeEnums", "-XdisableOptimizeDataflow");
+ "-XdisableOrdinalizeEnums", "-XdisableOptimizeDataflow", "-strict");
}
private void parseGoodArgs(String... argsToUse) {