private void doTestBadJarDoesntBlowUp(File badJar) throws IOException {
    FileOutputStream fileOutputStream = new FileOutputStream(badJar);
    JarOutputStream jarOutputStream = new JarOutputStream(fileOutputStream);
    byte[] bogusLine = "bogus line\n".getBytes("UTF-8");
    ZipEntry zipEntry = new ZipEntry("META-INF/services/" + AutoValueExtension.class.getName());
    zipEntry.setSize(bogusLine.length);
    jarOutputStream.putNextEntry(zipEntry);
    jarOutputStream.write(bogusLine);
    jarOutputStream.close();
    ClassLoader badJarLoader = new URLClassLoader(new URL[] {badJar.toURI().toURL()});
    JavaFileObject javaFileObject =
        JavaFileObjects.forSourceLines(
            "foo.bar.Baz",
            "package foo.bar;",
            "",
            "import com.google.auto.value.AutoValue;",
            "",
            "@AutoValue",
            "public abstract class Baz {",
            "}");
    Compilation compilation =
        javac().withProcessors(new AutoValueProcessor(badJarLoader)).compile(javaFileObject);
    assertThat(compilation).succeeded();
    assertThat(compilation)
        .hadWarningContaining(
            "This may be due to a corrupt jar file in the compiler's classpath.\n  "
                + ServiceConfigurationError.class.getName());
    assertThat(compilation).generatedSourceFile("foo.bar.AutoValue_Baz");
  }
Tests that the search for extensions doesn't completely blow AutoValue up if there is a corrupt
jar in the {@code processorpath}. If we're not careful, that can lead to a
ServiceConfigurationError.
value/src/test/java/com/google/auto/value/processor/ExtensionTest.java