CascadedInnerNewInstance.java revision 553:9d9f26857129
137960Ssos/*
260107Sobrien * Copyright (c) 1997, Oracle and/or its affiliates. All rights reserved.
360107Sobrien * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
437960Ssos *
537960Ssos * This code is free software; you can redistribute it and/or modify it
637960Ssos * under the terms of the GNU General Public License version 2 only, as
737960Ssos * published by the Free Software Foundation.
837960Ssos *
943334Syokota * This code is distributed in the hope that it will be useful, but WITHOUT
1037960Ssos * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1137960Ssos * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
1237960Ssos * version 2 for more details (a copy is included in the LICENSE file that
1337960Ssos * accompanied this code).
1437960Ssos *
1537960Ssos * You should have received a copy of the GNU General Public License version
1637960Ssos * 2 along with this work; if not, write to the Free Software Foundation,
1737960Ssos * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1837960Ssos *
1937960Ssos * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2037960Ssos * or visit www.oracle.com if you need additional information or have any
2137960Ssos * questions.
2237960Ssos */
2337960Ssos
2437960Ssos/*
2537960Ssos * @test
2637960Ssos * @bug 4030426
2737960Ssos * @summary Compiler should accept non-identifier expressions as
2837960Ssos * the outer instance in a 'new' expression for an inner class.
2937960Ssos *
3037960Ssos * @compile CascadedInnerNewInstance.java
3137960Ssos */
3237960Ssos
3337960Ssosclass CascadedInnerNewInstance {
3437960Ssos
3537960Ssos    Object createInner1InnerInnerMost() {
3637960Ssos        return new Inner1().new InnerMost().new InnerInnerMost();
3737960Ssos    }
3838140Syokota
3937960Ssos    class Inner1 {
4037960Ssos        class InnerMost {
4137960Ssos            class InnerInnerMost { }
4237960Ssos        }
4337960Ssos    }
4437960Ssos
4537960Ssos    Inner2.InnerMost createInner2InnerMost() {
4637960Ssos        return new Inner2().new InnerMost();
4737960Ssos    }
4837960Ssos
4937960Ssos    Object createInner2InnerInnerMost() {
5037960Ssos        return createInner2InnerMost().new InnerInnerMost();
5137960Ssos    }
5237960Ssos
5337960Ssos    class Inner2 {
5437960Ssos        class InnerMost {
5537960Ssos            class InnerInnerMost { }
5637960Ssos        }
5737960Ssos    }
5837960Ssos
5937960Ssos}
6037960Ssos