1 /*
2 * Copyright (c) 2014, 2024, 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 */
35 */
36
37 import java.util.*;
38
39 public class InnerClassesInLocalClassTest extends InnerClassesTestBase {
40
41 private final static Modifier[] LOCAL_CLASS_MODIFIERS =
42 new Modifier[]{Modifier.EMPTY, Modifier.ABSTRACT, Modifier.FINAL};
43 private final static String CLASS_TEMPLATE =
44 "public %CLASS% OuterClass {\n" +
45 "%SOURCE%\n" +
46 "}";
47
48 private final List<Data> innerClassesData;
49
50 public InnerClassesInLocalClassTest() {
51 innerClassesData = new ArrayList<>();
52 for (Modifier outerModifier : LOCAL_CLASS_MODIFIERS) {
53 StringBuilder sb = new StringBuilder();
54 sb.append(outerModifier.getString()).append(' ');
55 sb.append("class Local {");
56 Map<String, Set<String>> class2Flags = new HashMap<>();
57 for (int i = 0; i < LOCAL_CLASS_MODIFIERS.length; ++i) {
58 Modifier innerModifier = LOCAL_CLASS_MODIFIERS[i];
59 sb.append(innerModifier.getString()).append(' ')
60 .append("class").append(' ')
61 .append('A').append(i).append("{}\n");
62 class2Flags.put("A" + i, getFlags(innerModifier));
63 }
64 sb.append("};");
65 class2Flags.put("1Local", getFlags(outerModifier));
66 innerClassesData.add(new Data(sb.toString(), class2Flags));
67 }
68 }
69
70 public static void main(String[] args) throws TestFailedException {
71 InnerClassesTestBase test = new InnerClassesInLocalClassTest();
72 test.test("OuterClass$1Local", "1Local");
73 }
74
75 @Override
|
1 /*
2 * Copyright (c) 2014, 2025, 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 */
35 */
36
37 import java.util.*;
38
39 public class InnerClassesInLocalClassTest extends InnerClassesTestBase {
40
41 private final static Modifier[] LOCAL_CLASS_MODIFIERS =
42 new Modifier[]{Modifier.EMPTY, Modifier.ABSTRACT, Modifier.FINAL};
43 private final static String CLASS_TEMPLATE =
44 "public %CLASS% OuterClass {\n" +
45 "%SOURCE%\n" +
46 "}";
47
48 private final List<Data> innerClassesData;
49
50 public InnerClassesInLocalClassTest() {
51 innerClassesData = new ArrayList<>();
52 for (Modifier outerModifier : LOCAL_CLASS_MODIFIERS) {
53 StringBuilder sb = new StringBuilder();
54 sb.append(outerModifier.getString()).append(' ');
55 sb.append("class Local { int f; "); // impose identity to make testing predictable.
56 Map<String, Set<String>> class2Flags = new HashMap<>();
57 for (int i = 0; i < LOCAL_CLASS_MODIFIERS.length; ++i) {
58 Modifier innerModifier = LOCAL_CLASS_MODIFIERS[i];
59 sb.append(innerModifier.getString()).append(' ')
60 .append("class").append(' ')
61 .append('A').append(i).append("{}\n");
62 class2Flags.put("A" + i, getFlags(innerModifier));
63 }
64 sb.append("};");
65 class2Flags.put("1Local", getFlags(outerModifier));
66 innerClassesData.add(new Data(sb.toString(), class2Flags));
67 }
68 }
69
70 public static void main(String[] args) throws TestFailedException {
71 InnerClassesTestBase test = new InnerClassesInLocalClassTest();
72 test.test("OuterClass$1Local", "1Local");
73 }
74
75 @Override
|