class ServiceProviderExtensionStorage extends ExtensionStorage {

    public static final String EXTENSIONS_RESOURCE = "META-INF/services";

    public ServiceProviderExtensionStorage(ExtensionAnnotationProcessor processor) {
        super(processor);
    }

    @Override
    public Map<String, Set<String>> read() {<FILL_FUNCTION_BODY>}

    @Override
    public void write(Map<String, Set<String>> extensions) {
        for (Map.Entry<String, Set<String>> entry : extensions.entrySet()) {
            String extensionPoint = entry.getKey();
            try {
                FileObject file = getFiler().createResource(StandardLocation.CLASS_OUTPUT, "", EXTENSIONS_RESOURCE
                    + "/" + extensionPoint);
                try (BufferedWriter writer = new BufferedWriter(file.openWriter())) {
                    // write header
                    writer.write("# Generated by PF4J"); // write header
                    writer.newLine();
                    // write extensions
                    for (String extension : entry.getValue()) {
                        writer.write(extension);
                        if (!isExtensionOld(extensionPoint, extension)) {
                            writer.write(" # pf4j extension");
                        }
                        writer.newLine();
                    }
                }
            } catch (FileNotFoundException e) {
                // it's the first time, create the file
            } catch (FilerException e) {
                // re-opening the file for reading or after writing is ignorable
            } catch (IOException e) {
                error(e.toString());
            }
        }
    }

    private boolean isExtensionOld(String extensionPoint, String extension) {
        return processor.getOldExtensions().containsKey(extensionPoint)
            && processor.getOldExtensions().get(extensionPoint).contains(extension);
    }

}

        Map<String, Set<String>> extensions = new HashMap<>();

        for (String extensionPoint : processor.getExtensions().keySet()) {
            try {
                FileObject file = getFiler().getResource(StandardLocation.CLASS_OUTPUT, "", EXTENSIONS_RESOURCE
                    + "/" + extensionPoint);
                Set<String> entries = new HashSet<>();
                ExtensionStorage.read(file.openReader(true), entries);
                extensions.put(extensionPoint, entries);
            } catch (FileNotFoundException | NoSuchFileException e) {
                // doesn't exist, ignore
            } catch (FilerException e) {
                // re-opening the file for reading or after writing is ignorable
            } catch (IOException e) {
                error(e.getMessage());
            }
        }

        return extensions;
    
<methods>public void <init>(org.pf4j.processor.ExtensionAnnotationProcessor) ,public abstract Map<java.lang.String,Set<java.lang.String>> read() ,public static void read(java.io.Reader, Set<java.lang.String>) throws java.io.IOException,public abstract void write(Map<java.lang.String,Set<java.lang.String>>) <variables>private static final java.util.regex.Pattern COMMENT,private static final java.util.regex.Pattern WHITESPACE,protected final non-sealed org.pf4j.processor.ExtensionAnnotationProcessor processor