langtools/test/tools/javac/NestedInnerClassNames.java
author duke
Sat, 01 Dec 2007 00:00:00 +0000
changeset 10 06bc494ca11e
child 863 3113c955a388
permissions -rw-r--r--
Initial load
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 4037746 4277279 4350658 4785453
06bc494ca11e Initial load
duke
parents:
diff changeset
     4
 * @summary Verify that an inner class cannot have the same simple name as an enclosing one.
06bc494ca11e Initial load
duke
parents:
diff changeset
     5
 * @author William Maddox (maddox)
06bc494ca11e Initial load
duke
parents:
diff changeset
     6
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
     7
 * @run shell NestedInnerClassNames.sh
06bc494ca11e Initial load
duke
parents:
diff changeset
     8
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
     9
06bc494ca11e Initial load
duke
parents:
diff changeset
    10
/*
06bc494ca11e Initial load
duke
parents:
diff changeset
    11
 * This program should compile with errors as marked.
06bc494ca11e Initial load
duke
parents:
diff changeset
    12
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    13
06bc494ca11e Initial load
duke
parents:
diff changeset
    14
public class NestedInnerClassNames {
06bc494ca11e Initial load
duke
parents:
diff changeset
    15
06bc494ca11e Initial load
duke
parents:
diff changeset
    16
    class NestedInnerClassNames {}              // ERROR
06bc494ca11e Initial load
duke
parents:
diff changeset
    17
06bc494ca11e Initial load
duke
parents:
diff changeset
    18
    void m1() {
06bc494ca11e Initial load
duke
parents:
diff changeset
    19
        class NestedInnerClassNames {}          // ERROR
06bc494ca11e Initial load
duke
parents:
diff changeset
    20
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    21
06bc494ca11e Initial load
duke
parents:
diff changeset
    22
    class foo {
06bc494ca11e Initial load
duke
parents:
diff changeset
    23
        class foo { }                           // ERROR
06bc494ca11e Initial load
duke
parents:
diff changeset
    24
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    25
06bc494ca11e Initial load
duke
parents:
diff changeset
    26
    void m2 () {
06bc494ca11e Initial load
duke
parents:
diff changeset
    27
        class foo {
06bc494ca11e Initial load
duke
parents:
diff changeset
    28
            class foo { }                       // ERROR
06bc494ca11e Initial load
duke
parents:
diff changeset
    29
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
    30
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    31
06bc494ca11e Initial load
duke
parents:
diff changeset
    32
    class bar {
06bc494ca11e Initial load
duke
parents:
diff changeset
    33
        class foo { }
06bc494ca11e Initial load
duke
parents:
diff changeset
    34
        class NestedInnerClassNames {}          // ERROR
06bc494ca11e Initial load
duke
parents:
diff changeset
    35
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    36
06bc494ca11e Initial load
duke
parents:
diff changeset
    37
    void m3() {
06bc494ca11e Initial load
duke
parents:
diff changeset
    38
        class bar {
06bc494ca11e Initial load
duke
parents:
diff changeset
    39
            class foo { }
06bc494ca11e Initial load
duke
parents:
diff changeset
    40
            class NestedInnerClassNames {}      // ERROR
06bc494ca11e Initial load
duke
parents:
diff changeset
    41
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
    42
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    43
06bc494ca11e Initial load
duke
parents:
diff changeset
    44
    class baz {
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
        class baz {                             // ERROR
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
            class baz { }                       // ERROR
06bc494ca11e Initial load
duke
parents:
diff changeset
    47
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    49
06bc494ca11e Initial load
duke
parents:
diff changeset
    50
    void m4() {
06bc494ca11e Initial load
duke
parents:
diff changeset
    51
        class baz {
06bc494ca11e Initial load
duke
parents:
diff changeset
    52
            class baz {                         // ERROR
06bc494ca11e Initial load
duke
parents:
diff changeset
    53
                class baz { }                   // ERROR
06bc494ca11e Initial load
duke
parents:
diff changeset
    54
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
    class foo$bar {
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
        class foo$bar {                         // ERROR
06bc494ca11e Initial load
duke
parents:
diff changeset
    60
            class foo { }
06bc494ca11e Initial load
duke
parents:
diff changeset
    61
            class bar { }
06bc494ca11e Initial load
duke
parents:
diff changeset
    62
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
    63
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    64
06bc494ca11e Initial load
duke
parents:
diff changeset
    65
    void m5() {
06bc494ca11e Initial load
duke
parents:
diff changeset
    66
        class foo$bar {
06bc494ca11e Initial load
duke
parents:
diff changeset
    67
            class foo$bar {                     // ERROR
06bc494ca11e Initial load
duke
parents:
diff changeset
    68
                class foo { }
06bc494ca11e Initial load
duke
parents:
diff changeset
    69
                class bar { }
06bc494ca11e Initial load
duke
parents:
diff changeset
    70
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
    71
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
    72
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    73
06bc494ca11e Initial load
duke
parents:
diff changeset
    74
    class $bar {
06bc494ca11e Initial load
duke
parents:
diff changeset
    75
        class foo {
06bc494ca11e Initial load
duke
parents:
diff changeset
    76
            class $bar { }                      // ERROR
06bc494ca11e Initial load
duke
parents:
diff changeset
    77
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
    78
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    79
06bc494ca11e Initial load
duke
parents:
diff changeset
    80
    void m6() {
06bc494ca11e Initial load
duke
parents:
diff changeset
    81
        class $bar {
06bc494ca11e Initial load
duke
parents:
diff changeset
    82
            class foo {
06bc494ca11e Initial load
duke
parents:
diff changeset
    83
                class $bar { }                  // ERROR
06bc494ca11e Initial load
duke
parents:
diff changeset
    84
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
    85
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
    86
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    87
06bc494ca11e Initial load
duke
parents:
diff changeset
    88
    class bar$bar {
06bc494ca11e Initial load
duke
parents:
diff changeset
    89
        class bar {
06bc494ca11e Initial load
duke
parents:
diff changeset
    90
            class bar{ }                       // ERROR
06bc494ca11e Initial load
duke
parents:
diff changeset
    91
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
    92
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    93
06bc494ca11e Initial load
duke
parents:
diff changeset
    94
    void m7() {
06bc494ca11e Initial load
duke
parents:
diff changeset
    95
        class bar$bar {
06bc494ca11e Initial load
duke
parents:
diff changeset
    96
            class bar {
06bc494ca11e Initial load
duke
parents:
diff changeset
    97
                class bar{ }                   // ERROR
06bc494ca11e Initial load
duke
parents:
diff changeset
    98
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
    99
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   100
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   101
06bc494ca11e Initial load
duke
parents:
diff changeset
   102
    // The name of the class below clashes with the name of the
06bc494ca11e Initial load
duke
parents:
diff changeset
   103
    // class created above for 'class foo { class foo {} }'.
06bc494ca11e Initial load
duke
parents:
diff changeset
   104
    // The clash follows from the naming requirements of the inner
06bc494ca11e Initial load
duke
parents:
diff changeset
   105
    // classes spec, but is most likely a specification bug.
06bc494ca11e Initial load
duke
parents:
diff changeset
   106
06bc494ca11e Initial load
duke
parents:
diff changeset
   107
    // Error may be reported here.  See 4278961.
06bc494ca11e Initial load
duke
parents:
diff changeset
   108
    // As of Merlin-beta b21, this now results in an error.
06bc494ca11e Initial load
duke
parents:
diff changeset
   109
    class foo$foo { }                           // ERROR
06bc494ca11e Initial load
duke
parents:
diff changeset
   110
06bc494ca11e Initial load
duke
parents:
diff changeset
   111
}