void writeClass(final Pool pool, final ClassSymbol cs, final ClassWriter writer)
        throws IOException
    {
        try {
            pool.reset();
            cs.pool = pool;
            writer.writeClass(cs);
            for (Scope.Entry e = cs.members().elems; e != null; e = e.sibling) {
                if (e.sym.kind == Kinds.TYP) {
                    ClassSymbol nestedClass = (ClassSymbol)e.sym;
                    nestedClass.complete();
                    writeClass(pool, nestedClass, writer);
                }
            }
        } catch (ClassWriter.StringOverflow ex) {
            throw new RuntimeException(ex);
        } catch (ClassWriter.PoolOverflow ex) {
            throw new RuntimeException(ex);
        }
    }