< prev index next >

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

Print this page
@@ -1,7 +1,7 @@
  /*
-  * Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
+  * Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved.
   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   *
   * This code is free software; you can redistribute it and/or modify it
   * under the terms of the GNU General Public License version 2 only, as
   * published by the Free Software Foundation.

@@ -278,29 +278,33 @@
              StringBuilder sb = new StringBuilder();
              sb.append("public class InnerClassesSrc {")
                      .append(toString(outerMod)).append(' ')
                      .append(outerClassType).append(' ')
                      .append(prefix).append(' ').append('\n');
+             if (outerClassType == ClassType.CLASS && outerMod.contains(Modifier.ABSTRACT))
+                 sb.append("int f;\n"); // impose identity to make testing predicatable
              int count = 0;
              Map<String, Set<String>> class2Flags = new HashMap<>();
              List<String> syntheticClasses = new ArrayList<>();
              for (List<Modifier> innerMod : innerMods) {
                  ++count;
                  String privateConstructor = "";
                  if (hasSyntheticClass && !innerMod.contains(Modifier.ABSTRACT)) {
                      privateConstructor = "private A" + count + "() {}";
                      syntheticClasses.add("new A" + count + "();");
                  }
+                 String instField = innerClassType == ClassType.CLASS && innerMod.contains(Modifier.ABSTRACT) ?
+                                                 "int f; " : ""; // impose identity to make testing predicatable
                  sb.append(toString(innerMod)).append(' ');
-                 sb.append(String.format("%s A%d {%s}\n", innerClassType, count, privateConstructor));
+                 sb.append(String.format("%s A%d { %s %s}\n", innerClassType, count, instField, privateConstructor));
                  Set<String> flags = getFlags(innerClassType, innerMod);
                  class2Flags.put("A" + count, flags);
              }
              if (hasSyntheticClass) {
                  // Source to generate synthetic classes
                  sb.append(syntheticClasses.stream().collect(Collectors.joining(" ", "{", "}")));
-                 class2Flags.put("1", new HashSet<>(Arrays.asList("ACC_STATIC", "ACC_SYNTHETIC")));
+                 class2Flags.put("1", new HashSet<>(Arrays.asList("ACC_STATIC", "ACC_IDENTITY", "ACC_SYNTHETIC")));
              }
              sb.append(suffix).append("\n}");
              getAdditionalFlags(class2Flags, outerClassType, outerMod.toArray(new Modifier[outerMod.size()]));
              list.add(new TestCase(sb.toString(), class2Flags));
          }

@@ -375,10 +379,11 @@
  
      public enum ClassType {
          CLASS("class") {
              @Override
              public void addSpecificFlags(Set<String> flags) {
+                 flags.add("ACC_IDENTITY");
              }
          },
          INTERFACE("interface") {
              @Override
              public void addFlags(Set<String> flags) {

@@ -412,15 +417,17 @@
              @Override
              public void addSpecificFlags(Set<String> flags) {
                  flags.add("ACC_ENUM");
                  flags.add("ACC_FINAL");
                  flags.add("ACC_STATIC");
+                 flags.add("ACC_IDENTITY");
              }
          },
          OTHER("") {
              @Override
              public void addSpecificFlags(Set<String> flags) {
+                 flags.add("ACC_IDENTITY");
              }
          };
  
          private final String classType;
  

@@ -440,11 +447,12 @@
  
      public enum Modifier {
          PUBLIC("public"), PRIVATE("private"),
          PROTECTED("protected"), DEFAULT("default"),
          FINAL("final"), ABSTRACT("abstract"),
-         STATIC("static"), EMPTY("");
+         STATIC("static"), EMPTY(""),
+         IDENTITY("identity");
  
          private final String str;
  
          Modifier(String str) {
              this.str = str;
< prev index next >