langtools/test/tools/javac/T6326693/FinalVariableAssignedToInCatchBlockTest.java
author sogoel
Thu, 05 Jun 2014 10:57:10 -0700
changeset 24797 850ebd4d80a7
parent 18672 1d6d1be0a94f
permissions -rw-r--r--
8044072: Group 2: create .out files for OverrideChecks tests in tools/javac dir Reviewed-by: jjg
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
18672
1d6d1be0a94f 6326693: variable x might already have been assigned, when assignment is in catch block
vromero
parents:
diff changeset
     1
/*
1d6d1be0a94f 6326693: variable x might already have been assigned, when assignment is in catch block
vromero
parents:
diff changeset
     2
 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
1d6d1be0a94f 6326693: variable x might already have been assigned, when assignment is in catch block
vromero
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
1d6d1be0a94f 6326693: variable x might already have been assigned, when assignment is in catch block
vromero
parents:
diff changeset
     4
 *
1d6d1be0a94f 6326693: variable x might already have been assigned, when assignment is in catch block
vromero
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
1d6d1be0a94f 6326693: variable x might already have been assigned, when assignment is in catch block
vromero
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
1d6d1be0a94f 6326693: variable x might already have been assigned, when assignment is in catch block
vromero
parents:
diff changeset
     7
 * published by the Free Software Foundation.
1d6d1be0a94f 6326693: variable x might already have been assigned, when assignment is in catch block
vromero
parents:
diff changeset
     8
 *
1d6d1be0a94f 6326693: variable x might already have been assigned, when assignment is in catch block
vromero
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
1d6d1be0a94f 6326693: variable x might already have been assigned, when assignment is in catch block
vromero
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1d6d1be0a94f 6326693: variable x might already have been assigned, when assignment is in catch block
vromero
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
1d6d1be0a94f 6326693: variable x might already have been assigned, when assignment is in catch block
vromero
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
1d6d1be0a94f 6326693: variable x might already have been assigned, when assignment is in catch block
vromero
parents:
diff changeset
    13
 * accompanied this code).
1d6d1be0a94f 6326693: variable x might already have been assigned, when assignment is in catch block
vromero
parents:
diff changeset
    14
 *
1d6d1be0a94f 6326693: variable x might already have been assigned, when assignment is in catch block
vromero
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
1d6d1be0a94f 6326693: variable x might already have been assigned, when assignment is in catch block
vromero
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
1d6d1be0a94f 6326693: variable x might already have been assigned, when assignment is in catch block
vromero
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1d6d1be0a94f 6326693: variable x might already have been assigned, when assignment is in catch block
vromero
parents:
diff changeset
    18
 *
1d6d1be0a94f 6326693: variable x might already have been assigned, when assignment is in catch block
vromero
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1d6d1be0a94f 6326693: variable x might already have been assigned, when assignment is in catch block
vromero
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
1d6d1be0a94f 6326693: variable x might already have been assigned, when assignment is in catch block
vromero
parents:
diff changeset
    21
 * questions.
1d6d1be0a94f 6326693: variable x might already have been assigned, when assignment is in catch block
vromero
parents:
diff changeset
    22
 */
1d6d1be0a94f 6326693: variable x might already have been assigned, when assignment is in catch block
vromero
parents:
diff changeset
    23
1d6d1be0a94f 6326693: variable x might already have been assigned, when assignment is in catch block
vromero
parents:
diff changeset
    24
/*
1d6d1be0a94f 6326693: variable x might already have been assigned, when assignment is in catch block
vromero
parents:
diff changeset
    25
 * @test
1d6d1be0a94f 6326693: variable x might already have been assigned, when assignment is in catch block
vromero
parents:
diff changeset
    26
 * @bug 6356530
1d6d1be0a94f 6326693: variable x might already have been assigned, when assignment is in catch block
vromero
parents:
diff changeset
    27
 * @summary -Xlint:serial does not flag abstract classes with concrete methods/members
1d6d1be0a94f 6326693: variable x might already have been assigned, when assignment is in catch block
vromero
parents:
diff changeset
    28
 * @compile/fail/ref=FinalVariableAssignedToInCatchBlockTest.out -XDrawDiagnostics FinalVariableAssignedToInCatchBlockTest.java
1d6d1be0a94f 6326693: variable x might already have been assigned, when assignment is in catch block
vromero
parents:
diff changeset
    29
 */
1d6d1be0a94f 6326693: variable x might already have been assigned, when assignment is in catch block
vromero
parents:
diff changeset
    30
1d6d1be0a94f 6326693: variable x might already have been assigned, when assignment is in catch block
vromero
parents:
diff changeset
    31
import java.io.IOException;
1d6d1be0a94f 6326693: variable x might already have been assigned, when assignment is in catch block
vromero
parents:
diff changeset
    32
