< prev index next >

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

Print this page

  23  * questions.
  24  */
  25 
  26 package com.sun.tools.javac.jvm;
  27 
  28 import java.io.*;
  29 import java.util.LinkedHashMap;
  30 import java.util.Map;
  31 import java.util.Set;
  32 import java.util.LinkedHashSet;
  33 import java.util.function.ToIntFunction;
  34 
  35 import javax.tools.JavaFileManager;
  36 import javax.tools.FileObject;
  37 import javax.tools.JavaFileManager.Location;
  38 import javax.tools.JavaFileObject;
  39 
  40 import com.sun.tools.javac.code.*;
  41 import com.sun.tools.javac.code.Attribute.RetentionPolicy;
  42 import com.sun.tools.javac.code.Directive.*;

  43 import com.sun.tools.javac.code.Source.Feature;
  44 import com.sun.tools.javac.code.Symbol.*;
  45 import com.sun.tools.javac.code.Type.*;
  46 import com.sun.tools.javac.code.Types.SignatureGenerator.InvalidSignatureException;
  47 import com.sun.tools.javac.comp.Check;
  48 import com.sun.tools.javac.file.PathFileObject;
  49 import com.sun.tools.javac.jvm.PoolConstant.LoadableConstant;
  50 import com.sun.tools.javac.jvm.PoolConstant.Dynamic.BsmKey;
  51 import com.sun.tools.javac.resources.CompilerProperties.Errors;
  52 import com.sun.tools.javac.resources.CompilerProperties.Fragments;
  53 import com.sun.tools.javac.util.*;
  54 import com.sun.tools.javac.util.List;
  55 
  56 import static com.sun.tools.javac.code.Flags.*;
  57 import static com.sun.tools.javac.code.Kinds.Kind.*;
  58 import static com.sun.tools.javac.code.Scope.LookupKind.NON_RECURSIVE;
  59 import static com.sun.tools.javac.code.TypeTag.*;
  60 import static com.sun.tools.javac.main.Option.*;
  61 
  62 import static javax.tools.StandardLocation.CLASS_OUTPUT;

 125 
 126     /** An output buffer for member info.
 127      */
 128     public ByteBuffer databuf = new ByteBuffer(DATA_BUF_SIZE);
 129 
 130     /** An output buffer for the constant pool.
 131      */
 132     ByteBuffer poolbuf = new ByteBuffer(CLASS_BUF_SIZE);
 133 
 134     /** The constant pool writer.
 135      */
 136     final PoolWriter poolWriter;
 137 
 138     /** The log to use for verbose output.
 139      */
 140     private final Log log;
 141 
 142     /** The name table. */
 143     private final Names names;
 144 


 145     /** Access to files. */
 146     private final JavaFileManager fileManager;
 147 
 148     /** The tags and constants used in compressed stackmap. */
 149     static final int SAME_FRAME_SIZE = 64;
 150     static final int SAME_LOCALS_1_STACK_ITEM_EXTENDED = 247;
 151     static final int SAME_FRAME_EXTENDED = 251;
 152     static final int FULL_FRAME = 255;
 153     static final int MAX_LOCAL_LENGTH_DIFF = 4;
 154 
 155     /** Get the ClassWriter instance for this context. */
 156     public static ClassWriter instance(Context context) {
 157         ClassWriter instance = context.get(classWriterKey);
 158         if (instance == null)
 159             instance = new ClassWriter(context);
 160         return instance;
 161     }
 162 
 163     /** Construct a class writer, given an options table.
 164      */
 165     protected ClassWriter(Context context) {
 166         context.put(classWriterKey, this);
 167 
 168         log = Log.instance(context);
 169         names = Names.instance(context);
 170         options = Options.instance(context);
 171         preview = Preview.instance(context);
 172         target = Target.instance(context);
 173         source = Source.instance(context);
 174         types = Types.instance(context);
 175         check = Check.instance(context);
 176         fileManager = context.get(JavaFileManager.class);
 177         poolWriter = Gen.instance(context).poolWriter;

 178 
 179         verbose        = options.isSet(VERBOSE);
 180         genCrt         = options.isSet(XJCOV);
 181         debugstackmap = options.isSet("debug.stackmap");
 182 
 183         emitSourceFile = options.isUnset(G_CUSTOM) ||
 184                             options.isSet(G_CUSTOM, "source");
 185 
 186         String modifierFlags = options.get("debug.dumpmodifiers");
 187         if (modifierFlags != null) {
 188             dumpClassModifiers = modifierFlags.indexOf('c') != -1;
 189             dumpFieldModifiers = modifierFlags.indexOf('f') != -1;
 190             dumpInnerClassModifiers = modifierFlags.indexOf('i') != -1;
 191             dumpMethodModifiers = modifierFlags.indexOf('m') != -1;
 192         }
 193     }
 194 
 195     public void addExtraAttributes(ToIntFunction<Symbol> addExtraAttributes) {
 196         extraAttributeHooks = extraAttributeHooks.prepend(addExtraAttributes);
 197     }

 331         MethodSymbol enclMethod =
 332             (c.owner.type == null // local to init block
 333              || c.owner.kind != MTH) // or member init
 334             ? null
 335             : ((MethodSymbol)c.owner).originalEnclosingMethod();
 336         databuf.appendChar(poolWriter.putClass(enclClass));
 337         databuf.appendChar(enclMethod == null ? 0 : poolWriter.putNameAndType(enclMethod));
 338         endAttr(alenIdx);
 339         return 1;
 340     }
 341 
 342     /** Write flag attributes; return number of attributes written.
 343      */
 344     int writeFlagAttrs(long flags) {
 345         int acount = 0;
 346         if ((flags & DEPRECATED) != 0) {
 347             int alenIdx = writeAttr(names.Deprecated);
 348             endAttr(alenIdx);
 349             acount++;
 350         }






 351         return acount;
 352     }
 353 
 354     /** Write member (field or method) attributes;
 355      *  return number of attributes written.
 356      */
 357     int writeMemberAttrs(Symbol sym, boolean isRecordComponent) {
 358         int acount = 0;
 359         if (!isRecordComponent) {
 360             acount = writeFlagAttrs(sym.flags());
 361         }
 362         long flags = sym.flags();
 363         if ((flags & (SYNTHETIC | BRIDGE)) != SYNTHETIC &&
 364             (flags & ANONCONSTR) == 0 &&
 365             (!types.isSameType(sym.type, sym.erasure(types)) ||
 366              poolWriter.signatureGen.hasTypeVar(sym.type.getThrownTypes()))) {
 367             // note that a local class with captured variables
 368             // will get a signature attribute
 369             int alenIdx = writeAttr(names.Signature);
 370             databuf.appendChar(poolWriter.putSignature(sym));

 988             writeCode(m.code);
 989             m.code = null; // to conserve space
 990             endAttr(alenIdx);
 991             acount++;
 992         }
 993         List<Type> thrown = m.erasure(types).getThrownTypes();
 994         if (thrown.nonEmpty()) {
 995             int alenIdx = writeAttr(names.Exceptions);
 996             databuf.appendChar(thrown.length());
 997             for (List<Type> l = thrown; l.nonEmpty(); l = l.tail)
 998                 databuf.appendChar(poolWriter.putClass(l.head));
 999             endAttr(alenIdx);
1000             acount++;
1001         }
1002         if (m.defaultValue != null) {
1003             int alenIdx = writeAttr(names.AnnotationDefault);
1004             m.defaultValue.accept(awriter);
1005             endAttr(alenIdx);
1006             acount++;
1007         }
1008         if (target.hasMethodParameters() && (options.isSet(PARAMETERS) || m.isConstructor() && (m.flags_field & RECORD) != 0)) {


1009             if (!m.isLambdaMethod()) // Per JDK-8138729, do not emit parameters table for lambda bodies.
1010                 acount += writeMethodParametersAttr(m);
1011         }
1012         acount += writeMemberAttrs(m, false);
1013         if (!m.isLambdaMethod())
1014             acount += writeParameterAttrs(m.params);
1015         acount += writeExtraAttributes(m);
1016         endAttrs(acountIdx, acount);
1017     }
1018 
1019     /** Write code attribute of method.
1020      */
1021     void writeCode(Code code) {
1022         databuf.appendChar(code.max_stack);
1023         databuf.appendChar(code.max_locals);
1024         databuf.appendInt(code.cp);
1025         databuf.appendBytes(code.code, 0, code.cp);
1026         databuf.appendChar(code.catchInfo.length());
1027         for (List<char[]> l = code.catchInfo.toList();
1028              l.nonEmpty();

1208                 databuf.appendByte(1);
1209                 break;
1210             case FLOAT:
1211                 if (debugstackmap) System.out.print("float");
1212                 databuf.appendByte(2);
1213                 break;
1214             case DOUBLE:
1215                 if (debugstackmap) System.out.print("double");
1216                 databuf.appendByte(3);
1217                 break;
1218             case LONG:
1219                 if (debugstackmap) System.out.print("long");
1220                 databuf.appendByte(4);
1221                 break;
1222             case BOT: // null
1223                 if (debugstackmap) System.out.print("null");
1224                 databuf.appendByte(5);
1225                 break;
1226             case CLASS:
1227             case ARRAY:




1228             case TYPEVAR:
1229                 if (debugstackmap) System.out.print("object(" + types.erasure(t).tsym + ")");
1230                 databuf.appendByte(7);
1231                 databuf.appendChar(poolWriter.putClass(types.erasure(t)));
1232                 break;
1233             case UNINITIALIZED_THIS:
1234                 if (debugstackmap) System.out.print("uninit_this");
1235                 databuf.appendByte(6);
1236                 break;
1237             case UNINITIALIZED_OBJECT:
1238                 { UninitializedType uninitType = (UninitializedType)t;
1239                 databuf.appendByte(8);
1240                 if (debugstackmap) System.out.print("uninit_object@" + uninitType.offset);
1241                 databuf.appendChar(uninitType.offset);
1242                 }
1243                 break;
1244             default:
1245                 throw new AssertionError();
1246             }
1247         }

