< prev index next >

src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassReader.java

Print this page

1279                         Type type = poolReader.getType(nextChar());
1280                         RecordComponent c = new RecordComponent(name, type, sym);
1281                         readAttrs(c, AttributeKind.MEMBER);
1282                         components.add(c);
1283                     }
1284                     ((ClassSymbol) sym).setRecordComponents(components.toList());
1285                 }
1286             },
1287             new AttributeReader(names.PermittedSubclasses, V59, CLASS_ATTRIBUTE) {
1288                 @Override
1289                 protected boolean accepts(AttributeKind kind) {
1290                     return super.accepts(kind) && allowSealedTypes;
1291                 }
1292                 protected void read(Symbol sym, int attrLen) {
1293                     if (sym.kind == TYP) {
1294                         ListBuffer<Symbol> subtypes = new ListBuffer<>();
1295                         int numberOfPermittedSubtypes = nextChar();
1296                         for (int i = 0; i < numberOfPermittedSubtypes; i++) {
1297                             subtypes.add(poolReader.getClass(nextChar()));
1298                         }
1299                         ((ClassSymbol)sym).permitted = subtypes.toList();
1300                     }
1301                 }
1302             },
1303         };
1304 
1305         for (AttributeReader r: readers)
1306             attributeReaders.put(r.name, r);
1307     }
1308 
1309     protected void readEnclosingMethodAttr(Symbol sym) {
1310         // sym is a nested class with an "Enclosing Method" attribute
1311         // remove sym from it's current owners scope and place it in
1312         // the scope specified by the attribute
1313         sym.owner.members().remove(sym);
1314         ClassSymbol self = (ClassSymbol)sym;
1315         ClassSymbol c = poolReader.getClass(nextChar());
1316         NameAndType nt = optPoolEntry(nextChar(), poolReader::getNameAndType, null);
1317 
1318         if (c.members_field == null || c.kind != TYP)
1319             throw badClassFile("bad.enclosing.class", self, c);

2596             if (c.owner.kind != MDL) {
2597                 throw badClassFile("module.info.definition.expected");
2598             }
2599             currentModule = (ModuleSymbol) c.owner;
2600             int this_class = nextChar();
2601             // temp, no check on this_class
2602         }
2603 
2604         // class attributes must be read before class
2605         // skip ahead to read class attributes
2606         int startbp = bp;
2607         nextChar();
2608         char interfaceCount = nextChar();
2609         bp += interfaceCount * 2;
2610         char fieldCount = nextChar();
2611         for (int i = 0; i < fieldCount; i++) skipMember();
2612         char methodCount = nextChar();
2613         for (int i = 0; i < methodCount; i++) skipMember();
2614         readClassAttrs(c);
2615 
2616         if (c.permitted != null && !c.permitted.isEmpty()) {
2617             c.flags_field |= SEALED;
2618         }
2619 
2620         // reset and read rest of classinfo
2621         bp = startbp;
2622         int n = nextChar();
2623         if ((flags & MODULE) != 0 && n > 0) {
2624             throw badClassFile("module.info.invalid.super.class");
2625         }
2626         if (ct.supertype_field == null)
2627             ct.supertype_field =
2628                     optPoolEntry(n, idx -> poolReader.getClass(idx).erasure(types), Type.noType);
2629         n = nextChar();
2630         List<Type> is = List.nil();
2631         for (int i = 0; i < n; i++) {
2632             Type _inter = poolReader.getClass(nextChar()).erasure(types);
2633             is = is.prepend(_inter);
2634         }
2635         if (ct.interfaces_field == null)
2636             ct.interfaces_field = is.reverse();

1279                         Type type = poolReader.getType(nextChar());
1280                         RecordComponent c = new RecordComponent(name, type, sym);
1281                         readAttrs(c, AttributeKind.MEMBER);
1282                         components.add(c);
1283                     }
1284                     ((ClassSymbol) sym).setRecordComponents(components.toList());
1285                 }
1286             },
1287             new AttributeReader(names.PermittedSubclasses, V59, CLASS_ATTRIBUTE) {
1288                 @Override
1289                 protected boolean accepts(AttributeKind kind) {
1290                     return super.accepts(kind) && allowSealedTypes;
1291                 }
1292                 protected void read(Symbol sym, int attrLen) {
1293                     if (sym.kind == TYP) {
1294                         ListBuffer<Symbol> subtypes = new ListBuffer<>();
1295                         int numberOfPermittedSubtypes = nextChar();
1296                         for (int i = 0; i < numberOfPermittedSubtypes; i++) {
1297                             subtypes.add(poolReader.getClass(nextChar()));
1298                         }
1299                         ((ClassSymbol)sym).setPermittedSubclasses(subtypes.toList());
1300                     }
1301                 }
1302             },
1303         };
1304 
1305         for (AttributeReader r: readers)
1306             attributeReaders.put(r.name, r);
1307     }
1308 
1309     protected void readEnclosingMethodAttr(Symbol sym) {
1310         // sym is a nested class with an "Enclosing Method" attribute
1311         // remove sym from it's current owners scope and place it in
1312         // the scope specified by the attribute
1313         sym.owner.members().remove(sym);
1314         ClassSymbol self = (ClassSymbol)sym;
1315         ClassSymbol c = poolReader.getClass(nextChar());
1316         NameAndType nt = optPoolEntry(nextChar(), poolReader::getNameAndType, null);
1317 
1318         if (c.members_field == null || c.kind != TYP)
1319             throw badClassFile("bad.enclosing.class", self, c);

2596             if (c.owner.kind != MDL) {
2597                 throw badClassFile("module.info.definition.expected");
2598             }
2599             currentModule = (ModuleSymbol) c.owner;
2600             int this_class = nextChar();
2601             // temp, no check on this_class
2602         }
2603 
2604         // class attributes must be read before class
2605         // skip ahead to read class attributes
2606         int startbp = bp;
2607         nextChar();
2608         char interfaceCount = nextChar();
2609         bp += interfaceCount * 2;
2610         char fieldCount = nextChar();
2611         for (int i = 0; i < fieldCount; i++) skipMember();
2612         char methodCount = nextChar();
2613         for (int i = 0; i < methodCount; i++) skipMember();
2614         readClassAttrs(c);
2615 
2616         if (!c.getPermittedSubclasses().isEmpty()) {
2617             c.flags_field |= SEALED;
2618         }
2619 
2620         // reset and read rest of classinfo
2621         bp = startbp;
2622         int n = nextChar();
2623         if ((flags & MODULE) != 0 && n > 0) {
2624             throw badClassFile("module.info.invalid.super.class");
2625         }
2626         if (ct.supertype_field == null)
2627             ct.supertype_field =
2628                     optPoolEntry(n, idx -> poolReader.getClass(idx).erasure(types), Type.noType);
2629         n = nextChar();
2630         List<Type> is = List.nil();
2631         for (int i = 0; i < n; i++) {
2632             Type _inter = poolReader.getClass(nextChar()).erasure(types);
2633             is = is.prepend(_inter);
2634         }
2635         if (ct.interfaces_field == null)
2636             ct.interfaces_field = is.reverse();
< prev index next >