Switch expression with string concatenation (original) (raw)
Jan Lahoda jan.lahoda at oracle.com
Tue Nov 20 12:10:12 UTC 2018
- Previous message: Switch expression with string concatenation
- Next message: Switch-expression with nested try
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hi Tagir,
Thanks for the report, I've filled it here: https://bugs.openjdk.java.net/browse/JDK-8214113
Jan
On 20.11.2018 10:40, Tagir Valeev wrote:
Hello!
Seems that switch expression behaves badly with string concatenation. Example: public class Java12Test { public static void main(String[] args) { String s = "foo"; System.out.println(s + switch(0) { default -> { s = "bar"; break 1; } }); System.out.println(s); } }
"C:\Program Files\Java\jdk-12\bin\java.exe" -version openjdk version "12-ea" 2019-03-19 OpenJDK Runtime Environment (build 12-ea+20) OpenJDK 64-Bit Server VM (build 12-ea+20, mixed mode, sharing) "C:\Program Files\Java\jdk-12\bin\javac.exe" --enable-preview --release=12 Java12Test.java Note: Java12Test.java uses preview language features. Note: Recompile with -Xlint:preview for details. "C:\Program Files\Java\jdk-12\bin\java.exe" --enable-preview Java12Test foo1 foo As you can see,
s = "bar"
assignment was not executed. With best regards, Tagir Valeev
- Previous message: Switch expression with string concatenation
- Next message: Switch-expression with nested try
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]