InterfaceAndInnerClsCtor.java revision 0:9a66ca7c79fa
1303231Sdim/*
2303231Sdim * Copyright 1999 Sun Microsystems, Inc.  All Rights Reserved.
3353358Sdim * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4353358Sdim *
5353358Sdim * This code is free software; you can redistribute it and/or modify it
6303231Sdim * under the terms of the GNU General Public License version 2 only, as
7303231Sdim * published by the Free Software Foundation.
8303231Sdim *
9303231Sdim * This code is distributed in the hope that it will be useful, but WITHOUT
10303231Sdim * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11303231Sdim * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12303231Sdim * version 2 for more details (a copy is included in the LICENSE file that
13314564Sdim * accompanied this code).
14303231Sdim *
15303231Sdim * You should have received a copy of the GNU General Public License version
16303231Sdim * 2 along with this work; if not, write to the Free Software Foundation,
17303231Sdim * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18303231Sdim *
19303231Sdim * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
20303231Sdim * CA 95054 USA or visit www.sun.com if you need additional information or
21303231Sdim * have any questions.
22303231Sdim */
23303231Sdim
24303231Sdim/**
25303231Sdim * @test
26303231Sdim * @bug 4221648
27303231Sdim * @summary If an interface has an inner class, the constructor for that inner
28303231Sdim * class must be accessible to the interface, regardless of whether it is
29303231Sdim * explicitly declared private.
30314564Sdim *
31327952Sdim * @clean InterfaceAndInnerClsCtor
32327952Sdim * @compile InterfaceAndInnerClsCtor.java
33303231Sdim */
34303231Sdim
35303231Sdimpublic interface InterfaceAndInnerClsCtor
36303231Sdim{
37303231Sdim    // All interface memebers are implicitly public. Hence, there is no need to
38303231Sdim    // have other inner classes with different access levels.
39314564Sdim    public static class Inner {
40327952Sdim        // A constructor for each of the possible access levels.
41303231Sdim        public Inner(boolean b) {}
42314564Sdim        Inner(char c) {}
43314564Sdim        protected Inner(int i) {}
44314564Sdim        private Inner() {}
45303231Sdim    }
46303231Sdim
47303231Sdim    // Verify that all of the constructors are accessible at compile time.
48303231Sdim    public final static Inner i0 = new Inner(true);
49303231Sdim    public final static Inner i1 = new Inner('a');
50303231Sdim    public final static Inner i2 = new Inner(7);
51303231Sdim    public final static Inner i3 = new Inner();
52303231Sdim}
53341825Sdim