< prev index next >

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

Print this page

 205      *    'c' -- classes
 206      *    'f' -- fields
 207      *    'i' -- innerclass attributes
 208      *    'm' -- methods
 209      *  For example, to dump everything:
 210      *    javac -XDdumpmodifiers=cifm MyProg.java
 211      */
 212     private boolean dumpClassModifiers; // -XDdumpmodifiers=c
 213     private boolean dumpFieldModifiers; // -XDdumpmodifiers=f
 214     private boolean dumpInnerClassModifiers; // -XDdumpmodifiers=i
 215     private boolean dumpMethodModifiers; // -XDdumpmodifiers=m
 216 
 217 
 218     /** Return flags as a string, separated by " ".
 219      */
 220     public static String flagNames(long flags) {
 221         StringBuilder sbuf = new StringBuilder();
 222         int i = 0;
 223         long f = flags & StandardFlags;
 224         while (f != 0) {
 225             if ((f & 1) != 0) {
 226                 sbuf.append(" ");
 227                 sbuf.append(flagName[i]);
 228             }
 229             f = f >> 1;
 230             i++;
 231         }
 232         return sbuf.toString();
 233     }
 234     //where
 235         private static final String[] flagName = {
 236             "PUBLIC", "PRIVATE", "PROTECTED", "STATIC", "FINAL",
 237             "SUPER", "VOLATILE", "TRANSIENT", "NATIVE", "INTERFACE",

 238             "ABSTRACT", "STRICTFP"};
 239 
 240 /* ****************************************************************
 241  * Output routines
 242  ******************************************************************/
 243 
 244     /** Write a character into given byte buffer;
 245      *  byte buffer will not be grown.
 246      */
 247     void putChar(ByteBuffer buf, int op, int x) {
 248         buf.elems[op  ] = (byte)((x >>  8) & 0xFF);
 249         buf.elems[op+1] = (byte)((x      ) & 0xFF);
 250     }
 251 
 252     /** Write an integer into given byte buffer;
 253      *  byte buffer will not be grown.
 254      */
 255     void putInt(ByteBuffer buf, int adr, int x) {
 256         buf.elems[adr  ] = (byte)((x >> 24) & 0xFF);
 257         buf.elems[adr+1] = (byte)((x >> 16) & 0xFF);

 825             databuf.appendChar(poolWriter.putClass(srvc));
 826             databuf.appendChar(impls.size());
 827             impls.forEach(impl -> databuf.appendChar(poolWriter.putClass(impl)));
 828         });
 829 
 830         endAttr(alenIdx);
 831         return 1;
 832     }
 833 
 834 /* ********************************************************************
 835  * Writing Objects
 836  **********************************************************************/
 837 
 838     /** Write "inner classes" attribute.
 839      */
 840     void writeInnerClasses() {
 841         int alenIdx = writeAttr(names.InnerClasses);
 842         databuf.appendChar(poolWriter.innerClasses.size());
 843         for (ClassSymbol inner : poolWriter.innerClasses) {
 844             inner.markAbstractIfNeeded(types);
 845             int flags = adjustFlags(inner.flags_field);
 846             if ((flags & INTERFACE) != 0) flags |= ABSTRACT; // Interfaces are always ABSTRACT
 847             flags &= ~STRICTFP; //inner classes should not have the strictfp flag set.
 848             if (dumpInnerClassModifiers) {
 849                 PrintWriter pw = log.getWriter(Log.WriterKind.ERROR);
 850                 pw.println("INNERCLASS  " + inner.name);
 851                 pw.println("---" + flagNames(flags));
 852             }
 853             databuf.appendChar(poolWriter.putClass(inner));
 854             databuf.appendChar(
 855                 inner.owner.kind == TYP && !inner.name.isEmpty() ? poolWriter.putClass((ClassSymbol)inner.owner) : 0);
 856             databuf.appendChar(
 857                 !inner.name.isEmpty() ? poolWriter.putName(inner.name) : 0);
 858             databuf.appendChar(flags);
 859         }
 860         endAttr(alenIdx);
 861     }
 862 











 863     int writeRecordAttribute(ClassSymbol csym) {
 864         int alenIdx = writeAttr(names.Record);
 865         Scope s = csym.members();
 866         databuf.appendChar(csym.getRecordComponents().size());
 867         for (VarSymbol v: csym.getRecordComponents()) {
 868             //databuf.appendChar(poolWriter.putMember(v.accessor.head.snd));
 869             databuf.appendChar(poolWriter.putName(v.name));
 870             databuf.appendChar(poolWriter.putDescriptor(v));
 871             int acountIdx = beginAttrs();
 872             int acount = 0;
 873             acount += writeMemberAttrs(v, true);
 874             endAttrs(acountIdx, acount);
 875         }
 876         endAttr(alenIdx);
 877         return 1;
 878     }
 879 
 880     /**
 881      * Write NestMembers attribute (if needed)
 882      */

 956             }
 957         } while (lastBootstrapMethods < poolWriter.bootstrapMethods.size());
 958         databuf.appendChar(poolWriter.bootstrapMethods.size());
 959         for (BsmKey bsmKey : poolWriter.bootstrapMethods.keySet()) {
 960             //write BSM handle
 961             databuf.appendChar(poolWriter.putConstant(bsmKey.bsm));
 962             LoadableConstant[] uniqueArgs = bsmKey.staticArgs;
 963             //write static args length
 964             databuf.appendChar(uniqueArgs.length);
 965             //write static args array
 966             for (LoadableConstant arg : uniqueArgs) {
 967                 databuf.appendChar(poolWriter.putConstant(arg));
 968             }
 969         }
 970         endAttr(alenIdx);
 971     }
 972 
 973     /** Write field symbol, entering all references into constant pool.
 974      */
 975     void writeField(VarSymbol v) {
 976         int flags = adjustFlags(v.flags());
 977         databuf.appendChar(flags);
 978         if (dumpFieldModifiers) {
 979             PrintWriter pw = log.getWriter(Log.WriterKind.ERROR);
 980             pw.println("FIELD  " + v.name);
 981             pw.println("---" + flagNames(v.flags()));
 982         }
 983         databuf.appendChar(poolWriter.putName(v.name));
 984         databuf.appendChar(poolWriter.putDescriptor(v));







 985         int acountIdx = beginAttrs();
 986         int acount = 0;
 987         if (v.getConstValue() != null) {
 988             int alenIdx = writeAttr(names.ConstantValue);
 989             databuf.appendChar(poolWriter.putConstant(v.getConstValue()));
 990             endAttr(alenIdx);
 991             acount++;
 992         }
 993         acount += writeMemberAttrs(v, false);
 994         acount += writeExtraAttributes(v);
 995         endAttrs(acountIdx, acount);
 996     }
 997 
 998     /** Write method symbol, entering all references into constant pool.
 999      */
