test/langtools/tools/javac/7023703/T7023703neg.java
author bobv
Tue, 07 Nov 2017 10:30:53 -0500
changeset 47801 c7b50c23ea71
parent 47216 71c04702a3d5
permissions -rw-r--r--
8190283: Default heap sizing options select a MaxHeapSize larger than available physical memory in some cases Reviewed-by: tschatzl, sjohanss
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
8627
e60ca990602f 7023703: Valid code doesn't compile
mcimadamore
parents:
diff changeset
     1
/*
e60ca990602f 7023703: Valid code doesn't compile
mcimadamore
parents:
diff changeset
     2
 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
e60ca990602f 7023703: Valid code doesn't compile
mcimadamore
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
e60ca990602f 7023703: Valid code doesn't compile
mcimadamore
parents:
diff changeset
     4
 *
e60ca990602f 7023703: Valid code doesn't compile
mcimadamore
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
e60ca990602f 7023703: Valid code doesn't compile
mcimadamore
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
e60ca990602f 7023703: Valid code doesn't compile
mcimadamore
parents:
diff changeset
     7
 * published by the Free Software Foundation.
e60ca990602f 7023703: Valid code doesn't compile
mcimadamore
parents:
diff changeset
     8
 *
e60ca990602f 7023703: Valid code doesn't compile
mcimadamore
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
e60ca990602f 7023703: Valid code doesn't compile
mcimadamore
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e60ca990602f 7023703: Valid code doesn't compile
mcimadamore
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
e60ca990602f 7023703: Valid code doesn't compile
mcimadamore
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
e60ca990602f 7023703: Valid code doesn't compile
mcimadamore
parents:
diff changeset
    13
 * accompanied this code).
e60ca990602f 7023703: Valid code doesn't compile
mcimadamore
parents:
diff changeset
    14
 *
e60ca990602f 7023703: Valid code doesn't compile
mcimadamore
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
e60ca990602f 7023703: Valid code doesn't compile
mcimadamore
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
e60ca990602f 7023703: Valid code doesn't compile
mcimadamore
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
e60ca990602f 7023703: Valid code doesn't compile
mcimadamore
parents:
diff changeset
    18
 *
e60ca990602f 7023703: Valid code doesn't compile
mcimadamore
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
e60ca990602f 7023703: Valid code doesn't compile
mcimadamore
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
e60ca990602f 7023703: Valid code doesn't compile
mcimadamore
parents:
diff changeset
    21
 * questions.
e60ca990602f 7023703: Valid code doesn't compile
mcimadamore
parents:
diff changeset
    22
 */
e60ca990602f 7023703: Valid code doesn't compile
mcimadamore
parents:
diff changeset
    23
e60ca990602f 7023703: Valid code doesn't compile
mcimadamore
parents:
diff changeset
    24
/* @test
e60ca990602f 7023703: Valid code doesn't compile
mcimadamore
parents:
diff changeset
    25
 * @bug 7023703
e60ca990602f 7023703: Valid code doesn't compile
mcimadamore
parents:
diff changeset
    26
 * @summary Valid code doesn't compile
e60ca990602f 7023703: Valid code doesn't compile
mcimadamore
parents:
diff changeset
    27
 * @compile/fail/ref=T7023703neg.out -XDrawDiagnostics T7023703neg.java
e60ca990602f 7023703: Valid code doesn't compile
mcimadamore
parents:
diff changeset
    28
 */
e60ca990602f 7023703: Valid code doesn't compile
mcimadamore
parents:
diff changeset
    29
e60ca990602f 7023703: Valid code doesn't compile
mcimadamore
parents:
diff changeset
    30
