langtools/test/tools/javac/LocalClasses_2.java
author katleman
Thu, 21 Aug 2014 14:16:14 -0700
changeset 25878 6d561031123e
parent 6150 d055fa8ced62
permissions -rw-r--r--
Added tag jdk9-b27 for changeset 98ce0879ab4c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
06bc494ca11e Initial load
duke
parents:
diff changeset
     2
 * @test  /nodynamiccopyright/
06bc494ca11e Initial load
duke
parents:
diff changeset
     3
 * @bug 4074421 4277278 4785453
06bc494ca11e Initial load
duke
parents:
diff changeset
     4
 * @summary Verify that a local class cannot be redefined within its scope.
06bc494ca11e Initial load
duke
parents:
diff changeset
     5
 * @author William Maddox (maddox)
06bc494ca11e Initial load
duke
parents:
diff changeset
     6
 *
6150
d055fa8ced62 6971882: Remove -XDstdout from javac test
jjg
parents: 863
diff changeset
     7
 * @compile/fail/ref=LocalClasses_2.out -XDrawDiagnostics LocalClasses_2.java
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     8
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
     9
06bc494ca11e Initial load
duke
parents:
diff changeset
    10
class LocalClasses_2 {
06bc494ca11e Initial load
duke
parents:
diff changeset
    11
06bc494ca11e Initial load
duke
parents:
diff changeset
    12
    void foo() {
06bc494ca11e Initial load
duke
parents:
diff changeset
    13
        class Local { }
06bc494ca11e Initial load
duke
parents:
diff changeset
    14
        {
06bc494ca11e Initial load
duke
parents:
diff changeset
    15
            class Local { }                     // ERROR
06bc494ca11e Initial load
duke
parents:
diff changeset
    16
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
    17
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    18
06bc494ca11e Initial load
duke
parents:
diff changeset
    19
    void bar() {
06bc494ca11e Initial load
duke
parents:
diff changeset
    20
06bc494ca11e Initial load
duke
parents:
diff changeset
    21
        class Local { }
06bc494ca11e Initial load
duke
parents:
diff changeset
    22
06bc494ca11e Initial load
duke
parents:
diff changeset
    23
        class Baz {
06bc494ca11e Initial load
duke
parents:
diff changeset
    24
            void quux() {
06bc494ca11e Initial load
duke
parents:
diff changeset
    25
                class Local { }                 // OK
06bc494ca11e Initial load
duke
parents:
diff changeset
    26
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
    27
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
    28
06bc494ca11e Initial load
duke
parents:
diff changeset
    29
        class Quux {
06bc494ca11e Initial load
duke
parents:
diff changeset
    30
            void baz() {
06bc494ca11e Initial load
duke
parents:
diff changeset
    31
                class Random {
06bc494ca11e Initial load
duke
parents:
diff changeset
    32
                    void quem() {
06bc494ca11e Initial load
duke
parents:
diff changeset
    33
                        class Local { }         // OK
06bc494ca11e Initial load
duke
parents:
diff changeset
    34
                    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    35
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
    36
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
    37
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
    38
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    39
}