< prev index next >

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

Print this page

305     }
306 
307     /**
308      * Methods returns flags which must have type.
309      *
310      * @param type class, interface, enum or annotation
311      * @param mods modifiers
312      * @return set of access flags
313      */
314     protected Set<String> getFlags(ClassType type, List<Modifier> mods) {
315         Set<String> flags = mods.stream()
316                 .map(Modifier::getString)
317                 .filter(str -> !str.isEmpty())
318                 .map(str -> "ACC_" + str.toUpperCase())
319                 .collect(Collectors.toSet());
320         type.addSpecificFlags(flags);
321         return flags;
322     }
323 
324     protected List<String> getCompileOptions() {
325         return Collections.emptyList();

326     }
327 
328     private List<List<Modifier>> getAllCombinations(Modifier[] accessModifiers, Modifier[] otherModifiers) {
329         List<List<Modifier>> list = new ArrayList<>();
330         for (Modifier access : accessModifiers) {
331             for (int i = 0; i < otherModifiers.length; ++i) {
332                 Modifier mod1 = otherModifiers[i];
333                 for (int j = i + 1; j < otherModifiers.length; ++j) {
334                     Modifier mod2 = otherModifiers[j];
335                     if (isForbidden(mod1, mod2)) {
336                         continue;
337                     }
338                     list.add(Arrays.asList(access, mod1, mod2));
339                 }
340                 if (mod1 == Modifier.EMPTY) {
341                     list.add(Collections.singletonList(access));
342                 }
343             }
344         }
345         return list;

422         private final String classType;
423 
424         ClassType(String clazz) {
425             this.classType = clazz;
426         }
427 
428         public abstract void addSpecificFlags(Set<String> flags);
429 
430         public String toString() {
431             return classType;
432         }
433 
434         public void addFlags(Set<String> set) {
435         }
436     }
437 
438     public enum Modifier {
439         PUBLIC("public"), PRIVATE("private"),
440         PROTECTED("protected"), DEFAULT("default"),
441         FINAL("final"), ABSTRACT("abstract"),
442         STATIC("static"), EMPTY("");

443 
444         private final String str;
445 
446         Modifier(String str) {
447             this.str = str;
448         }
449 
450         public String getString() {
451             return str;
452         }
453     }
454 }

305     }
306 
307     /**
308      * Methods returns flags which must have type.
309      *
310      * @param type class, interface, enum or annotation
311      * @param mods modifiers
312      * @return set of access flags
313      */
314     protected Set<String> getFlags(ClassType type, List<Modifier> mods) {
315         Set<String> flags = mods.stream()
316                 .map(Modifier::getString)
317                 .filter(str -> !str.isEmpty())
318                 .map(str -> "ACC_" + str.toUpperCase())
319                 .collect(Collectors.toSet());
320         type.addSpecificFlags(flags);
321         return flags;
322     }
323 
324     protected List<String> getCompileOptions() {
325         // Use a release before value classes for now.
326         return List.of("--release", "25");
327     }
328 
329     private List<List<Modifier>> getAllCombinations(Modifier[] accessModifiers, Modifier[] otherModifiers) {
330         List<List<Modifier>> list = new ArrayList<>();
331         for (Modifier access : accessModifiers) {
332             for (int i = 0; i < otherModifiers.length; ++i) {
333                 Modifier mod1 = otherModifiers[i];
334                 for (int j = i + 1; j < otherModifiers.length; ++j) {
335                     Modifier mod2 = otherModifiers[j];
336                     if (isForbidden(mod1, mod2)) {
337                         continue;
338                     }
339                     list.add(Arrays.asList(access, mod1, mod2));
340                 }
341                 if (mod1 == Modifier.EMPTY) {
342                     list.add(Collections.singletonList(access));
343                 }
344             }
345         }
346         return list;

423         private final String classType;
424 
425         ClassType(String clazz) {
426             this.classType = clazz;
427         }
428 
429         public abstract void addSpecificFlags(Set<String> flags);
430 
431         public String toString() {
432             return classType;
433         }
434 
435         public void addFlags(Set<String> set) {
436         }
437     }
438 
439     public enum Modifier {
440         PUBLIC("public"), PRIVATE("private"),
441         PROTECTED("protected"), DEFAULT("default"),
442         FINAL("final"), ABSTRACT("abstract"),
443         STATIC("static"), EMPTY(""),
444         IDENTITY("identity");
445 
446         private final String str;
447 
448         Modifier(String str) {
449             this.str = str;
450         }
451 
452         public String getString() {
453             return str;
454         }
455     }
456 }
< prev index next >