public void writeClassFile(OutputStream out, ClassSymbol c)
        throws IOException, PoolOverflow, StringOverflow {
        Assert.check((c.flags() & COMPOUND) == 0);
        databuf.reset();
        poolbuf.reset();
        signatureGen.reset();
        pool = c.pool;
        innerClasses = null;
        innerClassesQueue = null;
        bootstrapMethods = new LinkedHashMap<>();

        Type supertype = types.supertype(c.type);
        List<Type> interfaces = types.interfaces(c.type);
        List<Type> typarams = c.type.getTypeArguments();

        int flags;
        if (c.owner.kind == MDL) {
            flags = ACC_MODULE;
        } else {
            flags = adjustFlags(c.flags() & ~DEFAULT);
            if ((flags & PROTECTED) != 0) flags |= PUBLIC;
            flags = flags & ClassFlags & ~STRICTFP;
            if ((flags & INTERFACE) == 0) flags |= ACC_SUPER;
        }

        if (dumpClassModifiers) {
            PrintWriter pw = log.getWriter(Log.WriterKind.ERROR);
            pw.println();
            pw.println("CLASSFILE  " + c.getQualifiedName());
            pw.println("---" + flagNames(flags));
        }
        databuf.appendChar(flags);

        if (c.owner.kind == MDL) {
            PackageSymbol unnamed = ((ModuleSymbol) c.owner).unnamedPackage;
            databuf.appendChar(pool.put(new ClassSymbol(0, names.module_info, unnamed)));
        } else {
            databuf.appendChar(pool.put(c));
        }
        databuf.appendChar(supertype.hasTag(CLASS) ? pool.put(supertype.tsym) : 0);
        databuf.appendChar(interfaces.length());
        for (List<Type> l = interfaces; l.nonEmpty(); l = l.tail)
            databuf.appendChar(pool.put(l.head.tsym));
        int fieldsCount = 0;
        int methodsCount = 0;
        for (Symbol sym : c.members().getSymbols(NON_RECURSIVE)) {
            switch (sym.kind) {
            case VAR: fieldsCount++; break;
            case MTH: if ((sym.flags() & HYPOTHETICAL) == 0) methodsCount++;
                      break;
            case TYP: enterInner((ClassSymbol)sym); break;
            default : Assert.error();
            }
        }

        if (c.trans_local != null) {
            for (ClassSymbol local : c.trans_local) {
                enterInner(local);
            }
        }

        databuf.appendChar(fieldsCount);
        writeFields(c.members());
        databuf.appendChar(methodsCount);
        writeMethods(c.members());

        int acountIdx = beginAttrs();
        int acount = 0;

        boolean sigReq =
            typarams.length() != 0 || supertype.allparams().length() != 0;
        for (List<Type> l = interfaces; !sigReq && l.nonEmpty(); l = l.tail)
            sigReq = l.head.allparams().length() != 0;
        if (sigReq) {
            int alenIdx = writeAttr(names.Signature);
            if (typarams.length() != 0) signatureGen.assembleParamsSig(typarams);
            signatureGen.assembleSig(supertype);
            for (List<Type> l = interfaces; l.nonEmpty(); l = l.tail)
                signatureGen.assembleSig(l.head);
            databuf.appendChar(pool.put(signatureGen.toName()));
            signatureGen.reset();
            endAttr(alenIdx);
            acount++;
        }

        if (c.sourcefile != null && emitSourceFile) {
            int alenIdx = writeAttr(names.SourceFile);
            // WHM 6/29/1999: Strip file path prefix.  We do it here at
            // the last possible moment because the sourcefile may be used
            // elsewhere in error diagnostics. Fixes 4241573.
            //databuf.appendChar(c.pool.put(c.sourcefile));
            String simpleName = PathFileObject.getSimpleName(c.sourcefile);
            databuf.appendChar(c.pool.put(names.fromString(simpleName)));
            endAttr(alenIdx);
            acount++;
        }

        if (genCrt) {
            // Append SourceID attribute
            int alenIdx = writeAttr(names.SourceID);
            databuf.appendChar(c.pool.put(names.fromString(Long.toString(getLastModified(c.sourcefile)))));
            endAttr(alenIdx);
            acount++;
            // Append CompilationID attribute
            alenIdx = writeAttr(names.CompilationID);
            databuf.appendChar(c.pool.put(names.fromString(Long.toString(System.currentTimeMillis()))));
            endAttr(alenIdx);
            acount++;
        }

        acount += writeFlagAttrs(c.flags());
        acount += writeJavaAnnotations(c.getRawAttributes());
        acount += writeTypeAnnotations(c.getRawTypeAttributes(), false);
        acount += writeEnclosingMethodAttribute(c);
        if (c.owner.kind == MDL) {
            acount += writeModuleAttribute(c);
            acount += writeFlagAttrs(c.owner.flags() & ~DEPRECATED);
        }
        acount += writeExtraClassAttributes(c);

        poolbuf.appendInt(JAVA_MAGIC);

        if (c.owner.kind == MDL) {
            // temporarily overide to force use of v53 for module-info.class
            poolbuf.appendChar(0);
            poolbuf.appendChar(53);
        } else {
            poolbuf.appendChar(target.minorVersion);
            poolbuf.appendChar(target.majorVersion);
        }

        writePool(c.pool);

        if (innerClasses != null) {
            writeInnerClasses();
            acount++;
        }

        if (!bootstrapMethods.isEmpty()) {
            writeBootstrapMethods();
            acount++;
        }

        endAttrs(acountIdx, acount);

        poolbuf.appendBytes(databuf.elems, 0, databuf.length);
        out.write(poolbuf.elems, 0, poolbuf.length);

        pool = c.pool = null; // to conserve space
     }