1d6d1be0a94f 6326693: variable x might already have been assigned, when assignment is in catch block
vromero
parents:
diff changeset
    33
public class FinalVariableAssignedToInCatchBlockTest {
1d6d1be0a94f 6326693: variable x might already have been assigned, when assignment is in catch block
vromero
parents:
diff changeset
    34
    public void m1(int o)
1d6d1be0a94f 6326693: variable x might already have been assigned, when assignment is in catch block
vromero
parents:
diff changeset
    35
    {
1d6d1be0a94f 6326693: variable x might already have been assigned, when assignment is in catch block
vromero
parents:
diff changeset
    36
        final int i;
1d6d1be0a94f 6326693: variable x might already have been assigned, when assignment is in catch block
vromero
parents:
diff changeset
    37
        try {
1d6d1be0a94f 6326693: variable x might already have been assigned, when assignment is in catch block
vromero
parents:
diff changeset
    38
            if (o == 1) {
1d6d1be0a94f 6326693: variable x might already have been assigned, when assignment is in catch block
vromero
parents:
diff changeset
    39
                throw new IOException();
1d6d1be0a94f 6326693: variable x might already have been assigned, when assignment is in catch block
vromero
parents:
diff changeset
    40
            } else if (o == 2) {
1d6d1be0a94f 6326693: variable x might already have been assigned, when assignment is in catch block
vromero
parents:
diff changeset
    41
                throw new InterruptedException();
1d6d1be0a94f 6326693: variable x might already have been assigned, when assignment is in catch block
vromero
parents:
diff changeset
    42
            } else {
1d6d1be0a94f 6326693: variable x might already have been assigned, when assignment is in catch block
vromero
parents:
diff changeset
    43
                throw new Exception();
1d6d1be0a94f 6326693: variable x might already have been assigned, when assignment is in catch block
vromero
parents:
diff changeset
    44
            }
1d6d1be0a94f 6326693: variable x might already have been assigned, when assignment is in catch block
vromero
parents:
diff changeset
    45
        } catch (IOException e) {
1d6d1be0a94f 6326693: variable x might already have been assigned, when assignment is in catch block
vromero
parents:
diff changeset
    46
            i = 1;
1d6d1be0a94f 6326693: variable x might already have been assigned, when assignment is in catch block
vromero
parents:
diff changeset
    47
        } catch (InterruptedException ie) {
1d6d1be0a94f 6326693: variable x might already have been assigned, when assignment is in catch block
vromero
parents:
diff changeset
    48
            i = 2;
1d6d1be0a94f 6326693: variable x might already have been assigned, when assignment is in catch block
vromero
parents:
diff changeset
    49
        } catch (Exception e) {
1d6d1be0a94f 6326693: variable x might already have been assigned, when assignment is in catch block
vromero
parents:
diff changeset
    50
            i = 3;
1d6d1be0a94f 6326693: variable x might already have been assigned, when assignment is in catch block
vromero
parents:
diff changeset
    51
        } finally {
1d6d1be0a94f 6326693: variable x might already have been assigned, when assignment is in catch block
vromero
parents:
diff changeset
    52
            i = 4;
1d6d1be0a94f 6326693: variable x might already have been assigned, when assignment is in catch block
vromero
parents:
diff changeset
    53
        }
1d6d1be0a94f 6326693: variable x might already have been assigned, when assignment is in catch block
vromero
parents:
diff changeset
    54
    }
1d6d1be0a94f 6326693: variable x might already have been assigned, when assignment is in catch block
vromero
parents:
diff changeset
    55
1d6d1be0a94f 6326693: variable x might already have been assigned, when assignment is in catch block
vromero
parents:
diff changeset
    56
    public void m2(int o)
1d6d1be0a94f 6326693: variable x might already have been assigned, when assignment is in catch block
vromero
parents:
diff changeset
    57
    {
1d6d1be0a94f 6326693: variable x might already have been assigned, when assignment is in catch block
vromero
parents:
diff changeset
    58
        final int i;
1d6d1be0a94f 6326693: variable x might already have been assigned, when assignment is in catch block
vromero
parents:
diff changeset
    59
        try {
1d6d1be0a94f 6326693: variable x might already have been assigned, when assignment is in catch block
vromero
parents:
diff changeset
    60
            if (o == 1) {
1d6d1be0a94f 6326693: variable x might already have been assigned, when assignment is in catch block
vromero
parents:
diff changeset
    61
                throw new IOException();
1d6d1be0a94f 6326693: variable x might already have been assigned, when assignment is in catch block
vromero
parents:
diff changeset
    62
            } else if (o == 2) {
1d6d1be0a94f 6326693: variable x might already have been assigned, when assignment is in catch block
vromero
parents:
diff changeset
    63
                throw new InterruptedException();
1d6d1be0a94f 6326693: variable x might already have been assigned, when assignment is in catch block
vromero
parents:
diff changeset
    64
            } else {
1d6d1be0a94f 6326693: variable x might already have been assigned, when assignment is in catch block
vromero
parents:
diff changeset
    65
                throw new Exception();
1d6d1be0a94f 6326693: variable x might already have been assigned, when assignment is in catch block
vromero
parents:
diff changeset
    66
            }
1d6d1be0a94f 6326693: variable x might already have been assigned, when assignment is in catch block
vromero
parents:
diff changeset
    67
        } catch (IOException e) {
1d6d1be0a94f 6326693: variable x might already have been assigned, when assignment is in catch block
vromero
parents:
diff changeset
    68
            i = 1;
1d6d1be0a94f 6326693: variable x might already have been assigned, when assignment is in catch block
vromero
parents:
diff changeset
    69
        } catch (InterruptedException ie) {
1d6d1be0a94f 6326693: variable x might already have been assigned, when assignment is in catch block
vromero
parents:
diff changeset
    70
            i = 2;
1d6d1be0a94f 6326693: variable x might already have been assigned, when assignment is in catch block
vromero
parents:
diff changeset
    71
        } catch (Exception e) {
1d6d1be0a94f 6326693: variable x might already have been assigned, when assignment is in catch block
vromero
parents:
diff changeset
    72
            i = 3;
1d6d1be0a94f 6326693: variable x might already have been assigned, when assignment is in catch block
vromero
parents:
diff changeset
    73
        }
1d6d1be0a94f 6326693: variable x might already have been assigned, when assignment is in catch block
vromero
parents:
diff changeset
    74
    }
1d6d1be0a94f 6326693: variable x might already have been assigned, when assignment is in catch block
vromero
parents:
diff changeset
    75
1d6d1be0a94f 6326693: variable x might already have been assigned, when assignment is in catch block
vromero
parents:
diff changeset
    76
    public void m3(int o) throws Exception
1d6d1be0a94f 6326693: variable x might already have been assigned, when assignment is in catch block
vromero
parents:
diff changeset
    77
    {
1d6d1be0a94f 6326693: variable x might already have been assigned, when assignment is in catch block
vromero
parents:
diff changeset
    78
        final int i;
1d6d1be0a94f 6326693: variable x might already have been assigned, when assignment is in catch block
vromero
parents:
diff changeset
    79
        try {
1d6d1be0a94f 6326693: variable x might already have been assigned, when assignment is in catch block
vromero
parents:
diff changeset
    80
            if (o == 1) {
1d6d1be0a94f 6326693: variable x might already have been assigned, when assignment is in catch block
vromero
parents:
diff changeset
    81
                throw new IOException();
1d6d1be0a94f 6326693: variable x might already have been assigned, when assignment is in catch block
vromero
parents:
diff changeset
    82
            } else if (o == 2) {
1d6d1be0a94f 6326693: variable x might already have been assigned, when assignment is in catch block
vromero
parents:
diff changeset
    83
                throw new InterruptedException();
1d6d1be0a94f 6326693: variable x might already have been assigned, when assignment is in catch block
vromero
parents:
diff changeset
    84
            } else {
1d6d1be0a94f 6326693: variable x might already have been assigned, when assignment is in catch block
vromero
parents:
diff changeset
    85
                throw new Exception();
1d6d1be0a94f 6326693: variable x might already have been assigned, when assignment is in catch block
vromero
parents:
diff changeset
    86
            }
1d6d1be0a94f 6326693: variable x might already have been assigned, when assignment is in catch block
vromero
parents:
diff changeset
    87
        } catch (IOException e) {
1d6d1be0a94f 6326693: variable x might already have been assigned, when assignment is in catch block
vromero
parents:
diff changeset
    88
            i = 1;
1d6d1be0a94f 6326693: variable x might already have been assigned, when assignment is in catch block
vromero
parents:
diff changeset
    89
        } catch (InterruptedException ie) {
1d6d1be0a94f 6326693: variable x might already have been assigned, when assignment is in catch block
vromero
parents:
diff changeset
    90
            i = 2;
1d6d1be0a94f 6326693: variable x might already have been assigned, when assignment is in catch block
vromero
parents:
diff changeset
    91
        }
1d6d1be0a94f 6326693: variable x might already have been assigned, when assignment is in catch block
vromero
parents:
diff changeset
    92
        i = 3;
1d6d1be0a94f 6326693: variable x might already have been assigned, when assignment is in catch block
vromero
parents:
diff changeset
    93
    }
1d6d1be0a94f 6326693: variable x might already have been assigned, when assignment is in catch block
vromero
parents:
diff changeset
    94
}