Buggy code:
public class Buffer implements IBuffer { protected IFile file ; protected int flags ; protected char [ ] contents ; protected ArrayList changeListeners ; protected IOpenable owner ; protected int gapStart = - 1 ; protected int gapEnd = - 1 ; protected Object lock = new Object ( ) ; protected static final int F_HAS_UNSAVED_CHANGES = 1 ; protected static final int F_IS_READ_ONLY = 2 ; protected static final int F_IS_CLOSED = 4 ; protected Buffer ( IFile file , IOpenable owner , boolean readOnly ) { } public synchronized void addBufferChangedListener ( IBufferChangedListener listener ) { } public void append ( char [ ] text ) { } public void append ( String text ) { } public void close ( ) { } public char getChar ( int position ) { } public char [ ] getCharacters ( ) { } public String getContents ( ) { } public int getLength ( ) { } public IOpenable getOwner ( ) { } public String getText ( int offset , int length ) { } public IResource getUnderlyingResource ( ) { } public boolean hasUnsavedChanges ( ) { } public boolean isClosed ( ) { } public boolean isReadOnly ( ) { } protected void moveAndResizeGap ( int position , int size ) { } protected void notifyChanged ( final BufferChangedEvent event ) { } public synchronized void removeBufferChangedListener ( IBufferChangedListener listener ) { } public void replace ( int position , int length , char [ ] text ) { } public void replace ( int position , int length , String text ) { } public void save ( IProgressMonitor progress , boolean force ) throws JavaModelException { if ( ( isReadOnly ( ) ) || ( ( this . file ) == null ) ) { return ; } if ( ! ( hasUnsavedChanges ( ) ) ) return ; try { String stringContents = this . getContents ( ) ; if ( stringContents == null ) return ; String encoding = null ; try { encoding = this . file . getCharset ( ) ; } catch ( CoreException ce ) { } byte [ ] bytes = ( encoding == null ) ? stringContents . getBytes ( ) : stringContents . getBytes ( encoding ) ; <START_BUG> if ( encoding . equals ( Util . UTF_8 ) ) { <END_BUG> IContentDescription description = this . file . getContentDescription ( ) ; if ( ( description != null ) && ( ( description . getProperty ( IContentDescription . BYTE_ORDER_MARK ) ) != null ) ) { int bomLength = IContentDescription . BOM_UTF_8 . length ; byte [ ] bytesWithBOM = new byte [ ( bytes . length ) + bomLength ] ; System . arraycopy ( IContentDescription . BOM_UTF_8 , 0 , bytesWithBOM , 0 , bomLength ) ; System . arraycopy ( bytes , 0 , bytesWithBOM , bomLength , bytes . length ) ; bytes = bytesWithBOM ; } } ByteArrayInputStream stream = new ByteArrayInputStream ( bytes ) ; if ( this . file . exists ( ) ) { this . file . setContents ( stream , ( force ? ( IResource . FORCE ) | ( IResource . KEEP_HISTORY ) : IResource . KEEP_HISTORY ) , null ) ; } else { this . file . create ( stream , force , null ) ; } } catch ( IOException e ) { throw new JavaModelException ( e , IJavaModelStatusConstants . IO_EXCEPTION ) ; } catch ( CoreException e ) { throw new JavaModelException ( e ) ; } this . flags &= ~ ( Buffer . F_HAS_UNSAVED_CHANGES ) ; } public void setContents ( char [ ] newContents ) { } public void setContents ( String newContents ) { } protected void setReadOnly ( boolean readOnly ) { } public String toString ( ) { } }

Fix:
if ( ( encoding != null ) && ( encoding . equals ( Util . UTF_8 ) ) ) {