|
Java example source code file (NestedInnerClassNames.java)
The NestedInnerClassNames.java Java example source code/* * @test /nodynamiccopyright/ * @bug 4037746 4277279 4350658 4785453 * @summary Verify that an inner class cannot have the same simple name as an enclosing one. * @author William Maddox (maddox) * * @compile/fail/ref=NestedInnerClassNames.out -XDrawDiagnostics NestedInnerClassNames.java */ /* * This program should compile with errors as marked. */ public class NestedInnerClassNames { class NestedInnerClassNames {} // ERROR void m1() { class NestedInnerClassNames {} // ERROR } class foo { class foo { } // ERROR } void m2 () { class foo { class foo { } // ERROR } } class bar { class foo { } class NestedInnerClassNames {} // ERROR } void m3() { class bar { class foo { } class NestedInnerClassNames {} // ERROR } } class baz { class baz { // ERROR class baz { } // ERROR } } void m4() { class baz { class baz { // ERROR class baz { } // ERROR } } } class foo$bar { class foo$bar { // ERROR class foo { } class bar { } } } void m5() { class foo$bar { class foo$bar { // ERROR class foo { } class bar { } } } } class $bar { class foo { class $bar { } // ERROR } } void m6() { class $bar { class foo { class $bar { } // ERROR } } } class bar$bar { class bar { class bar{ } // ERROR } } void m7() { class bar$bar { class bar { class bar{ } // ERROR } } } // The name of the class below clashes with the name of the // class created above for 'class foo { class foo {} }'. // The clash follows from the naming requirements of the inner // classes spec, but is most likely a specification bug. // Error may be reported here. See 4278961. // As of Merlin-beta b21, this now results in an error. class foo$foo { } // ERROR } Other Java examples (source code examples)Here is a short list of links related to this Java NestedInnerClassNames.java source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.