[JEP 325 Switch Expression] switch labeled block completion issue? (original) (raw)
Manoj Palat manojnp.java at gmail.com
Sat Dec 1 12:19:04 UTC 2018
- Previous message: Yocto Sumo [Was: OpenJDK 8 Segfault on Startup]
- Next message: [zero] zero VM fails to build on arm64 and ppc64el
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hi Jan, Thanks for the reply. I downloaded ea22 just now and checked and indeed the issue is fixed and I see the error message " error: switch rule completes without providing a value } ^ (switch rules in switch expressions must either provide a value or throw)" as expected.
Regards, Manoj
On Fri, Nov 30, 2018 at 2:55 PM Jan Lahoda <jan.lahoda at oracle.com> wrote:
Hi Manoj,
Please see: https://bugs.openjdk.java.net/browse/JDK-8212982 Which is marked as fixed in build 21. Jan On 28.11.2018 05:19, Manoj Palat wrote: > Hi Joe, all, > The following program compiles without errors. > > package se2; > > import java.io.IOException; > public class X { > public static int twice(int i) throws IOException { > int k = switch (i) { > case 1 -> { > System.out.println("hello"); > // break 1; > } > case 2 -> { > System.out.println("world"); > // break 2; > } > default -> 10; > }; > return k; > } > public static void main(String[] args) { > try { > System.out.println(X.twice(1)); > } catch (IOException e) { > //do nothing; > } > } > } > > $ javac12 --enable-preview -source 12 se2/X.java > Note: se2\X.java uses preview language features. > Note: Recompile with -Xlint:preview for details. > > $ java12 --enable-preview se2/X > hello > world > 10 > > Other details: > $ uname -a > CYGWINNT-6.1 XXXXX 2.9.0(0.318/5/3) 2017-09-12 10:18 x8664 Cygwin > > The output of the program is given above – essentially a fall-through akin > to a switch statement’s expected behavior. > However, From JLS 12 15.29.1,* “Given a switch expression, if the switch > block consists of switch labeled rules, then it is a compile-time error if > any switch labeled block can complete normally. If, on the other hand, the > switch block consists of switch labeled statement groups, then it is a > compile-time error if either the last statement in the switch block can > complete normally, or the switch block includes one or more switch labels > at the end.” * > > From the above I expected a compilation error to be shown since the case 1 > and case 2 arms can complete normally without a break expression. > > Is this an error in Javac or is it a wrong interpretation of "complete > normally" in the spec on my part? > (Once the break expressions are uncommented, the switch expression returns > the appropriate values which is of course the correct behavior.) I am > using ea 20 for this. > > Regards, > Manoj Palat > Eclipse Java Dev, > IBM. > > PS: I had sent this mail yesterday from my IBM official id, but I don;t see > that mail in the mailing list yet - hence resending from personal id. > > From: "Joseph D. Darcy" <joe.darcy at oracle.com> > To: jdk-dev <jdk-dev at openjdk.java.net> > Date: 11/27/2018 06:29 AM > Subject: Reminder: submit CSRs for JDK 12 with sufficient time ahead of > rampdown 1 milestone > Sent by: "jdk-dev" <jdk-dev-bounces at openjdk.java.net> > > > > Hello, > > As a reminder, per the JDK 12 schedule > ( > https://urldefense.proofpoint.com/v2/url?u=http-3A_openjdk.java.netprojectsjdk12&d=DwICaQ&c=jfiaSHvJObTbx-siA1ZOg&r=A51zLdywEjS50U7u2UMWvsDIrUGEJ5IDXskL5MxIEjA&m=NBCxwvEUF6bxl1FYxFdnHSL7MKL5Ya8ynDOXXPMdM4&s=nQVLCHjGW7vanaEOQjwFI3syk30KByjLdaV09RMXlA&e= ) > rampdown phase 1 of the > release is coming up in a few weeks on Dec. 13, 2018. > > If you are planning to get a change into JDK 12 before the rampdown 1 > milestone and the change requires a CSR, the CSR needs to be an the > Approved state before the change is pushed. The nominal review time of > the CSR is one week. Note this is the time to review, not necessarily > the time to approve. As with code reviews, the CSR process can provide > feedback which has to be acted upon before a request is approved. > > Please plan accordingly; cheers, > > -Joe > CSR Lead >
- Previous message: Yocto Sumo [Was: OpenJDK 8 Segfault on Startup]
- Next message: [zero] zero VM fails to build on arm64 and ppc64el
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]