Buggy code:
public String getEncoding ( ) { } public void setUseLanguageEncodingFlag ( boolean b ) { } public void setCreateUnicodeExtraFields ( ZipArchiveOutputStream . UnicodeExtraFieldPolicy b ) { } public void setFallbackToUTF8 ( boolean b ) { } public void setUseZip64 ( Zip64Mode mode ) { } @ Override public void finish ( ) throws IOException { } @ Override public void closeArchiveEntry ( ) throws IOException { } private void closeCopiedEntry ( ) throws IOException { } private void doCloseEntry ( long realCrc , long bytesWritten ) throws IOException { } private void doCloseCopiedEntry ( ) throws IOException { } private void closeEntry ( boolean actuallyNeedsZip64 ) throws IOException { } private void preClose ( ) throws IOException { } public void addRawArchiveEntry ( ZipArchiveEntry entry , InputStream rawStream ) throws IOException { } private void flushDeflater ( ) throws IOException { } private boolean handleSizesAndCrc ( long bytesWritten , long crc , Zip64Mode effectiveMode ) throws ZipException { } private boolean checkIfNeedsZip64 ( Zip64Mode effectiveMode ) throws ZipException { } private void rewriteSizesAndCrc ( boolean actuallyNeedsZip64 ) throws IOException { } @ Override public void putArchiveEntry ( ArchiveEntry archiveEntry ) throws IOException { } private void setDefaults ( ZipArchiveEntry entry ) { } private void validateSizeInformation ( Zip64Mode effectiveMode ) throws ZipException { } private boolean shouldAddZip64Extra ( ZipArchiveEntry entry , Zip64Mode mode ) { } public void setComment ( String comment ) { } public void setLevel ( int level ) { } public void setMethod ( int method ) { } @ Override public boolean canWriteEntryData ( ArchiveEntry ae ) { } @ Override public void write ( byte [ ] b , int offset , int length ) throws IOException { } private void writeCounted ( byte [ ] data ) throws IOException { } final byte [ ] copyBuffer = new byte [ 16384 ] ; private void copyFromZipInputStream ( InputStream src ) throws IOException { } @ Override public void close ( ) throws IOException { } @ Override public void flush ( ) throws IOException { } static final byte [ ] LFH_SIG = ZipLong . LFH_SIG . getBytes ( ) ; static final byte [ ] DD_SIG = ZipLong . DD_SIG . getBytes ( ) ; static final byte [ ] CFH_SIG = ZipLong . CFH_SIG . getBytes ( ) ; static final byte [ ] EOCD_SIG = ZipLong . getBytes ( 101010256L ) ; static final byte [ ] ZIP64_EOCD_SIG = ZipLong . getBytes ( 101075792L ) ; static final byte [ ] ZIP64_EOCD_LOC_SIG = ZipLong . getBytes ( 117853008L ) ; protected final void deflate ( ) throws IOException { } protected void writeLocalFileHeader ( ZipArchiveEntry ze ) throws IOException { } private byte [ ] createLocalFileHeader ( ZipArchiveEntry ze , ByteBuffer name , boolean encodable ) { } private void addUnicodeExtraFields ( ZipArchiveEntry ze , boolean encodable , ByteBuffer name ) throws IOException { } protected void writeDataDescriptor ( ZipArchiveEntry ze ) throws IOException { } protected void writeCentralFileHeader ( ZipArchiveEntry ze ) throws IOException { } private byte [ ] createCentralFileHeader ( ZipArchiveEntry ze , ByteBuffer name , long lfhOffset , boolean needsZip64Extra ) throws IOException { } private void handleZip64Extra ( ZipArchiveEntry ze , long lfhOffset , boolean needsZip64Extra ) { } protected void writeCentralDirectoryEnd ( ) throws IOException { } private static final byte [ ] ONE = ZipLong . getBytes ( 1L ) ; protected void writeZip64CentralDirectory ( ) throws IOException { if ( ( zip64Mode ) == ( Zip64Mode . Never ) ) { return ; } if ( ( ! ( hasUsedZip64 ) ) && ( ( ( ( cdOffset ) >= ( ZipConstants . ZIP64_MAGIC ) ) || ( ( cdLength ) >= ( ZipConstants . ZIP64_MAGIC ) ) ) || ( ( entries . size ( ) ) >= ( ZipConstants . ZIP64_MAGIC_SHORT ) ) ) ) { hasUsedZip64 = true ; } if ( ! ( hasUsedZip64 ) ) { return ; } <START_BUG> long offset = streamCompressor . getBytesWritten ( ) ; <END_BUG> writeOut ( ZipArchiveOutputStream . ZIP64_EOCD_SIG ) ; writeOut ( ZipEightByteInteger . getBytes ( ( ( ( ( ( ( ( ( ZipConstants . SHORT ) + ( ZipConstants . SHORT ) ) + ( ZipConstants . WORD ) ) + ( ZipConstants . WORD ) ) + ( ZipConstants . DWORD ) ) + ( ZipConstants . DWORD ) ) + ( ZipConstants . DWORD ) ) + ( ZipConstants . DWORD ) ) ) ) ; writeOut ( ZipShort . getBytes ( ZipConstants . ZIP64_MIN_VERSION ) ) ; writeOut ( ZipShort . getBytes ( ZipConstants . ZIP64_MIN_VERSION ) ) ; writeOut ( ZipArchiveOutputStream . LZERO ) ; writeOut ( ZipArchiveOutputStream . LZERO ) ; byte [ ] num = ZipEightByteInteger . getBytes ( entries . size ( ) ) ; writeOut ( num ) ; writeOut ( num ) ; writeOut ( ZipEightByteInteger . getBytes ( cdLength ) ) ; writeOut ( ZipEightByteInteger . getBytes ( cdOffset ) ) ; writeOut ( ZipArchiveOutputStream . ZIP64_EOCD_LOC_SIG ) ; writeOut ( ZipArchiveOutputStream . LZERO ) ; writeOut ( ZipEightByteInteger . getBytes ( offset ) ) ; writeOut ( ZipArchiveOutputStream . ONE ) ; } protected final void writeOut ( byte [ ] data ) throws IOException { } protected final void writeOut ( byte [ ] data , int offset , int length ) throws IOException { } private GeneralPurposeBit getGeneralPurposeBits ( final int zipMethod , final boolean utfFallback ) { } private int versionNeededToExtract ( final int zipMethod , final boolean zip64 ) { } private boolean isDeflatedToOutputStream ( int zipMethod ) { } @ Override public ArchiveEntry createArchiveEntry ( File inputFile , String entryName ) throws IOException { } private Zip64ExtendedInformationExtraField getZip64Extra ( ZipArchiveEntry ze ) { } private boolean hasZip64Extra ( ZipArchiveEntry ze ) { } private Zip64Mode getEffectiveZip64Mode ( ZipArchiveEntry ze ) { } private ZipEncoding getEntryEncoding ( ZipArchiveEntry ze ) { } private ByteBuffer getName ( ZipArchiveEntry ze ) throws IOException { }

Fix:
long offset = streamCompressor . getTotalBytesWritten ( ) ;