1521     }
1522 
1523     /** Write class `c' to outstream `out'.
1524      */
1525     public void writeClassFile(OutputStream out, ClassSymbol c)
1526         throws IOException, PoolOverflow, StringOverflow {
1527         Assert.check((c.flags() & COMPOUND) == 0);
1528         databuf.reset();
1529         poolbuf.reset();
1530 
1531         Type supertype = types.supertype(c.type);
1532         List<Type> interfaces = types.interfaces(c.type);
1533         List<Type> typarams = c.type.getTypeArguments();
1534 
1535         int flags;
1536         if (c.owner.kind == MDL) {
1537             flags = ACC_MODULE;
1538         } else {
1539             flags = adjustFlags(c.flags() & ~DEFAULT);
1540             if ((flags & PROTECTED) != 0) flags |= PUBLIC;
1541             flags = flags & ClassFlags & ~STRICTFP;
1542             if ((flags & INTERFACE) == 0) flags |= ACC_SUPER;
1543         }
1544 
1545         if (dumpClassModifiers) {
1546             PrintWriter pw = log.getWriter(Log.WriterKind.ERROR);
1547             pw.println();
1548             pw.println("CLASSFILE  " + c.getQualifiedName());
1549             pw.println("---" + flagNames(flags));
1550         }
1551         databuf.appendChar(flags);
1552 
1553         if (c.owner.kind == MDL) {
1554             PackageSymbol unnamed = ((ModuleSymbol) c.owner).unnamedPackage;
1555             databuf.appendChar(poolWriter.putClass(new ClassSymbol(0, names.module_info, unnamed)));
1556         } else {
1557             databuf.appendChar(poolWriter.putClass(c));
1558         }
1559         databuf.appendChar(supertype.hasTag(CLASS) ? poolWriter.putClass((ClassSymbol)supertype.tsym) : 0);
1560         databuf.appendChar(interfaces.length());
1561         for (List<Type> l = interfaces; l.nonEmpty(); l = l.tail)

1691         int i = 0;
1692         for (ToIntFunction<Symbol> hook : extraAttributeHooks) {
1693             i += hook.applyAsInt(sym);
1694         }
1695         return i;
1696     }
1697 
1698     int adjustFlags(final long flags) {
1699         int result = (int)flags;
1700 
1701         // Elide strictfp bit in class files
1702         if (target.obsoleteAccStrict())
1703             result &= ~STRICTFP;
1704 
1705         if ((flags & BRIDGE) != 0)
1706             result |= ACC_BRIDGE;
1707         if ((flags & VARARGS) != 0)
1708             result |= ACC_VARARGS;
1709         if ((flags & DEFAULT) != 0)
1710             result &= ~ABSTRACT;


1711         return result;
1712     }
1713 
1714     long getLastModified(FileObject filename) {
1715         long mod = 0;
1716         try {
1717             mod = filename.getLastModified();
1718         } catch (SecurityException e) {
1719             throw new AssertionError("CRT: couldn't get source file modification date: " + e.getMessage());
1720         }
1721         return mod;
1722     }
1723 }

  23  * questions.
  24  */
  25 
  26 package com.sun.tools.javac.jvm;
  27 
  28 import java.io.*;
  29 import java.util.LinkedHashMap;
  30 import java.util.Map;
  31 import java.util.Set;
  32 import java.util.LinkedHashSet;
  33 import java.util.function.ToIntFunction;
  34 
  35 import javax.tools.JavaFileManager;
  36 import javax.tools.FileObject;
  37 import javax.tools.JavaFileManager.Location;
  38 import javax.tools.JavaFileObject;
  39 
  40 import com.sun.tools.javac.code.*;
  41 import com.sun.tools.javac.code.Attribute.RetentionPolicy;
  42 import com.sun.tools.javac.code.Directive.*;
  43 import com.sun.tools.javac.code.Scope.WriteableScope;
  44 import com.sun.tools.javac.code.Source.Feature;
  45 import com.sun.tools.javac.code.Symbol.*;
  46 import com.sun.tools.javac.code.Type.*;
  47 import com.sun.tools.javac.code.Types.SignatureGenerator.InvalidSignatureException;
  48 import com.sun.tools.javac.comp.Check;
  49 import com.sun.tools.javac.file.PathFileObject;
  50 import com.sun.tools.javac.jvm.PoolConstant.LoadableConstant;
  51 import com.sun.tools.javac.jvm.PoolConstant.Dynamic.BsmKey;
  52 import com.sun.tools.javac.resources.CompilerProperties.Errors;
  53 import com.sun.tools.javac.resources.CompilerProperties.Fragments;
  54 import com.sun.tools.javac.util.*;
  55 import com.sun.tools.javac.util.List;
  56 
  57 import static com.sun.tools.javac.code.Flags.*;
  58 import static com.sun.tools.javac.code.Kinds.Kind.*;
  59 import static com.sun.tools.javac.code.Scope.LookupKind.NON_RECURSIVE;
  60 import static com.sun.tools.javac.code.TypeTag.*;
  61 import static com.sun.tools.javac.main.Option.*;
  62 
  63 import static javax.tools.StandardLocation.CLASS_OUTPUT;

 126 
 127     /** An output buffer for member info.
 128      */
 129     public ByteBuffer databuf = new ByteBuffer(DATA_BUF_SIZE);
 130 
 131     /** An output buffer for the constant pool.
 132      */
 133     ByteBuffer poolbuf = new ByteBuffer(CLASS_BUF_SIZE);
 134 
 135     /** The constant pool writer.
 136      */
 137     final PoolWriter poolWriter;
 138 
 139     /** The log to use for verbose output.
 140      */
 141     private final Log log;
 142 
 143     /** The name table. */
 144     private final Names names;
 145 
 146     private final Symtab syms;
 147 
 148     /** Access to files. */
 149     private final JavaFileManager fileManager;
 150 
 151     /** The tags and constants used in compressed stackmap. */
 152     static final int SAME_FRAME_SIZE = 64;
 153     static final int SAME_LOCALS_1_STACK_ITEM_EXTENDED = 247;
 154     static final int SAME_FRAME_EXTENDED = 251;
 155     static final int FULL_FRAME = 255;
 156     static final int MAX_LOCAL_LENGTH_DIFF = 4;
 157 
 158     /** Get the ClassWriter instance for this context. */
 159     public static ClassWriter instance(Context context) {
 160         ClassWriter instance = context.get(classWriterKey);
 161         if (instance == null)
 162             instance = new ClassWriter(context);
 163         return instance;
 164     }
 165 
 166     /** Construct a class writer, given an options table.
 167      */
 168     protected ClassWriter(Context context) {
 169         context.put(classWriterKey, this);
 170 
 171         log = Log.instance(context);
 172         names = Names.instance(context);
 173         options = Options.instance(context);
 174         preview = Preview.instance(context);
 175         target = Target.instance(context);
 176         source = Source.instance(context);
 177         types = Types.instance(context);
 178         check = Check.instance(context);
 179         fileManager = context.get(JavaFileManager.class);
 180         poolWriter = Gen.instance(context).poolWriter;
 181         syms = Symtab.instance(context);
 182 
 183         verbose        = options.isSet(VERBOSE);
 184         genCrt         = options.isSet(XJCOV);
 185         debugstackmap = options.isSet("debug.stackmap");
 186 
 187         emitSourceFile = options.isUnset(G_CUSTOM) ||
 188                             options.isSet(G_CUSTOM, "source");
 189 
 190         String modifierFlags = options.get("debug.dumpmodifiers");
 191         if (modifierFlags != null) {
 192             dumpClassModifiers = modifierFlags.indexOf('c') != -1;
 193             dumpFieldModifiers = modifierFlags.indexOf('f') != -1;
 194             dumpInnerClassModifiers = modifierFlags.indexOf('i') != -1;
 195             dumpMethodModifiers = modifierFlags.indexOf('m') != -1;
 196         }
 197     }
 198 
 199     public void addExtraAttributes(ToIntFunction<Symbol> addExtraAttributes) {
 200         extraAttributeHooks = extraAttributeHooks.prepend(addExtraAttributes);
 201     }

 335         MethodSymbol enclMethod =
 336             (c.owner.type == null // local to init block
 337              || c.owner.kind != MTH) // or member init
 338             ? null
 339             : ((MethodSymbol)c.owner).originalEnclosingMethod();
 340         databuf.appendChar(poolWriter.putClass(enclClass));
 341         databuf.appendChar(enclMethod == null ? 0 : poolWriter.putNameAndType(enclMethod));
 342         endAttr(alenIdx);
 343         return 1;
 344     }
 345 
 346     /** Write flag attributes; return number of attributes written.
 347      */
 348     int writeFlagAttrs(long flags) {
 349         int acount = 0;
 350         if ((flags & DEPRECATED) != 0) {
 351             int alenIdx = writeAttr(names.Deprecated);
 352             endAttr(alenIdx);
 353             acount++;
 354         }
 355         if ((flags & REFERENCE_FAVORING) != 0) {
 356             int alenIdx = writeAttr(names.JavaFlags);
 357             databuf.appendChar(ACC_REF_DEFAULT);
 358             endAttr(alenIdx);
 359             acount++;
 360         }
 361         return acount;
 362     }
 363 
 364     /** Write member (field or method) attributes;
 365      *  return number of attributes written.
 366      */
 367     int writeMemberAttrs(Symbol sym, boolean isRecordComponent) {
 368         int acount = 0;
 369         if (!isRecordComponent) {
 370             acount = writeFlagAttrs(sym.flags());
 371         }
 372         long flags = sym.flags();
 373         if ((flags & (SYNTHETIC | BRIDGE)) != SYNTHETIC &&
 374             (flags & ANONCONSTR) == 0 &&
 375             (!types.isSameType(sym.type, sym.erasure(types)) ||
 376              poolWriter.signatureGen.hasTypeVar(sym.type.getThrownTypes()))) {
 377             // note that a local class with captured variables
 378             // will get a signature attribute
 379             int alenIdx = writeAttr(names.Signature);
 380             databuf.appendChar(poolWriter.putSignature(sym));

 998             writeCode(m.code);
 999             m.code = null; // to conserve space
1000             endAttr(alenIdx);
1001             acount++;
1002         }
1003         List<Type> thrown = m.erasure(types).getThrownTypes();
1004         if (thrown.nonEmpty()) {
1005             int alenIdx = writeAttr(names.Exceptions);
1006             databuf.appendChar(thrown.length());
1007             for (List<Type> l = thrown; l.nonEmpty(); l = l.tail)
1008                 databuf.appendChar(poolWriter.putClass(l.head));
1009             endAttr(alenIdx);
1010             acount++;
1011         }
1012         if (m.defaultValue != null) {
1013             int alenIdx = writeAttr(names.AnnotationDefault);
1014             m.defaultValue.accept(awriter);
1015             endAttr(alenIdx);
1016             acount++;
1017         }
1018         if (target.hasMethodParameters() && (
1019                 options.isSet(PARAMETERS)
1020                 || ((m.flags_field & RECORD) != 0 && (m.isConstructor() || m.isPrimitiveObjectFactory())))) {
1021             if (!m.isLambdaMethod()) // Per JDK-8138729, do not emit parameters table for lambda bodies.
1022                 acount += writeMethodParametersAttr(m);
1023         }
1024         acount += writeMemberAttrs(m, false);
1025         if (!m.isLambdaMethod())
1026             acount += writeParameterAttrs(m.params);
1027         acount += writeExtraAttributes(m);
1028         endAttrs(acountIdx, acount);
1029     }
1030 
1031     /** Write code attribute of method.
1032      */
1033     void writeCode(Code code) {
1034         databuf.appendChar(code.max_stack);
1035         databuf.appendChar(code.max_locals);
1036         databuf.appendInt(code.cp);
1037         databuf.appendBytes(code.code, 0, code.cp);
1038         databuf.appendChar(code.catchInfo.length());
1039         for (List<char[]> l = code.catchInfo.toList();
1040              l.nonEmpty();

1220                 databuf.appendByte(1);
1221                 break;
1222             case FLOAT:
1223                 if (debugstackmap) System.out.print("float");
1224                 databuf.appendByte(2);
1225                 break;
1226             case DOUBLE:
1227                 if (debugstackmap) System.out.print("double");
1228                 databuf.appendByte(3);
1229                 break;
1230             case LONG:
1231                 if (debugstackmap) System.out.print("long");
1232                 databuf.appendByte(4);
1233                 break;
1234             case BOT: // null
1235                 if (debugstackmap) System.out.print("null");
1236                 databuf.appendByte(5);
1237                 break;
1238             case CLASS:
1239             case ARRAY:
1240                 if (debugstackmap) System.out.print("object(" + types.erasure(t).tsym + ")");
1241                 databuf.appendByte(7);
1242                 databuf.appendChar(types.isPrimitiveClass(t) ? poolWriter.putClass(new ConstantPoolQType(types.erasure(t), types)) : poolWriter.putClass(types.erasure(t)));
1243                 break;
1244             case TYPEVAR:
1245                 if (debugstackmap) System.out.print("object(" + types.erasure(t).tsym + ")");
1246                 databuf.appendByte(7);
1247                 databuf.appendChar(poolWriter.putClass(types.erasure(t)));
1248                 break;
1249             case UNINITIALIZED_THIS:
1250                 if (debugstackmap) System.out.print("uninit_this");
1251                 databuf.appendByte(6);
1252                 break;
1253             case UNINITIALIZED_OBJECT:
1254                 { UninitializedType uninitType = (UninitializedType)t;
1255                 databuf.appendByte(8);
1256                 if (debugstackmap) System.out.print("uninit_object@" + uninitType.offset);
1257                 databuf.appendChar(uninitType.offset);
1258                 }
1259                 break;
1260             default:
1261                 throw new AssertionError();
1262             }
1263         }

