< prev index next >

test/langtools/tools/javac/classfiles/attributes/innerclasses/InnerClassesInAnonymousClassTest.java

Print this page

42     private ClassType currentClassType;
43 
44     public static void main(String[] args) throws TestFailedException {
45         InnerClassesTestBase test = new InnerClassesInAnonymousClassTest();
46         test.test("InnerClassesSrc$1", "Anonymous", "1");
47     }
48 
49     @Override
50     public void setProperties() {
51         setOuterOtherModifiers(Modifier.EMPTY, Modifier.ABSTRACT, Modifier.STATIC);
52         setInnerAccessModifiers(Modifier.EMPTY);
53         setInnerOtherModifiers(Modifier.EMPTY, Modifier.ABSTRACT, Modifier.FINAL);
54         setOuterClassType(ClassType.OTHER);
55         setInnerClassType(ClassType.CLASS);
56         setSuffix("};}");
57     }
58 
59     @Override
60     public List<TestCase> generateTestCases() {
61         currentClassType = ClassType.CLASS;
62         setPrefix("class Anonymous {} {new Anonymous() {");
63         List<TestCase> sources = super.generateTestCases();
64 
65         currentClassType = ClassType.INTERFACE;
66         setPrefix("interface Anonymous {} {new Anonymous() {");
67         sources.addAll(super.generateTestCases());
68 
69         currentClassType = ClassType.ANNOTATION;
70         setPrefix("@interface Anonymous {} {new Anonymous() {@Override public "
71                 + "Class<? extends java.lang.annotation.Annotation> "
72                 + "annotationType() {return null;}");
73         sources.addAll(super.generateTestCases());
74         return sources;
75     }
76 
77     @Override
78     public void getAdditionalFlags(Map<String, Set<String>> class2Flags, ClassType type, Modifier... flags) {
79         super.getAdditionalFlags(class2Flags, type, flags);
80         class2Flags.put("Anonymous", getFlags(currentClassType, Arrays.asList(flags)));
81         class2Flags.put("1", new HashSet<>() {});
82     }
83 }

42     private ClassType currentClassType;
43 
44     public static void main(String[] args) throws TestFailedException {
45         InnerClassesTestBase test = new InnerClassesInAnonymousClassTest();
46         test.test("InnerClassesSrc$1", "Anonymous", "1");
47     }
48 
49     @Override
50     public void setProperties() {
51         setOuterOtherModifiers(Modifier.EMPTY, Modifier.ABSTRACT, Modifier.STATIC);
52         setInnerAccessModifiers(Modifier.EMPTY);
53         setInnerOtherModifiers(Modifier.EMPTY, Modifier.ABSTRACT, Modifier.FINAL);
54         setOuterClassType(ClassType.OTHER);
55         setInnerClassType(ClassType.CLASS);
56         setSuffix("};}");
57     }
58 
59     @Override
60     public List<TestCase> generateTestCases() {
61         currentClassType = ClassType.CLASS;
62         setPrefix("class Anonymous { int f; } {new Anonymous() {"); // impose identity to make testing predictable.
63         List<TestCase> sources = super.generateTestCases();
64 
65         currentClassType = ClassType.INTERFACE;
66         setPrefix("interface Anonymous {} {new Anonymous() {");
67         sources.addAll(super.generateTestCases());
68 
69         currentClassType = ClassType.ANNOTATION;
70         setPrefix("@interface Anonymous {} {new Anonymous() {@Override public "
71                 + "Class<? extends java.lang.annotation.Annotation> "
72                 + "annotationType() {return null;}");
73         sources.addAll(super.generateTestCases());
74         return sources;
75     }
76 
77     @Override
78     public void getAdditionalFlags(Map<String, Set<String>> class2Flags, ClassType type, Modifier... flags) {
79         super.getAdditionalFlags(class2Flags, type, flags);
80         class2Flags.put("Anonymous", getFlags(currentClassType, Arrays.asList(flags)));
81         class2Flags.put("1", new HashSet<>(Arrays.asList("ACC_IDENTITY")));
82     }
83 }
< prev index next >