Call for feedback -- switch expressions in JDK 12

Alex Buckley alex.buckley at oracle.com
Sat Mar 30 00:19:19 UTC 2019


Hi everyone,

People often ask how they can contribute to the Java development 
process. One of the easiest ways is to try out new features _on real 
code_ and share your experiences. We would love to hear how you're using 
the new language feature available on a preview basis in JDK 12 -- 
switch expressions.

Switch expressions make it easy to express multi-way conditionals in a 
compact, readable manner. Unlike switch statements, switch expressions 
don't fall through from one case to the next. Also, switch expressions 
on enums don't require a default if the cases are exhaustive. Also, 
multiple labels per case. See http://openjdk.java.net/jeps/325 for more.

To try switch expressions in your favorite environment:
- IntelliJ IDEA 2019.1: 
https://blog.jetbrains.com/idea/2019/02/java-12-and-intellij-idea/
- Eclipse 4.11: https://www.eclipse.org/eclipse/news/4.11/jdt.php#Java12
- Apache NetBeans 11.0: 
https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=103091452
- jshell in JDK 12: pass `--enable-preview`
- javac in JDK 12: pass `--release 12 --enable-preview`

What works? What doesn't work? What was surprising? (Asking about use of 
the language feature, not setup of the IDE.)

Please respond here, or on the amber-dev list. Thank you in advance!

Alex


More information about the jdk-dev mailing list