1537     }
1538 
1539     /** Write class `c' to outstream `out'.
1540      */
1541     public void writeClassFile(OutputStream out, ClassSymbol c)
1542         throws IOException, PoolOverflow, StringOverflow {
1543         Assert.check((c.flags() & COMPOUND) == 0);
1544         databuf.reset();
1545         poolbuf.reset();
1546 
1547         Type supertype = types.supertype(c.type);
1548         List<Type> interfaces = types.interfaces(c.type);
1549         List<Type> typarams = c.type.getTypeArguments();
1550 
1551         int flags;
1552         if (c.owner.kind == MDL) {
1553             flags = ACC_MODULE;
1554         } else {
1555             flags = adjustFlags(c.flags() & ~DEFAULT);
1556             if ((flags & PROTECTED) != 0) flags |= PUBLIC;
1557             flags = flags & (ClassFlags | ACC_PRIMITIVE) & ~STRICTFP;
1558             if ((flags & INTERFACE) == 0) flags |= ACC_SUPER;
1559         }
1560 
1561         if (dumpClassModifiers) {
1562             PrintWriter pw = log.getWriter(Log.WriterKind.ERROR);
1563             pw.println();
1564             pw.println("CLASSFILE  " + c.getQualifiedName());
1565             pw.println("---" + flagNames(flags));
1566         }
1567         databuf.appendChar(flags);
1568 
1569         if (c.owner.kind == MDL) {
1570             PackageSymbol unnamed = ((ModuleSymbol) c.owner).unnamedPackage;
1571             databuf.appendChar(poolWriter.putClass(new ClassSymbol(0, names.module_info, unnamed)));
1572         } else {
1573             databuf.appendChar(poolWriter.putClass(c));
1574         }
1575         databuf.appendChar(supertype.hasTag(CLASS) ? poolWriter.putClass((ClassSymbol)supertype.tsym) : 0);
1576         databuf.appendChar(interfaces.length());
1577         for (List<Type> l = interfaces; l.nonEmpty(); l = l.tail)

1707         int i = 0;
1708         for (ToIntFunction<Symbol> hook : extraAttributeHooks) {
1709             i += hook.applyAsInt(sym);
1710         }
1711         return i;
1712     }
1713 
1714     int adjustFlags(final long flags) {
1715         int result = (int)flags;
1716 
1717         // Elide strictfp bit in class files
1718         if (target.obsoleteAccStrict())
1719             result &= ~STRICTFP;
1720 
1721         if ((flags & BRIDGE) != 0)
1722             result |= ACC_BRIDGE;
1723         if ((flags & VARARGS) != 0)
1724             result |= ACC_VARARGS;
1725         if ((flags & DEFAULT) != 0)
1726             result &= ~ABSTRACT;
1727         if ((flags & PRIMITIVE_CLASS) != 0)
1728             result |= ACC_PRIMITIVE;
1729         return result;
1730     }
1731 
1732     long getLastModified(FileObject filename) {
1733         long mod = 0;
1734         try {
1735             mod = filename.getLastModified();
1736         } catch (SecurityException e) {
1737             throw new AssertionError("CRT: couldn't get source file modification date: " + e.getMessage());
1738         }
1739         return mod;
1740     }
1741 }
< prev index next >