private static Reader readerFromJar(URL resourceUrl) throws URISyntaxException, IOException {
    // Jar URLs look like this: jar:file:/path/to/file.jar!/entry/within/jar
    // So take apart the URL to open the jar /path/to/file.jar and read the entry
    // entry/within/jar from it.
    // We could use the methods from JarURLConnection here, but that would risk provoking the same
    // problem that prompted this workaround in the first place.
    String resourceUrlString = resourceUrl.toString().substring("jar:".length());
    int bang = resourceUrlString.lastIndexOf('!');
    String entryName = resourceUrlString.substring(bang + 1);
    if (entryName.startsWith("/")) {
      entryName = entryName.substring(1);
    }
    URI jarUri = new URI(resourceUrlString.substring(0, bang));
    try (JarFile jar = new JarFile(new File(jarUri));
        InputStream in = jar.getInputStream(jar.getJarEntry(entryName))) {
      String contents = new String(ByteStreams.toByteArray(in), UTF_8);
      return new StringReader(contents);
    }
  }
Returns the result of substituting the variables defined by the fields of this class (a
concrete subclass of TemplateVars) into the template returned by {@link #parsedTemplate()}.
value/src/main/java/com/google/auto/value/processor/TemplateVars.java