Source:
<code>public void writeToFile( String jaifPath, AnnotationsInContexts annosToIgnore, OutputFormat outputFormat, BaseTypeChecker checker) { assert jaifPath.endsWith(".jaif"); AScene scene = theScene.clone(); removeAnnosFromScene(scene, annosToIgnore); scene.prune(); String filepath; switch (outputFormat) { case JAIF: filepath = jaifPath; break; case STUB: String astubWithChecker = "-" + checker.getClass().getCanonicalName() + ".astub"; filepath = jaifPath.replace(".jaif", astubWithChecker); break; default: throw new BugInCF("Unhandled outputFormat " + outputFormat); } new File(filepath).delete(); if (!scene.isEmpty()) { try { switch (outputFormat) { case STUB: <START> SceneToStubWriter.write(this, filepath, checker); <END> break; case JAIF: for (Map.Entry<String, AClass> classEntry : scene.classes.entrySet()) { AClass aClass = classEntry.getValue(); for (Map.Entry<String, AMethod> methodEntry : aClass.getMethods().entrySet()) { AMethod aMethod = methodEntry.getValue(); List<AnnotationMirror> contractAnnotationMirrors = checker.getTypeFactory().getContractAnnotations(aMethod); List<Annotation> contractAnnotations = mapList( AnnotationConverter::annotationMirrorToAnnotation, contractAnnotationMirrors); aMethod.contracts = contractAnnotations; } } IndexFileWriter.write(scene, new FileWriter(filepath)); break; default: throw new BugInCF("Unhandled outputFormat " + outputFormat); } } catch (IOException e) { throw new UserError("Problem while writing %s: %s", filepath, e.getMessage()); } catch (DefException e) { throw new BugInCF(e); } } }</code><technical_language>Instead of passing in checker, add contracts AMethod writing out scene, reusing code below</technical_language>

Target:
public void writeToFile( String jaifPath, AnnotationsInContexts annosToIgnore, OutputFormat outputFormat, BaseTypeChecker checker) { assert jaifPath.endsWith(".jaif"); AScene scene = theScene.clone(); removeAnnosFromScene(scene, annosToIgnore); scene.prune(); String filepath; switch (outputFormat) { case JAIF: filepath = jaifPath; break; case STUB: String astubWithChecker = "-" + checker.getClass().getCanonicalName() + ".astub"; filepath = jaifPath.replace(".jaif", astubWithChecker); break; default: throw new BugInCF("Unhandled outputFormat " + outputFormat); } new File(filepath).delete(); if (!scene.isEmpty()) { try { switch (outputFormat) { case STUB: SceneToStubWriter.write(this, filepath, checker); break; case JAIF: for (Map.Entry<String, AClass> classEntry : scene.classes.entrySet()) { AClass aClass = classEntry.getValue(); for (Map.Entry<String, AMethod> methodEntry : aClass.getMethods().entrySet()) { AMethod aMethod = methodEntry.getValue(); List<AnnotationMirror> contractAnnotationMirrors = checker.getTypeFactory().getContractAnnotations(aMethod); List<Annotation> contractAnnotations = CollectionsPlume.mapList( AnnotationConverter::annotationMirrorToAnnotation, contractAnnotationMirrors); aMethod.contracts = contractAnnotations; } } IndexFileWriter.write(scene, new FileWriter(filepath)); break; default: throw new BugInCF("Unhandled outputFormat " + outputFormat); } } catch (IOException e) { throw new UserError("Problem while writing %s: %s", filepath, e.getMessage()); } catch (DefException e) { throw new BugInCF(e); } } }