class T7023703neg {
e60ca990602f 7023703: Valid code doesn't compile
mcimadamore
parents:
diff changeset
    31
e60ca990602f 7023703: Valid code doesn't compile
mcimadamore
parents:
diff changeset
    32
    void testForLoop(boolean cond) {
e60ca990602f 7023703: Valid code doesn't compile
mcimadamore
parents:
diff changeset
    33
        final int bug;
e60ca990602f 7023703: Valid code doesn't compile
mcimadamore
parents:
diff changeset
    34
        final int bug2;
e60ca990602f 7023703: Valid code doesn't compile
mcimadamore
parents:
diff changeset
    35
        for (;cond;) {
e60ca990602f 7023703: Valid code doesn't compile
mcimadamore
parents:
diff changeset
    36
            final int item = 0;
e60ca990602f 7023703: Valid code doesn't compile
mcimadamore
parents:
diff changeset
    37
            bug2 = 1; //error
e60ca990602f 7023703: Valid code doesn't compile
mcimadamore
parents:
diff changeset
    38
        }
e60ca990602f 7023703: Valid code doesn't compile
mcimadamore
parents:
diff changeset
    39
        bug = 0; //ok
e60ca990602f 7023703: Valid code doesn't compile
mcimadamore
parents:
diff changeset
    40
    }
e60ca990602f 7023703: Valid code doesn't compile
mcimadamore
parents:
diff changeset
    41
e60ca990602f 7023703: Valid code doesn't compile
mcimadamore
parents:
diff changeset
    42
    void testForEachLoop(java.util.Collection<Integer> c) {
e60ca990602f 7023703: Valid code doesn't compile
mcimadamore
parents:
diff changeset
    43
        final int bug;
e60ca990602f 7023703: Valid code doesn't compile
mcimadamore
parents:
diff changeset
    44
        final int bug2;
e60ca990602f 7023703: Valid code doesn't compile
mcimadamore
parents:
diff changeset
    45
        for (Integer i : c) {
e60ca990602f 7023703: Valid code doesn't compile
mcimadamore
parents:
diff changeset
    46
            final int item = 0;
e60ca990602f 7023703: Valid code doesn't compile
mcimadamore
parents:
diff changeset
    47
            bug2 = 1; //error
e60ca990602f 7023703: Valid code doesn't compile
mcimadamore
parents:
diff changeset
    48
        }
e60ca990602f 7023703: Valid code doesn't compile
mcimadamore
parents:
diff changeset
    49
        bug = 0; //ok
e60ca990602f 7023703: Valid code doesn't compile
mcimadamore
parents:
diff changeset
    50
    }
e60ca990602f 7023703: Valid code doesn't compile
mcimadamore
parents:
diff changeset
    51
e60ca990602f 7023703: Valid code doesn't compile
mcimadamore
parents:
diff changeset
    52
    void testWhileLoop(boolean cond) {
e60ca990602f 7023703: Valid code doesn't compile
mcimadamore
parents:
diff changeset
    53
        final int bug;
e60ca990602f 7023703: Valid code doesn't compile
mcimadamore
parents:
diff changeset
    54
        final int bug2;
e60ca990602f 7023703: Valid code doesn't compile
mcimadamore
parents:
diff changeset
    55
        while (cond) {
e60ca990602f 7023703: Valid code doesn't compile
mcimadamore
parents:
diff changeset
    56
            final int item = 0;
e60ca990602f 7023703: Valid code doesn't compile
mcimadamore
parents:
diff changeset
    57
            bug2 = 1; //error
e60ca990602f 7023703: Valid code doesn't compile
mcimadamore
parents:
diff changeset
    58
        }
e60ca990602f 7023703: Valid code doesn't compile
mcimadamore
parents:
diff changeset
    59
        bug = 0; //ok
e60ca990602f 7023703: Valid code doesn't compile
mcimadamore
parents:
diff changeset
    60
    }
e60ca990602f 7023703: Valid code doesn't compile
mcimadamore
parents:
diff changeset
    61
e60ca990602f 7023703: Valid code doesn't compile
mcimadamore
parents:
diff changeset
    62
    void testDoWhileLoop(boolean cond) {
e60ca990602f 7023703: Valid code doesn't compile
mcimadamore
parents:
diff changeset
    63
        final int bug;
e60ca990602f 7023703: Valid code doesn't compile
mcimadamore
parents:
diff changeset
    64
        final int bug2;
e60ca990602f 7023703: Valid code doesn't compile
mcimadamore
parents:
diff changeset
    65
        do {
e60ca990602f 7023703: Valid code doesn't compile
mcimadamore
parents:
diff changeset
    66
            final int item = 0;
e60ca990602f 7023703: Valid code doesn't compile
mcimadamore
parents:
diff changeset
    67
            bug2 = 1; //error
e60ca990602f 7023703: Valid code doesn't compile
mcimadamore
parents:
diff changeset
    68
        } while (cond);
e60ca990602f 7023703: Valid code doesn't compile
mcimadamore
parents:
diff changeset
    69
        bug = 0; //ok
e60ca990602f 7023703: Valid code doesn't compile
mcimadamore
parents:
diff changeset
    70
    }
e60ca990602f 7023703: Valid code doesn't compile
mcimadamore
parents:
diff changeset
    71
}