Buggy code:
protected boolean isMappingMode ( ClassMetaData meta ) { } protected boolean isMappingMode ( ValueMetaData vmd ) { } public void addMetaData ( ClassMetaData meta ) { } public void addSequenceMetaData ( SequenceMetaData meta ) { } public void addQueryMetaData ( QueryMetaData meta ) { } public void addAll ( MetaDataRepository repos ) { } public boolean removeMetaData ( ClassMetaData meta ) { } public boolean removeSequenceMetaData ( SequenceMetaData meta ) { } public boolean removeQueryMetaData ( QueryMetaData meta ) { } public boolean removeAll ( MetaDataRepository repos ) { } public void clear ( ) { } protected void addSystemMappingElements ( Collection toSerialize ) { } private void serializationSort ( List objs ) { } protected AnnotationPersistenceMetaDataSerializer . SerializationComparator newSerializationComparator ( ) { } private void addSequenceMetaDatas ( Collection all ) { } private void addQueryMetaDatas ( Collection all ) { } protected AnnotationBuilder newAnnotationBuilder ( Class < ? extends Annotation > annType ) { } protected void addAnnotation ( AnnotationBuilder ab , Object meta ) { } protected void addAnnotation ( AnnotationBuilder ab , ClassMetaData meta ) { } protected void addAnnotation ( AnnotationBuilder ab , FieldMetaData meta ) { } protected void addAnnotation ( AnnotationBuilder ab , SequenceMetaData meta ) { } protected void addAnnotation ( AnnotationBuilder ab , QueryMetaData meta ) { } protected AnnotationBuilder addAnnotation ( Class < ? extends Annotation > annType , ClassMetaData meta ) { } protected AnnotationBuilder addAnnotation ( Class < ? extends Annotation > annType , FieldMetaData meta ) { } protected AnnotationBuilder addAnnotation ( Class < ? extends Annotation > annType , SequenceMetaData meta ) { } protected AnnotationBuilder addAnnotation ( Class < ? extends Annotation > annType , QueryMetaData meta ) { } protected void serialize ( Collection objects ) { } protected int type ( Object o ) { } protected void serializeSystemMappingElement ( Object obj ) { } private void serializeQuery ( QueryMetaData meta ) { } private void serializeQueryHints ( QueryMetaData meta , AnnotationBuilder ab ) { } protected void serializeSequence ( SequenceMetaData meta ) { } protected void serializeClass ( ClassMetaData meta ) { } private static Class < ? extends Annotation > getEntityAnnotationType ( ClassMetaData meta ) { } private static Class < ? extends Annotation > getFieldAnnotationType ( FieldMetaData fmd , PersistenceStrategy strat ) { } private static MetaDataTag getEntityTag ( ClassMetaData meta ) { } protected void addClassMappingAnnotations ( ClassMetaData mapping ) { } private void serializeIdClass ( ClassMetaData meta ) { } protected void serializeClassMappingContent ( ClassMetaData mapping ) { } protected void serializeInheritanceContent ( ClassMetaData mapping ) { } protected void serializeQueryMappings ( ClassMetaData meta ) { } private void serializeField ( FieldMetaData fmd , FieldMetaData orig ) { } protected void addFieldMappingAttributes ( FieldMetaData fmd , FieldMetaData orig , AnnotationBuilder ab ) { } protected boolean serializeAttributeOverride ( FieldMetaData fmd , FieldMetaData orig ) { } private void serializeAttributeOverrideContent ( FieldMetaData fmd , FieldMetaData orig ) { } protected void serializeAttributeOverrideMappingContent ( FieldMetaData fmd , FieldMetaData orig , AnnotationBuilder ab ) { } private void serializeCascades ( ValueMetaData vmd , AnnotationBuilder ab ) { } protected PersistenceStrategy getStrategy ( FieldMetaData fmd ) { } private void addBasicAttributes ( FieldMetaData fmd , AnnotationBuilder ab ) { } private void addManyToOneAttributes ( FieldMetaData fmd , AnnotationBuilder ab ) { } private void addOneToOneAttributes ( FieldMetaData fmd , AnnotationBuilder ab ) { } private void addOneToManyAttributes ( FieldMetaData fmd , AnnotationBuilder ab ) { } private void addManyToManyAttributes ( FieldMetaData fmd , AnnotationBuilder ab ) { } private void addTargetEntityAttribute ( FieldMetaData fmd , AnnotationBuilder ab ) { } protected void serializeFieldMappingContent ( FieldMetaData fmd , PersistenceStrategy strategy , AnnotationBuilder ab ) { } protected void addStrategyMappingAttributes ( FieldMetaData fmd , AnnotationBuilder ab ) { } protected Collection getObjects ( ) { } protected void writeAnnotations ( Object meta , List < AnnotationBuilder > builders , Map output ) { } public void serialize ( Map output , int flags ) throws IOException { } public void serialize ( File file , int flags ) throws IOException { try { <START_BUG> FileWriter out = new FileWriter ( ( ( String ) ( AccessController . doPrivileged ( J2DoPrivHelper . getCanonicalPathAction ( file ) ) ) ) , ( ( flags & ( APPEND ) ) > 0 ) ) ; <END_BUG> serialize ( out , flags ) ; out . close ( ) ; } catch ( PrivilegedActionException pae ) { throw ( ( IOException ) ( pae . getException ( ) ) ) ; } } public void serialize ( Writer out , int flags ) throws IOException { } public void serialize ( int flags ) throws IOException { } private static class ClassSeqs implements Comparable < AnnotationPersistenceMetaDataSerializer . ClassSeqs > , Comparator < SequenceMetaData > , SourceTracker { private final SequenceMetaData [ ] _seqs ; public ClassSeqs ( List < SequenceMetaData > seqs ) { } public SequenceMetaData [ ] getSequences ( ) { } public int compare ( SequenceMetaData o1 , SequenceMetaData o2 ) { } public File getSourceFile ( ) { } public Object getSourceScope ( ) { } public int getSourceType ( ) { } public String getResourceName ( ) { } public int compareTo ( AnnotationPersistenceMetaDataSerializer . ClassSeqs other ) { } } private static class ClassQueries implements Comparable < AnnotationPersistenceMetaDataSerializer . ClassQueries > , Comparator < QueryMetaData > , SourceTracker { private final QueryMetaData [ ] _queries ; public ClassQueries ( List < QueryMetaData > queries ) { } public QueryMetaData [ ] getQueries ( ) { } public int compare ( QueryMetaData o1 , QueryMetaData o2 ) { } public File getSourceFile ( ) { } public Object getSourceScope ( ) { } public int getSourceType ( ) { } public String getResourceName ( ) { } public int compareTo ( AnnotationPersistenceMetaDataSerializer . ClassQueries other ) { } } protected class SerializationComparator extends MetaDataInheritanceComparator { public int compare ( Object o1 , Object o2 ) { }

Fix:
FileWriter out = new FileWriter ( AccessController . doPrivileged ( J2DoPrivHelper . getCanonicalPathAction ( file ) ) , ( ( flags & ( APPEND ) ) > 0 ) ) ;