1000     void writeMethod(MethodSymbol m) {
1001         int flags = adjustFlags(m.flags());
1002         databuf.appendChar(flags);
1003         if (dumpMethodModifiers) {
1004             PrintWriter pw = log.getWriter(Log.WriterKind.ERROR);
1005             pw.println("METHOD  " + m.name);
1006             pw.println("---" + flagNames(m.flags()));
1007         }
1008         databuf.appendChar(poolWriter.putName(m.name));
1009         databuf.appendChar(poolWriter.putDescriptor(m));
















1010         int acountIdx = beginAttrs();
1011         int acount = 0;
1012         if (m.code != null) {
1013             int alenIdx = writeAttr(names.Code);
1014             writeCode(m.code);
1015             m.code = null; // to conserve space
1016             endAttr(alenIdx);
1017             acount++;
1018         }
1019         List<Type> thrown = m.erasure(types).getThrownTypes();
1020         if (thrown.nonEmpty()) {
1021             int alenIdx = writeAttr(names.Exceptions);
1022             databuf.appendChar(thrown.length());
1023             for (List<Type> l = thrown; l.nonEmpty(); l = l.tail)
1024                 databuf.appendChar(poolWriter.putClass(l.head));
1025             endAttr(alenIdx);
1026             acount++;
1027         }
1028         if (m.defaultValue != null) {
1029             int alenIdx = writeAttr(names.AnnotationDefault);

1567         }
1568         return outFile; // may be null if write failed
1569     }
1570 
1571     /** Write class `c' to outstream `out'.
1572      */
1573     public void writeClassFile(OutputStream out, ClassSymbol c)
1574         throws IOException, PoolOverflow, StringOverflow {
1575         Assert.check((c.flags() & COMPOUND) == 0);
1576         databuf.reset();
1577         poolbuf.reset();
1578 
1579         Type supertype = types.supertype(c.type);
1580         List<Type> interfaces = types.interfaces(c.type);
1581         List<Type> typarams = c.type.getTypeArguments();
1582 
1583         int flags;
1584         if (c.owner.kind == MDL) {
1585             flags = ACC_MODULE;
1586         } else {
1587             flags = adjustFlags(c.flags() & ~DEFAULT);

1588             if ((flags & PROTECTED) != 0) flags |= PUBLIC;
1589             flags = flags & ClassFlags & ~STRICTFP;
1590             if ((flags & INTERFACE) == 0) flags |= ACC_SUPER;
1591         }
1592 
1593         if (dumpClassModifiers) {
1594             PrintWriter pw = log.getWriter(Log.WriterKind.ERROR);
1595             pw.println();
1596             pw.println("CLASSFILE  " + c.getQualifiedName());
1597             pw.println("---" + flagNames(flags));
1598         }
1599         databuf.appendChar(flags);
1600 
1601         if (c.owner.kind == MDL) {
1602             PackageSymbol unnamed = ((ModuleSymbol) c.owner).unnamedPackage;
1603             databuf.appendChar(poolWriter.putClass(new ClassSymbol(0, names.module_info, unnamed)));
1604         } else {
1605             databuf.appendChar(poolWriter.putClass(c));
1606         }
1607         databuf.appendChar(supertype.hasTag(CLASS) ? poolWriter.putClass((ClassSymbol)supertype.tsym) : 0);
1608         databuf.appendChar(interfaces.length());
1609         for (List<Type> l = interfaces; l.nonEmpty(); l = l.tail)
1610             databuf.appendChar(poolWriter.putClass((ClassSymbol)l.head.tsym));

1696         }
1697 
1698         if (c.isRecord()) {
1699             acount += writeRecordAttribute(c);
1700         }
1701 
1702         if (target.hasSealedClasses()) {
1703             acount += writePermittedSubclassesIfNeeded(c);
1704         }
1705 
1706         if (!poolWriter.bootstrapMethods.isEmpty()) {
1707             writeBootstrapMethods();
1708             acount++;
1709         }
1710 
1711         if (!poolWriter.innerClasses.isEmpty()) {
1712             writeInnerClasses();
1713             acount++;
1714         }
1715 





