8029179: javac produces a compile error for valid boolean expressions

Tue, 03 Dec 2013 18:13:18 +0000

author
vromero
date
Tue, 03 Dec 2013 18:13:18 +0000
changeset 2211
fb8c59cf26c8
parent 2210
a746587a1ff1
child 2212
4cb9de4dd420

8029179: javac produces a compile error for valid boolean expressions
Reviewed-by: jjg, jlahoda

src/share/classes/com/sun/tools/javac/parser/JavacParser.java file | annotate | diff | comparison | revisions
test/tools/javac/T8029179/CompileErrorForValidBooleanExpTest.java file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/classes/com/sun/tools/javac/parser/JavacParser.java	Tue Dec 03 18:50:26 2013 +0100
     1.2 +++ b/src/share/classes/com/sun/tools/javac/parser/JavacParser.java	Tue Dec 03 18:13:18 2013 +0000
     1.3 @@ -1596,6 +1596,7 @@
     1.4                          // Identifier, ')' '->' -> implicit lambda
     1.5                          return ParensResult.IMPLICIT_LAMBDA;
     1.6                      }
     1.7 +                    type = false;
     1.8                      break;
     1.9                  case FINAL:
    1.10                  case ELLIPSIS:
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/test/tools/javac/T8029179/CompileErrorForValidBooleanExpTest.java	Tue Dec 03 18:13:18 2013 +0000
     2.3 @@ -0,0 +1,56 @@
     2.4 +/*
     2.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
     2.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     2.7 + *
     2.8 + * This code is free software; you can redistribute it and/or modify it
     2.9 + * under the terms of the GNU General Public License version 2 only, as
    2.10 + * published by the Free Software Foundation.
    2.11 + *
    2.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    2.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    2.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    2.15 + * version 2 for more details (a copy is included in the LICENSE file that
    2.16 + * accompanied this code).
    2.17 + *
    2.18 + * You should have received a copy of the GNU General Public License version
    2.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    2.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    2.21 + *
    2.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    2.23 + * or visit www.oracle.com if you need additional information or have any
    2.24 + * questions.
    2.25 + */
    2.26 +
    2.27 +/*
    2.28 + * @test
    2.29 + * @bug 8029179
    2.30 + * @summary javac produces a compile error for valid boolean expressions
    2.31 + * @compile CompileErrorForValidBooleanExpTest.java
    2.32 + */
    2.33 +
    2.34 +public class CompileErrorForValidBooleanExpTest {
    2.35 +    static int a, b, c, d;
    2.36 +
    2.37 +    static void m() {
    2.38 +        boolean cond1 = (a < b & c > d);
    2.39 +        boolean cond2 = (f1() < f2() & c > d);
    2.40 +        boolean cond3 = (f1() < b & f3() > d);
    2.41 +        boolean cond4 = (f1() < b & f3() > 1);
    2.42 +    }
    2.43 +
    2.44 +    static int f1() {
    2.45 +        return 0;
    2.46 +    }
    2.47 +
    2.48 +    static int f2() {
    2.49 +        return 0;
    2.50 +    }
    2.51 +
    2.52 +    static int f3() {
    2.53 +        return 0;
    2.54 +    }
    2.55 +
    2.56 +    static int f4() {
    2.57 +        return 0;
    2.58 +    }
    2.59 +}

mercurial