< prev index next >

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

Print this page




 389                 databuf.appendChar(poolWriter.putName(s.name));
 390                 databuf.appendChar(flags);
 391             }
 392             // Now write the captured locals
 393             for (VarSymbol s : m.capturedLocals) {
 394                 final int flags =
 395                     ((int) s.flags() & (FINAL | SYNTHETIC | MANDATED)) |
 396                     ((int) m.flags() & SYNTHETIC);
 397                 databuf.appendChar(poolWriter.putName(s.name));
 398                 databuf.appendChar(flags);
 399             }
 400             endAttr(attrIndex);
 401             return 1;
 402         } else
 403             return 0;
 404     }
 405 
 406 
 407     private void writeParamAnnotations(List<VarSymbol> params,
 408                                        RetentionPolicy retention) {

 409         for (VarSymbol s : params) {
 410             ListBuffer<Attribute.Compound> buf = new ListBuffer<>();
 411             for (Attribute.Compound a : s.getRawAttributes())
 412                 if (types.getRetention(a) == retention)
 413                     buf.append(a);
 414             databuf.appendChar(buf.length());
 415             for (Attribute.Compound a : buf)
 416                 writeCompoundAttribute(a);
 417         }
 418 
 419     }
 420 
 421     private void writeParamAnnotations(MethodSymbol m,
 422                                        RetentionPolicy retention) {
 423         databuf.appendByte(m.params.length());
 424         writeParamAnnotations(m.params, retention);
 425     }
 426 
 427     /** Write method parameter annotations;
 428      *  return number of attributes written.
 429      */
 430     int writeParameterAttrs(MethodSymbol m) {
 431         boolean hasVisible = false;
 432         boolean hasInvisible = false;
 433         if (m.params != null) {
 434             for (VarSymbol s : m.params) {
 435                 for (Attribute.Compound a : s.getRawAttributes()) {
 436                     switch (types.getRetention(a)) {
 437                     case SOURCE: break;
 438                     case CLASS: hasInvisible = true; break;
 439                     case RUNTIME: hasVisible = true; break;
 440                     default: // /* fail soft */ throw new AssertionError(vis);
 441                     }
 442                 }
 443             }
 444         }
 445 
 446         int attrCount = 0;
 447         if (hasVisible) {
 448             int attrIndex = writeAttr(names.RuntimeVisibleParameterAnnotations);
 449             writeParamAnnotations(m, RetentionPolicy.RUNTIME);
 450             endAttr(attrIndex);
 451             attrCount++;
 452         }
 453         if (hasInvisible) {
 454             int attrIndex = writeAttr(names.RuntimeInvisibleParameterAnnotations);
 455             writeParamAnnotations(m, RetentionPolicy.CLASS);
 456             endAttr(attrIndex);
 457             attrCount++;
 458         }
 459         return attrCount;
 460     }
 461 
 462 /**********************************************************************
 463  * Writing Java-language annotations (aka metadata, attributes)
 464  **********************************************************************/
 465 
 466     /** Write Java-language annotations; return number of JVM
 467      *  attributes written (zero or one).
 468      */
 469     int writeJavaAnnotations(List<Attribute.Compound> attrs) {
 470         if (attrs.isEmpty()) return 0;
 471         ListBuffer<Attribute.Compound> visibles = new ListBuffer<>();
 472         ListBuffer<Attribute.Compound> invisibles = new ListBuffer<>();
 473         for (Attribute.Compound a : attrs) {
 474             switch (types.getRetention(a)) {
 475             case SOURCE: break;


 814         for (ClassSymbol inner : poolWriter.innerClasses) {
 815             inner.markAbstractIfNeeded(types);
 816             char flags = (char) adjustFlags(inner.flags_field);
 817             if ((flags & INTERFACE) != 0) flags |= ABSTRACT; // Interfaces are always ABSTRACT
 818             flags &= ~STRICTFP; //inner classes should not have the strictfp flag set.
 819             if (dumpInnerClassModifiers) {
 820                 PrintWriter pw = log.getWriter(Log.WriterKind.ERROR);
 821                 pw.println("INNERCLASS  " + inner.name);
 822                 pw.println("---" + flagNames(flags));
 823             }
 824             databuf.appendChar(poolWriter.putClass(inner));
 825             databuf.appendChar(
 826                 inner.owner.kind == TYP && !inner.name.isEmpty() ? poolWriter.putClass((ClassSymbol)inner.owner) : 0);
 827             databuf.appendChar(
 828                 !inner.name.isEmpty() ? poolWriter.putName(inner.name) : 0);
 829             databuf.appendChar(flags);
 830         }
 831         endAttr(alenIdx);
 832     }
 833 



















 834     /**
 835      * Write NestMembers attribute (if needed)
 836      */
 837     int writeNestMembersIfNeeded(ClassSymbol csym) {
 838         ListBuffer<ClassSymbol> nested = new ListBuffer<>();
 839         listNested(csym, nested);
 840         Set<ClassSymbol> nestedUnique = new LinkedHashSet<>(nested);
 841         if (csym.owner.kind == PCK && !nestedUnique.isEmpty()) {
 842             int alenIdx = writeAttr(names.NestMembers);
 843             databuf.appendChar(nestedUnique.size());
 844             for (ClassSymbol s : nestedUnique) {
 845                 databuf.appendChar(poolWriter.putClass(s));
 846             }
 847             endAttr(alenIdx);
 848             return 1;
 849         }
 850         return 0;
 851     }
 852 
 853     /**


 864     }
 865 
 866     private void listNested(Symbol sym, ListBuffer<ClassSymbol> seen) {
 867         if (sym.kind != TYP) return;
 868         ClassSymbol csym = (ClassSymbol)sym;
 869         if (csym.owner.kind != PCK) {
 870             seen.add(csym);
 871         }
 872         if (csym.members() != null) {
 873             for (Symbol s : sym.members().getSymbols()) {
 874                 listNested(s, seen);
 875             }
 876         }
 877         if (csym.trans_local != null) {
 878             for (Symbol s : csym.trans_local) {
 879                 listNested(s, seen);
 880             }
 881         }
 882     }
 883 
















 884     /** Write "bootstrapMethods" attribute.
 885      */
 886     void writeBootstrapMethods() {
 887         int alenIdx = writeAttr(names.BootstrapMethods);
 888         databuf.appendChar(poolWriter.bootstrapMethods.size());
 889         for (BsmKey bsmKey : poolWriter.bootstrapMethods.keySet()) {
 890             //write BSM handle
 891             databuf.appendChar(poolWriter.putConstant(bsmKey.bsm));
 892             LoadableConstant[] uniqueArgs = bsmKey.staticArgs;
 893             //write static args length
 894             databuf.appendChar(uniqueArgs.length);
 895             //write static args array
 896             for (LoadableConstant arg : uniqueArgs) {
 897                 databuf.appendChar(poolWriter.putConstant(arg));
 898             }
 899         }
 900         endAttr(alenIdx);
 901     }
 902 
 903     /** Write field symbol, entering all references into constant pool.


 943             writeCode(m.code);
 944             m.code = null; // to conserve space
 945             endAttr(alenIdx);
 946             acount++;
 947         }
 948         List<Type> thrown = m.erasure(types).getThrownTypes();
 949         if (thrown.nonEmpty()) {
 950             int alenIdx = writeAttr(names.Exceptions);
 951             databuf.appendChar(thrown.length());
 952             for (List<Type> l = thrown; l.nonEmpty(); l = l.tail)
 953                 databuf.appendChar(poolWriter.putClass(l.head));
 954             endAttr(alenIdx);
 955             acount++;
 956         }
 957         if (m.defaultValue != null) {
 958             int alenIdx = writeAttr(names.AnnotationDefault);
 959             m.defaultValue.accept(awriter);
 960             endAttr(alenIdx);
 961             acount++;
 962         }
 963         if (options.isSet(PARAMETERS) && target.hasMethodParameters()) {
 964             if (!m.isLambdaMethod()) // Per JDK-8138729, do not emit parameters table for lambda bodies.
 965                 acount += writeMethodParametersAttr(m);
 966         }
 967         acount += writeMemberAttrs(m);
 968         if (!m.isLambdaMethod())
 969             acount += writeParameterAttrs(m);
 970         endAttrs(acountIdx, acount);
 971     }
 972 
 973     /** Write code attribute of method.
 974      */
 975     void writeCode(Code code) {
 976         databuf.appendChar(code.max_stack);
 977         databuf.appendChar(code.max_locals);
 978         databuf.appendInt(code.cp);
 979         databuf.appendBytes(code.code, 0, code.cp);
 980         databuf.appendChar(code.catchInfo.length());
 981         for (List<char[]> l = code.catchInfo.toList();
 982              l.nonEmpty();
 983              l = l.tail) {
 984             for (int i = 0; i < l.head.length; i++)
 985                 databuf.appendChar(l.head[i]);
 986         }
 987         int acountIdx = beginAttrs();
 988         int acount = 0;
 989 


1474         return outFile; // may be null if write failed
1475     }
1476 
1477     /** Write class `c' to outstream `out'.
1478      */
1479     public void writeClassFile(OutputStream out, ClassSymbol c)
1480         throws IOException, PoolOverflow, StringOverflow {
1481         Assert.check((c.flags() & COMPOUND) == 0);
1482         databuf.reset();
1483         poolbuf.reset();
1484 
1485         Type supertype = types.supertype(c.type);
1486         List<Type> interfaces = types.interfaces(c.type);
1487         List<Type> typarams = c.type.getTypeArguments();
1488 
1489         int flags;
1490         if (c.owner.kind == MDL) {
1491             flags = ACC_MODULE;
1492         } else {
1493             flags = adjustFlags(c.flags() & ~DEFAULT);






1494             if ((flags & PROTECTED) != 0) flags |= PUBLIC;
1495             flags = flags & ClassFlags & ~STRICTFP;
1496             if ((flags & INTERFACE) == 0) flags |= ACC_SUPER;
1497         }
1498 
1499         if (dumpClassModifiers) {
1500             PrintWriter pw = log.getWriter(Log.WriterKind.ERROR);
1501             pw.println();
1502             pw.println("CLASSFILE  " + c.getQualifiedName());
1503             pw.println("---" + flagNames(flags));
1504         }
1505         databuf.appendChar(flags);
1506 
1507         if (c.owner.kind == MDL) {
1508             PackageSymbol unnamed = ((ModuleSymbol) c.owner).unnamedPackage;
1509             databuf.appendChar(poolWriter.putClass(new ClassSymbol(0, names.module_info, unnamed)));
1510         } else {
1511             databuf.appendChar(poolWriter.putClass(c));
1512         }
1513         databuf.appendChar(supertype.hasTag(CLASS) ? poolWriter.putClass((ClassSymbol)supertype.tsym) : 0);


1583             acount += writeModuleAttribute(c);
1584             acount += writeFlagAttrs(c.owner.flags() & ~DEPRECATED);
1585         }
1586         acount += writeExtraClassAttributes(c);
1587 
1588         poolbuf.appendInt(JAVA_MAGIC);
1589         if (preview.isEnabled()) {
1590             poolbuf.appendChar(ClassFile.PREVIEW_MINOR_VERSION);
1591         } else {
1592             poolbuf.appendChar(target.minorVersion);
1593         }
1594         poolbuf.appendChar(target.majorVersion);
1595 
1596         if (c.owner.kind != MDL) {
1597             if (target.hasNestmateAccess()) {
1598                 acount += writeNestMembersIfNeeded(c);
1599                 acount += writeNestHostIfNeeded(c);
1600             }
1601         }
1602 








1603         if (!poolWriter.bootstrapMethods.isEmpty()) {
1604             writeBootstrapMethods();
1605             acount++;
1606         }
1607 
1608         if (!poolWriter.innerClasses.isEmpty()) {
1609             writeInnerClasses();
1610             acount++;
1611         }
1612 
1613         endAttrs(acountIdx, acount);
1614 
1615         out.write(poolbuf.elems, 0, poolbuf.length);
1616 
1617         poolWriter.writePool(out);
1618         poolWriter.reset(); // to save space
1619 
1620         out.write(databuf.elems, 0, databuf.length);
1621      }
1622 
1623     /**Allows subclasses to write additional class attributes
1624      *
1625      * @return the number of attributes written
1626      */
1627     protected int writeExtraClassAttributes(ClassSymbol c) {
1628         return 0;
1629     }
1630 
1631     int adjustFlags(final long flags) {
1632         int result = (int)flags;
1633 
1634         if ((flags & BRIDGE) != 0)
1635             result |= ACC_BRIDGE;
1636         if ((flags & VARARGS) != 0)
1637             result |= ACC_VARARGS;
1638         if ((flags & DEFAULT) != 0)
1639             result &= ~ABSTRACT;


1640         return result;
1641     }
1642 
1643     long getLastModified(FileObject filename) {
1644         long mod = 0;
1645         try {
1646             mod = filename.getLastModified();
1647         } catch (SecurityException e) {
1648             throw new AssertionError("CRT: couldn't get source file modification date: " + e.getMessage());
1649         }
1650         return mod;
1651     }
1652 }


 389                 databuf.appendChar(poolWriter.putName(s.name));
 390                 databuf.appendChar(flags);
 391             }
 392             // Now write the captured locals
 393             for (VarSymbol s : m.capturedLocals) {
 394                 final int flags =
 395                     ((int) s.flags() & (FINAL | SYNTHETIC | MANDATED)) |
 396                     ((int) m.flags() & SYNTHETIC);
 397                 databuf.appendChar(poolWriter.putName(s.name));
 398                 databuf.appendChar(flags);
 399             }
 400             endAttr(attrIndex);
 401             return 1;
 402         } else
 403             return 0;
 404     }
 405 
 406 
 407     private void writeParamAnnotations(List<VarSymbol> params,
 408                                        RetentionPolicy retention) {
 409         databuf.appendByte(params.length());
 410         for (VarSymbol s : params) {
 411             ListBuffer<Attribute.Compound> buf = new ListBuffer<>();
 412             for (Attribute.Compound a : s.getRawAttributes())
 413                 if (types.getRetention(a) == retention)
 414                     buf.append(a);
 415             databuf.appendChar(buf.length());
 416             for (Attribute.Compound a : buf)
 417                 writeCompoundAttribute(a);
 418         }
 419 
 420     }
 421 
 422     private void writeParamAnnotations(MethodSymbol m,
 423                                        RetentionPolicy retention) {
 424         databuf.appendByte(m.params.length());
 425         writeParamAnnotations(m.params, retention);
 426     }
 427 
 428     /** Write method parameter annotations;
 429      *  return number of attributes written.
 430      */
 431     int writeParameterAttrs(List<VarSymbol> vars) {
 432         boolean hasVisible = false;
 433         boolean hasInvisible = false;
 434         if (vars != null) {
 435             for (VarSymbol s : vars) {
 436                 for (Attribute.Compound a : s.getRawAttributes()) {
 437                     switch (types.getRetention(a)) {
 438                     case SOURCE: break;
 439                     case CLASS: hasInvisible = true; break;
 440                     case RUNTIME: hasVisible = true; break;
 441                     default: // /* fail soft */ throw new AssertionError(vis);
 442                     }
 443                 }
 444             }
 445         }
 446 
 447         int attrCount = 0;
 448         if (hasVisible) {
 449             int attrIndex = writeAttr(names.RuntimeVisibleParameterAnnotations);
 450             writeParamAnnotations(vars, RetentionPolicy.RUNTIME);
 451             endAttr(attrIndex);
 452             attrCount++;
 453         }
 454         if (hasInvisible) {
 455             int attrIndex = writeAttr(names.RuntimeInvisibleParameterAnnotations);
 456             writeParamAnnotations(vars, RetentionPolicy.CLASS);
 457             endAttr(attrIndex);
 458             attrCount++;
 459         }
 460         return attrCount;
 461     }
 462 
 463 /**********************************************************************
 464  * Writing Java-language annotations (aka metadata, attributes)
 465  **********************************************************************/
 466 
 467     /** Write Java-language annotations; return number of JVM
 468      *  attributes written (zero or one).
 469      */
 470     int writeJavaAnnotations(List<Attribute.Compound> attrs) {
 471         if (attrs.isEmpty()) return 0;
 472         ListBuffer<Attribute.Compound> visibles = new ListBuffer<>();
 473         ListBuffer<Attribute.Compound> invisibles = new ListBuffer<>();
 474         for (Attribute.Compound a : attrs) {
 475             switch (types.getRetention(a)) {
 476             case SOURCE: break;


 815         for (ClassSymbol inner : poolWriter.innerClasses) {
 816             inner.markAbstractIfNeeded(types);
 817             char flags = (char) adjustFlags(inner.flags_field);
 818             if ((flags & INTERFACE) != 0) flags |= ABSTRACT; // Interfaces are always ABSTRACT
 819             flags &= ~STRICTFP; //inner classes should not have the strictfp flag set.
 820             if (dumpInnerClassModifiers) {
 821                 PrintWriter pw = log.getWriter(Log.WriterKind.ERROR);
 822                 pw.println("INNERCLASS  " + inner.name);
 823                 pw.println("---" + flagNames(flags));
 824             }
 825             databuf.appendChar(poolWriter.putClass(inner));
 826             databuf.appendChar(
 827                 inner.owner.kind == TYP && !inner.name.isEmpty() ? poolWriter.putClass((ClassSymbol)inner.owner) : 0);
 828             databuf.appendChar(
 829                 !inner.name.isEmpty() ? poolWriter.putName(inner.name) : 0);
 830             databuf.appendChar(flags);
 831         }
 832         endAttr(alenIdx);
 833     }
 834 
 835     int writeRecordAttribute(ClassSymbol csym) {
 836         int alenIdx = writeAttr(names.Record);
 837         Scope s = csym.members();
 838         List<VarSymbol> vars = List.nil();
 839         int numParams = 0;
 840         for (Symbol sym : s.getSymbols(NON_RECURSIVE)) {
 841             if (sym.kind == VAR && sym.isRecord()) {
 842                 vars = vars.prepend((VarSymbol)sym);
 843                 numParams++;
 844             }
 845         }
 846         databuf.appendChar(numParams);
 847         for (VarSymbol v: vars) {
 848             databuf.appendChar(poolWriter.putMember(v.accessors.head.snd));
 849         }
 850         endAttr(alenIdx);
 851         return 1;
 852     }
 853 
 854     /**
 855      * Write NestMembers attribute (if needed)
 856      */
 857     int writeNestMembersIfNeeded(ClassSymbol csym) {
 858         ListBuffer<ClassSymbol> nested = new ListBuffer<>();
 859         listNested(csym, nested);
 860         Set<ClassSymbol> nestedUnique = new LinkedHashSet<>(nested);
 861         if (csym.owner.kind == PCK && !nestedUnique.isEmpty()) {
 862             int alenIdx = writeAttr(names.NestMembers);
 863             databuf.appendChar(nestedUnique.size());
 864             for (ClassSymbol s : nestedUnique) {
 865                 databuf.appendChar(poolWriter.putClass(s));
 866             }
 867             endAttr(alenIdx);
 868             return 1;
 869         }
 870         return 0;
 871     }
 872 
 873     /**


 884     }
 885 
 886     private void listNested(Symbol sym, ListBuffer<ClassSymbol> seen) {
 887         if (sym.kind != TYP) return;
 888         ClassSymbol csym = (ClassSymbol)sym;
 889         if (csym.owner.kind != PCK) {
 890             seen.add(csym);
 891         }
 892         if (csym.members() != null) {
 893             for (Symbol s : sym.members().getSymbols()) {
 894                 listNested(s, seen);
 895             }
 896         }
 897         if (csym.trans_local != null) {
 898             for (Symbol s : csym.trans_local) {
 899                 listNested(s, seen);
 900             }
 901         }
 902     }
 903 
 904     /** Write "PermittedSubtypes" attribute.
 905      */
 906     int writePermittedSubtypesIfNeeded(ClassSymbol csym) {
 907         ClassType ct = (ClassType)csym.type;
 908         if (ct.permitted.nonEmpty()) {
 909             int alenIdx = writeAttr(names.PermittedSubtypes);
 910             databuf.appendChar(ct.permitted.size());
 911             for (Type t : ct.permitted) {
 912                 databuf.appendChar(poolWriter.putClass((ClassSymbol)t.tsym));
 913             }
 914             endAttr(alenIdx);
 915             return 1;
 916         }
 917         return 0;
 918     }
 919 
 920     /** Write "bootstrapMethods" attribute.
 921      */
 922     void writeBootstrapMethods() {
 923         int alenIdx = writeAttr(names.BootstrapMethods);
 924         databuf.appendChar(poolWriter.bootstrapMethods.size());
 925         for (BsmKey bsmKey : poolWriter.bootstrapMethods.keySet()) {
 926             //write BSM handle
 927             databuf.appendChar(poolWriter.putConstant(bsmKey.bsm));
 928             LoadableConstant[] uniqueArgs = bsmKey.staticArgs;
 929             //write static args length
 930             databuf.appendChar(uniqueArgs.length);
 931             //write static args array
 932             for (LoadableConstant arg : uniqueArgs) {
 933                 databuf.appendChar(poolWriter.putConstant(arg));
 934             }
 935         }
 936         endAttr(alenIdx);
 937     }
 938 
 939     /** Write field symbol, entering all references into constant pool.


 979             writeCode(m.code);
 980             m.code = null; // to conserve space
 981             endAttr(alenIdx);
 982             acount++;
 983         }
 984         List<Type> thrown = m.erasure(types).getThrownTypes();
 985         if (thrown.nonEmpty()) {
 986             int alenIdx = writeAttr(names.Exceptions);
 987             databuf.appendChar(thrown.length());
 988             for (List<Type> l = thrown; l.nonEmpty(); l = l.tail)
 989                 databuf.appendChar(poolWriter.putClass(l.head));
 990             endAttr(alenIdx);
 991             acount++;
 992         }
 993         if (m.defaultValue != null) {
 994             int alenIdx = writeAttr(names.AnnotationDefault);
 995             m.defaultValue.accept(awriter);
 996             endAttr(alenIdx);
 997             acount++;
 998         }
 999         if (target.hasMethodParameters() && (options.isSet(PARAMETERS) || m.isConstructor() && m.isRecord())) {
1000             if (!m.isLambdaMethod()) // Per JDK-8138729, do not emit parameters table for lambda bodies.
1001                 acount += writeMethodParametersAttr(m);
1002         }
1003         acount += writeMemberAttrs(m);
1004         if (!m.isLambdaMethod())
1005             acount += writeParameterAttrs(m.params);
1006         endAttrs(acountIdx, acount);
1007     }
1008 
1009     /** Write code attribute of method.
1010      */
1011     void writeCode(Code code) {
1012         databuf.appendChar(code.max_stack);
1013         databuf.appendChar(code.max_locals);
1014         databuf.appendInt(code.cp);
1015         databuf.appendBytes(code.code, 0, code.cp);
1016         databuf.appendChar(code.catchInfo.length());
1017         for (List<char[]> l = code.catchInfo.toList();
1018              l.nonEmpty();
1019              l = l.tail) {
1020             for (int i = 0; i < l.head.length; i++)
1021                 databuf.appendChar(l.head[i]);
1022         }
1023         int acountIdx = beginAttrs();
1024         int acount = 0;
1025 


1510         return outFile; // may be null if write failed
1511     }
1512 
1513     /** Write class `c' to outstream `out'.
1514      */
1515     public void writeClassFile(OutputStream out, ClassSymbol c)
1516         throws IOException, PoolOverflow, StringOverflow {
1517         Assert.check((c.flags() & COMPOUND) == 0);
1518         databuf.reset();
1519         poolbuf.reset();
1520 
1521         Type supertype = types.supertype(c.type);
1522         List<Type> interfaces = types.interfaces(c.type);
1523         List<Type> typarams = c.type.getTypeArguments();
1524 
1525         int flags;
1526         if (c.owner.kind == MDL) {
1527             flags = ACC_MODULE;
1528         } else {
1529             flags = adjustFlags(c.flags() & ~DEFAULT);
1530             if (c.isSealed()) {
1531                 flags &= ~SEALED;
1532                 if (((ClassType)c.type).permitted.isEmpty()) {
1533                     flags |= FINAL;
1534                 }
1535             }
1536             if ((flags & PROTECTED) != 0) flags |= PUBLIC;
1537             flags = flags & ClassFlags & ~STRICTFP;
1538             if ((flags & INTERFACE) == 0) flags |= ACC_SUPER;
1539         }
1540 
1541         if (dumpClassModifiers) {
1542             PrintWriter pw = log.getWriter(Log.WriterKind.ERROR);
1543             pw.println();
1544             pw.println("CLASSFILE  " + c.getQualifiedName());
1545             pw.println("---" + flagNames(flags));
1546         }
1547         databuf.appendChar(flags);
1548 
1549         if (c.owner.kind == MDL) {
1550             PackageSymbol unnamed = ((ModuleSymbol) c.owner).unnamedPackage;
1551             databuf.appendChar(poolWriter.putClass(new ClassSymbol(0, names.module_info, unnamed)));
1552         } else {
1553             databuf.appendChar(poolWriter.putClass(c));
1554         }
1555         databuf.appendChar(supertype.hasTag(CLASS) ? poolWriter.putClass((ClassSymbol)supertype.tsym) : 0);


1625             acount += writeModuleAttribute(c);
1626             acount += writeFlagAttrs(c.owner.flags() & ~DEPRECATED);
1627         }
1628         acount += writeExtraClassAttributes(c);
1629 
1630         poolbuf.appendInt(JAVA_MAGIC);
1631         if (preview.isEnabled()) {
1632             poolbuf.appendChar(ClassFile.PREVIEW_MINOR_VERSION);
1633         } else {
1634             poolbuf.appendChar(target.minorVersion);
1635         }
1636         poolbuf.appendChar(target.majorVersion);
1637 
1638         if (c.owner.kind != MDL) {
1639             if (target.hasNestmateAccess()) {
1640                 acount += writeNestMembersIfNeeded(c);
1641                 acount += writeNestHostIfNeeded(c);
1642             }
1643         }
1644 
1645         if (c.isRecord()) {
1646             acount += writeRecordAttribute(c);
1647         }
1648 
1649         if (target.hasSealedTypes()) {
1650             acount += writePermittedSubtypesIfNeeded(c);
1651         }
1652 
1653         if (!poolWriter.bootstrapMethods.isEmpty()) {
1654             writeBootstrapMethods();
1655             acount++;
1656         }
1657 
1658         if (!poolWriter.innerClasses.isEmpty()) {
1659             writeInnerClasses();
1660             acount++;
1661         }
1662 
1663         endAttrs(acountIdx, acount);
1664 
1665         out.write(poolbuf.elems, 0, poolbuf.length);
1666 
1667         poolWriter.writePool(out);
1668         poolWriter.reset(); // to save space
1669 
1670         out.write(databuf.elems, 0, databuf.length);
1671      }
1672 
1673     /**Allows subclasses to write additional class attributes
1674      *
1675      * @return the number of attributes written
1676      */
1677     protected int writeExtraClassAttributes(ClassSymbol c) {
1678         return 0;
1679     }
1680 
1681     int adjustFlags(final long flags) {
1682         int result = (int)flags;
1683 
1684         if ((flags & BRIDGE) != 0)
1685             result |= ACC_BRIDGE;
1686         if ((flags & VARARGS) != 0)
1687             result |= ACC_VARARGS;
1688         if ((flags & DEFAULT) != 0)
1689             result &= ~ABSTRACT;
1690         if ((flags & SEALED) != 0)
1691             result |= FINAL;
1692         return result;
1693     }
1694 
1695     long getLastModified(FileObject filename) {
1696         long mod = 0;
1697         try {
1698             mod = filename.getLastModified();
1699         } catch (SecurityException e) {
1700             throw new AssertionError("CRT: couldn't get source file modification date: " + e.getMessage());
1701         }
1702         return mod;
1703     }
1704 }
< prev index next >