1716         endAttrs(acountIdx, acount);
1717 
1718         out.write(poolbuf.elems, 0, poolbuf.length);
1719 
1720         poolWriter.writePool(out);
1721         poolWriter.reset(); // to save space
1722 
1723         out.write(databuf.elems, 0, databuf.length);
1724     }
1725 
1726      /**Allows subclasses to write additional class attributes
1727       *
1728       * @return the number of attributes written
1729       */
1730     protected int writeExtraClassAttributes(ClassSymbol c) {
1731         return 0;
1732     }
1733 
1734     /**Allows friends to write additional attributes
1735      *
1736      * @return the number of attributes written
1737      */
1738     protected int writeExtraAttributes(Symbol sym) {
1739         int i = 0;
1740         for (ToIntFunction<Symbol> hook : extraAttributeHooks) {
1741             i += hook.applyAsInt(sym);
1742         }
1743         return i;
1744     }
1745 
1746     int adjustFlags(final long flags) {
1747         int result = (int)flags;
1748 
1749         // Elide strictfp bit in class files
1750         if (target.obsoleteAccStrict())
1751             result &= ~STRICTFP;
1752 
1753         if ((flags & BRIDGE) != 0)
1754             result |= ACC_BRIDGE;
1755         if ((flags & VARARGS) != 0)
1756             result |= ACC_VARARGS;
1757         if ((flags & DEFAULT) != 0)
1758             result &= ~ABSTRACT;








1759         return result;
1760     }
1761 
1762     long getLastModified(FileObject filename) {
1763         long mod = 0;
1764         try {
1765             mod = filename.getLastModified();
1766         } catch (SecurityException e) {
1767             throw new AssertionError("CRT: couldn't get source file modification date: " + e.getMessage());
1768         }
1769         return mod;
1770     }
1771 }

 205      *    'c' -- classes
 206      *    'f' -- fields
 207      *    'i' -- innerclass attributes
 208      *    'm' -- methods
 209      *  For example, to dump everything:
 210      *    javac -XDdumpmodifiers=cifm MyProg.java
 211      */
 212     private boolean dumpClassModifiers; // -XDdumpmodifiers=c
 213     private boolean dumpFieldModifiers; // -XDdumpmodifiers=f
 214     private boolean dumpInnerClassModifiers; // -XDdumpmodifiers=i
 215     private boolean dumpMethodModifiers; // -XDdumpmodifiers=m
 216 
 217 
 218     /** Return flags as a string, separated by " ".
 219      */
 220     public static String flagNames(long flags) {
 221         StringBuilder sbuf = new StringBuilder();
 222         int i = 0;
 223         long f = flags & StandardFlags;
 224         while (f != 0) {
 225             if ((f & 1) != 0 && flagName[i] != "") {
 226                 sbuf.append(" ");
 227                 sbuf.append(flagName[i]);
 228             }
 229             f = f >> 1;
 230             i++;
 231         }
 232         return sbuf.toString();
 233     }
 234     //where
 235         private static final String[] flagName = {
 236             "PUBLIC", "PRIVATE", "PROTECTED", "STATIC", "FINAL",
 237             // the empty position should be for synchronized but right now we don't have any test checking it
 238             "", "VOLATILE", "TRANSIENT", "NATIVE", "INTERFACE",
 239             "ABSTRACT", "STRICTFP"};
 240 
 241 /* ****************************************************************
 242  * Output routines
 243  ******************************************************************/
 244 
 245     /** Write a character into given byte buffer;
 246      *  byte buffer will not be grown.
 247      */
 248     void putChar(ByteBuffer buf, int op, int x) {
 249         buf.elems[op  ] = (byte)((x >>  8) & 0xFF);
 250         buf.elems[op+1] = (byte)((x      ) & 0xFF);
 251     }
 252 
 253     /** Write an integer into given byte buffer;
 254      *  byte buffer will not be grown.
 255      */
 256     void putInt(ByteBuffer buf, int adr, int x) {
 257         buf.elems[adr  ] = (byte)((x >> 24) & 0xFF);
 258         buf.elems[adr+1] = (byte)((x >> 16) & 0xFF);

 826             databuf.appendChar(poolWriter.putClass(srvc));
 827             databuf.appendChar(impls.size());
 828             impls.forEach(impl -> databuf.appendChar(poolWriter.putClass(impl)));
 829         });
 830 
 831         endAttr(alenIdx);
 832         return 1;
 833     }
 834 
 835 /* ********************************************************************
 836  * Writing Objects
 837  **********************************************************************/
 838 
 839     /** Write "inner classes" attribute.
 840      */
 841     void writeInnerClasses() {
 842         int alenIdx = writeAttr(names.InnerClasses);
 843         databuf.appendChar(poolWriter.innerClasses.size());
 844         for (ClassSymbol inner : poolWriter.innerClasses) {
 845             inner.markAbstractIfNeeded(types);
 846             int flags = adjustFlags(inner, inner.flags_field);
 847             if ((flags & INTERFACE) != 0) flags |= ABSTRACT; // Interfaces are always ABSTRACT

 848             if (dumpInnerClassModifiers) {
 849                 PrintWriter pw = log.getWriter(Log.WriterKind.ERROR);
 850                 pw.println("INNERCLASS  " + inner.name);
 851                 pw.println("---" + flagNames(flags));
 852             }
 853             databuf.appendChar(poolWriter.putClass(inner));
 854             databuf.appendChar(
 855                 inner.owner.kind == TYP && !inner.name.isEmpty() ? poolWriter.putClass((ClassSymbol)inner.owner) : 0);
 856             databuf.appendChar(
 857                 !inner.name.isEmpty() ? poolWriter.putName(inner.name) : 0);
 858             databuf.appendChar(flags);
 859         }
 860         endAttr(alenIdx);
 861     }
 862 
 863      /** Write out "LoadableDescriptors" attribute by enumerating the value classes encountered in field/method descriptors during this compilation.
 864       */
 865      void writeLoadableDescriptorsAttribute() {
 866         int alenIdx = writeAttr(names.LoadableDescriptors);
 867         databuf.appendChar(poolWriter.loadableDescriptors.size());
 868         for (Symbol c : poolWriter.loadableDescriptors) {
 869             databuf.appendChar(poolWriter.putDescriptor(c));
 870         }
 871         endAttr(alenIdx);
 872      }
 873 
 874     int writeRecordAttribute(ClassSymbol csym) {
 875         int alenIdx = writeAttr(names.Record);
 876         Scope s = csym.members();
 877         databuf.appendChar(csym.getRecordComponents().size());
 878         for (VarSymbol v: csym.getRecordComponents()) {
 879             //databuf.appendChar(poolWriter.putMember(v.accessor.head.snd));
 880             databuf.appendChar(poolWriter.putName(v.name));
 881             databuf.appendChar(poolWriter.putDescriptor(v));
 882             int acountIdx = beginAttrs();
 883             int acount = 0;
 884             acount += writeMemberAttrs(v, true);
 885             endAttrs(acountIdx, acount);
 886         }
 887         endAttr(alenIdx);
 888         return 1;
 889     }
 890 
 891     /**
 892      * Write NestMembers attribute (if needed)
 893      */

 967             }
 968         } while (lastBootstrapMethods < poolWriter.bootstrapMethods.size());
 969         databuf.appendChar(poolWriter.bootstrapMethods.size());
 970         for (BsmKey bsmKey : poolWriter.bootstrapMethods.keySet()) {
 971             //write BSM handle
 972             databuf.appendChar(poolWriter.putConstant(bsmKey.bsm));
 973             LoadableConstant[] uniqueArgs = bsmKey.staticArgs;
 974             //write static args length
 975             databuf.appendChar(uniqueArgs.length);
 976             //write static args array
 977             for (LoadableConstant arg : uniqueArgs) {
 978                 databuf.appendChar(poolWriter.putConstant(arg));
 979             }
 980         }
 981         endAttr(alenIdx);
 982     }
 983 
 984     /** Write field symbol, entering all references into constant pool.
 985      */
 986     void writeField(VarSymbol v) {
 987         int flags = adjustFlags(v, v.flags());
 988         databuf.appendChar(flags);
 989         if (dumpFieldModifiers) {
 990             PrintWriter pw = log.getWriter(Log.WriterKind.ERROR);
 991             pw.println("FIELD  " + v.name);
 992             pw.println("---" + flagNames(v.flags()));
 993         }
 994         databuf.appendChar(poolWriter.putName(v.name));
 995         databuf.appendChar(poolWriter.putDescriptor(v));
 996         Type fldType = v.erasure(types);
 997         if (fldType.requiresLoadableDescriptors(v.owner)) {
 998             poolWriter.enterLoadableDescriptorsClass(fldType.tsym);
 999             if (preview.isPreview(Source.Feature.VALUE_CLASSES)) {
1000                 preview.markUsesPreview(null);
1001             }
1002         }
1003         int acountIdx = beginAttrs();
1004         int acount = 0;
1005         if (v.getConstValue() != null) {
1006             int alenIdx = writeAttr(names.ConstantValue);
1007             databuf.appendChar(poolWriter.putConstant(v.getConstValue()));
1008             endAttr(alenIdx);
1009             acount++;
1010         }
1011         acount += writeMemberAttrs(v, false);
1012         acount += writeExtraAttributes(v);
1013         endAttrs(acountIdx, acount);
1014     }
1015 
1016     /** Write method symbol, entering all references into constant pool.
1017      */
1018     void writeMethod(MethodSymbol m) {
1019         int flags = adjustFlags(m, m.flags());
1020         databuf.appendChar(flags);
1021         if (dumpMethodModifiers) {
1022             PrintWriter pw = log.getWriter(Log.WriterKind.ERROR);
1023             pw.println("METHOD  " + m.name);
1024             pw.println("---" + flagNames(m.flags()));
1025         }
1026         databuf.appendChar(poolWriter.putName(m.name));
1027         databuf.appendChar(poolWriter.putDescriptor(m));
1028         MethodType mtype = (MethodType) m.externalType(types);
1029         for (Type t : mtype.getParameterTypes()) {
1030             if (t.requiresLoadableDescriptors(m.owner)) {
1031                 poolWriter.enterLoadableDescriptorsClass(t.tsym);
1032                 if (preview.isPreview(Source.Feature.VALUE_CLASSES)) {
1033                     preview.markUsesPreview(null);
1034                 }
1035             }
1036         }
1037         Type returnType = mtype.getReturnType();
1038         if (returnType.requiresLoadableDescriptors(m.owner)) {
1039             poolWriter.enterLoadableDescriptorsClass(returnType.tsym);
1040             if (preview.isPreview(Source.Feature.VALUE_CLASSES)) {
1041                 preview.markUsesPreview(null);
1042             }
1043         }
1044         int acountIdx = beginAttrs();
1045         int acount = 0;
1046         if (m.code != null) {
1047             int alenIdx = writeAttr(names.Code);
1048             writeCode(m.code);
1049             m.code = null; // to conserve space
1050             endAttr(alenIdx);
1051             acount++;
1052         }
1053         List<Type> thrown = m.erasure(types).getThrownTypes();
1054         if (thrown.nonEmpty()) {
1055             int alenIdx = writeAttr(names.Exceptions);
1056             databuf.appendChar(thrown.length());
1057             for (List<Type> l = thrown; l.nonEmpty(); l = l.tail)
1058                 databuf.appendChar(poolWriter.putClass(l.head));
1059             endAttr(alenIdx);
1060             acount++;
1061         }
1062         if (m.defaultValue != null) {
1063             int alenIdx = writeAttr(names.AnnotationDefault);

1601         }
1602         return outFile; // may be null if write failed
1603     }
1604 
1605     /** Write class `c' to outstream `out'.
1606      */
1607     public void writeClassFile(OutputStream out, ClassSymbol c)
1608         throws IOException, PoolOverflow, StringOverflow {
1609         Assert.check((c.flags() & COMPOUND) == 0);
1610         databuf.reset();
1611         poolbuf.reset();
1612 
1613         Type supertype = types.supertype(c.type);
1614         List<Type> interfaces = types.interfaces(c.type);
1615         List<Type> typarams = c.type.getTypeArguments();
1616 
1617         int flags;
1618         if (c.owner.kind == MDL) {
1619             flags = ACC_MODULE;
1620         } else {
1621             long originalFlags = c.flags();
1622             flags = adjustFlags(c, c.flags() & ~(DEFAULT | STRICTFP));
1623             if ((flags & PROTECTED) != 0) flags |= PUBLIC;
1624             flags = flags & ClassFlags;
1625             flags |= (originalFlags & IDENTITY_TYPE) != 0 ? ACC_IDENTITY : flags;
1626         }
1627 
1628         if (dumpClassModifiers) {
1629             PrintWriter pw = log.getWriter(Log.WriterKind.ERROR);
1630             pw.println();
1631             pw.println("CLASSFILE  " + c.getQualifiedName());
1632             pw.println("---" + flagNames(flags));
1633         }
1634         databuf.appendChar(flags);
1635 
1636         if (c.owner.kind == MDL) {
1637             PackageSymbol unnamed = ((ModuleSymbol) c.owner).unnamedPackage;
1638             databuf.appendChar(poolWriter.putClass(new ClassSymbol(0, names.module_info, unnamed)));
1639         } else {
1640             databuf.appendChar(poolWriter.putClass(c));
1641         }
1642         databuf.appendChar(supertype.hasTag(CLASS) ? poolWriter.putClass((ClassSymbol)supertype.tsym) : 0);
1643         databuf.appendChar(interfaces.length());
1644         for (List<Type> l = interfaces; l.nonEmpty(); l = l.tail)
1645             databuf.appendChar(poolWriter.putClass((ClassSymbol)l.head.tsym));

1731         }
1732 
1733         if (c.isRecord()) {
1734             acount += writeRecordAttribute(c);
1735         }
1736 
1737         if (target.hasSealedClasses()) {
1738             acount += writePermittedSubclassesIfNeeded(c);
1739         }
1740 
1741         if (!poolWriter.bootstrapMethods.isEmpty()) {
1742             writeBootstrapMethods();
1743             acount++;
1744         }
1745 
1746         if (!poolWriter.innerClasses.isEmpty()) {
1747             writeInnerClasses();
1748             acount++;
1749         }
1750 
1751         if (!poolWriter.loadableDescriptors.isEmpty()) {
1752             writeLoadableDescriptorsAttribute();
1753             acount++;
1754         }
1755 
1756         endAttrs(acountIdx, acount);
1757 
1758         out.write(poolbuf.elems, 0, poolbuf.length);
1759 
1760         poolWriter.writePool(out);
1761         poolWriter.reset(); // to save space
1762 
1763         out.write(databuf.elems, 0, databuf.length);
1764     }
1765 
1766      /**Allows subclasses to write additional class attributes
1767       *
1768       * @return the number of attributes written
1769       */
1770     protected int writeExtraClassAttributes(ClassSymbol c) {
1771         return 0;
1772     }
1773 
1774     /**Allows friends to write additional attributes
1775      *
1776      * @return the number of attributes written
1777      */
1778     protected int writeExtraAttributes(Symbol sym) {
1779         int i = 0;
1780         for (ToIntFunction<Symbol> hook : extraAttributeHooks) {
1781             i += hook.applyAsInt(sym);
1782         }
1783         return i;
1784     }
1785 
1786     int adjustFlags(Symbol sym, final long flags) {
1787         int result = (int)flags;
1788 
1789         // Elide strictfp bit in class files
1790         if (target.obsoleteAccStrict())
1791             result &= ~STRICTFP;
1792 
1793         if ((flags & BRIDGE) != 0)
1794             result |= ACC_BRIDGE;
1795         if ((flags & VARARGS) != 0)
1796             result |= ACC_VARARGS;
1797         if ((flags & DEFAULT) != 0)
1798             result &= ~ABSTRACT;
1799         if ((flags & IDENTITY_TYPE) != 0) {
1800             result |= ACC_IDENTITY;
1801         }
1802         if (sym.kind == VAR) {
1803             if ((flags & STRICT) != 0) {
1804                 result |= ACC_STRICT;
1805             }
1806         }
1807         return result;
1808     }
1809 
1810     long getLastModified(FileObject filename) {
1811         long mod = 0;
1812         try {
1813             mod = filename.getLastModified();
1814         } catch (SecurityException e) {
1815             throw new AssertionError("CRT: couldn't get source file modification date: " + e.getMessage());
1816         }
1817         return mod;
1818     }
1819 }
< prev index next >