public void writeClassFile ( OutputStream out , ClassSymbol c ) throws IOException , PoolOverflow , StringOverflow { Assert . check ( ( c . flags ( ) & COMPOUND ) == 0 ) ; databuf . reset ( ) ; poolbuf . reset ( ) ; signatureGen . reset ( ) ; pool = c . pool ; innerClasses = null ; innerClassesQueue = null ; bootstrapMethods = new LinkedHashMap < > ( ) ; Type supertype = types . supertype ( c . type ) ; List < Type > interfaces = types . interfaces ( c . type ) ; List < Type > typarams = c . type . getTypeArguments ( ) ; int flags ; if ( c . owner . kind == MDL ) { flags = ACC_MODULE ; } else { flags = adjustFlags ( c . flags ( ) & ~ DEFAULT ) ; if ( ( flags & PROTECTED ) != 0 ) flags |= PUBLIC ; flags = flags & ClassFlags & ~ STRICTFP ; if ( ( flags & INTERFACE ) == 0 ) flags |= ACC_SUPER ; } if ( dumpClassModifiers ) { PrintWriter pw = log . getWriter ( Log . WriterKind . ERROR ) ; pw . println ( ) ; pw . println ( "CLASSFILE  " + c . getQualifiedName ( ) ) ; pw . println ( "---" + flagNames ( flags ) ) ; } databuf . appendChar ( flags ) ; if ( c . owner . kind == MDL ) { PackageSymbol unnamed = ( ( ModuleSymbol ) c . owner ) . unnamedPackage ; databuf . appendChar ( pool . put ( new ClassSymbol ( 0 , names . module_info , unnamed ) ) ) ; } else { databuf . appendChar ( pool . put ( c ) ) ; } databuf . appendChar ( supertype . hasTag ( CLASS ) ? pool . put ( supertype . tsym ) : 0 ) ; databuf . appendChar ( interfaces . length ( ) ) ; for ( List < Type > l = interfaces ; l . nonEmpty ( ) ; l = l . tail ) databuf . appendChar ( pool . put ( l . head . tsym ) ) ; int fieldsCount = 0 ; int methodsCount = 0 ; for ( Symbol sym : c . members ( ) . getSymbols ( NON_RECURSIVE ) ) { switch ( sym . kind ) { case VAR : fieldsCount ++ ; break ; case MTH : if ( ( sym . flags ( ) & HYPOTHETICAL ) == 0 ) methodsCount ++ ; break ; case TYP : enterInner ( ( ClassSymbol ) sym ) ; break ; default : Assert . error ( ) ; } } if ( c . trans_local != null ) { for ( ClassSymbol local : c . trans_local ) { enterInner ( local ) ; } } databuf . appendChar ( fieldsCount ) ; writeFields ( c . members ( ) ) ; databuf . appendChar ( methodsCount ) ; writeMethods ( c . members ( ) ) ; int acountIdx = beginAttrs ( ) ; int acount = 0 ; boolean sigReq = typarams . length ( ) != 0 || supertype . allparams ( ) . length ( ) != 0 ; for ( List < Type > l = interfaces ; ! sigReq && l . nonEmpty ( ) ; l = l . tail ) sigReq = l . head . allparams ( ) . length ( ) != 0 ; if ( sigReq ) { int alenIdx = writeAttr ( names . Signature ) ; if ( typarams . length ( ) != 0 ) signatureGen . assembleParamsSig ( typarams ) ; signatureGen . assembleSig ( supertype ) ; for ( List < Type > l = interfaces ; l . nonEmpty ( ) ; l = l . tail ) signatureGen . assembleSig ( l . head ) ; databuf . appendChar ( pool . put ( signatureGen . toName ( ) ) ) ; signatureGen . reset ( ) ; endAttr ( alenIdx ) ; acount ++ ; } if ( c . sourcefile != null && emitSourceFile ) { int alenIdx = writeAttr ( names . SourceFile ) ; String simpleName = PathFileObject . getSimpleName ( c . sourcefile ) ; databuf . appendChar ( c . pool . put ( names . fromString ( simpleName ) ) ) ; endAttr ( alenIdx ) ; acount ++ ; } if ( genCrt ) { int alenIdx = writeAttr ( names . SourceID ) ; databuf . appendChar ( c . pool . put ( names . fromString ( Long . toString ( getLastModified ( c . sourcefile ) ) ) ) ) ; endAttr ( alenIdx ) ; acount ++ ; alenIdx = writeAttr ( names . CompilationID ) ; databuf . appendChar ( c . pool . put ( names . fromString ( Long . toString ( System . currentTimeMillis ( ) ) ) ) ) ; endAttr ( alenIdx ) ; acount ++ ; } acount += writeFlagAttrs ( c . flags ( ) ) ; acount += writeJavaAnnotations ( c . getRawAttributes ( ) ) ; acount += writeTypeAnnotations ( c . getRawTypeAttributes ( ) , false ) ; acount += writeEnclosingMethodAttribute ( c ) ; if ( c . owner . kind == MDL ) { acount += writeModuleAttribute ( c ) ; acount += writeFlagAttrs ( c . owner . flags ( ) & ~ DEPRECATED ) ; } acount += writeExtraClassAttributes ( c ) ; poolbuf . appendInt ( JAVA_MAGIC ) ; if ( c . owner . kind == MDL ) { poolbuf . appendChar ( 0 ) ; poolbuf . appendChar ( 53 ) ; } else { poolbuf . appendChar ( target . minorVersion ) ; poolbuf . appendChar ( target . majorVersion ) ; } writePool ( c . pool ) ; if ( innerClasses != null ) { writeInnerClasses ( ) ; acount ++ ; } if ( ! bootstrapMethods . isEmpty ( ) ) { writeBootstrapMethods ( ) ; acount ++ ; } endAttrs ( acountIdx , acount ) ; poolbuf . appendBytes ( databuf . elems , 0 , databuf . length ) ; out . write ( poolbuf . elems , 0 , poolbuf . length ) ; pool = c . pool = null ; }
Write class `c' to outstream `out'.