InnerClassesTest.java revision 2933:49d207bf704d
1/*
2 * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24
25/*
26 * @test
27 * @bug 8034854 8042251
28 * @summary Testing inner classes attributes.
29 * @library /tools/lib /tools/javac/lib ../lib
30 * @modules jdk.compiler/com.sun.tools.classfile
31 *          jdk.compiler/com.sun.tools.javac.api
32 *          jdk.compiler/com.sun.tools.javac.file
33 *          jdk.compiler/com.sun.tools.javac.main
34 * @build InnerClassesTestBase TestBase TestResult InMemoryFileManager ToolBox
35 * @run main InnerClassesTest
36 */
37
38import java.util.List;
39
40public class InnerClassesTest extends InnerClassesTestBase {
41
42    public static void main(String[] args) throws TestFailedException {
43        new InnerClassesTest().test("InnerClassesSrc");
44    }
45
46    private List<TestCase> generateClasses() {
47        setInnerClassType(ClassType.CLASS);
48        setHasSyntheticClass(true);
49        return super.generateTestCases();
50    }
51
52    private List<TestCase> generateEnums() {
53        setInnerOtherModifiers(Modifier.EMPTY, Modifier.STATIC);
54        setInnerClassType(ClassType.ENUM);
55        setHasSyntheticClass(false);
56        return super.generateTestCases();
57    }
58
59    private List<TestCase> generateInterfaces() {
60        setInnerOtherModifiers(Modifier.EMPTY, Modifier.ABSTRACT, Modifier.STATIC);
61        setInnerClassType(ClassType.INTERFACE);
62        return super.generateTestCases();
63    }
64
65    private List<TestCase> generateAnnotations() {
66        setInnerOtherModifiers(Modifier.EMPTY, Modifier.ABSTRACT, Modifier.STATIC);
67        setInnerClassType(ClassType.ANNOTATION);
68        return super.generateTestCases();
69    }
70
71    @Override
72    public void setProperties() {
73        setOuterAccessModifiers(Modifier.EMPTY);
74        setOuterOtherModifiers(Modifier.EMPTY);
75        setOuterClassType(ClassType.OTHER);
76    }
77
78    @Override
79    public List<TestCase> generateTestCases() {
80        List<TestCase> sources = generateClasses();
81        sources.addAll(generateEnums());
82        sources.addAll(generateInterfaces());
83        sources.addAll(generateAnnotations());
84        return sources;
85    }
86}
87