{"action":"created","issue":{"url":"https://api.github.com/repos/facebook/buck/issues/1781","repository_url":"https://api.github.com/repos/facebook/buck","labels_url":"https://api.github.com/repos/facebook/buck/issues/1781/labels{/name}","comments_url":"https://api.github.com/repos/facebook/buck/issues/1781/comments","events_url":"https://api.github.com/repos/facebook/buck/issues/1781/events","html_url":"https://github.com/facebook/buck/issues/1781","id":299560630,"number":1781,"title":"Enabling proper Error Prone integration with Buck","user":{"login":"msridhar","id":193105,"avatar_url":"https://avatars1.githubusercontent.com/u/193105?v=4","gravatar_id":"","url":"https://api.github.com/users/msridhar","html_url":"https://github.com/msridhar","followers_url":"https://api.github.com/users/msridhar/followers","following_url":"https://api.github.com/users/msridhar/following{/other_user}","gists_url":"https://api.github.com/users/msridhar/gists{/gist_id}","starred_url":"https://api.github.com/users/msridhar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/msridhar/subscriptions","organizations_url":"https://api.github.com/users/msridhar/orgs","repos_url":"https://api.github.com/users/msridhar/repos","events_url":"https://api.github.com/users/msridhar/events{/privacy}","received_events_url":"https://api.github.com/users/msridhar/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":7,"created_at":"2018-02-23T00:41:13Z","updated_at":"2018-03-08T01:20:55Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"We wanted to have a discussion on the best way to \"upstream\" our technique for using using [Error Prone](http://errorprone.info/) with Buck, which would primarily consist of adding documentation.\r\n\r\nFor the most part, our integration uses the available `javac_jar` and `compiler_class_name` options, where the javac jar is the [Error Prone Ant artifact](http://search.maven.org/#search%7Cga%7C1%7Ca%3A%22error_prone_ant%22).  Error Prone is packaged with [a version of the JDK 9 javac compiler](http://search.maven.org/#search%7Cga%7C1%7Ca%3A%22javac%22), whereas we currently build on JDK 8.  This makes integration slightly tricky, as the JDK 9 javac includes updated versions of certain `javax.tools` and `javax.lang.model.type` classes as compared to what is in the JDK 8 `rt.jar`.  To work around this issue, we have extracted the relevant classes from the EP javac jar into a small new jar `tiny_tools.jar` that we place in Buck's bootclasspath via `.buckjavaargs`.  (Placing the full EP Ant artifact in the bootclasspath is risky; see google/error-prone#934.)  With this change, everything seems to work well, including plugin checks.  One downside is that the EP Ant artifact exposes some third-party libraries like Guava to annotation processors; we opened google/error-prone#950 to relocate the classes most likely to cause conflicts.\r\n\r\nAn alternative integration point would be to use Error Prone as a Javac plugin, which is supported by Error Prone (see [the docs](http://errorprone.info/docs/installation)).  However, this integration requires Java 9, and we are still building on JDK 8; we have not yet tried it in the context of Buck builds.\r\n\r\nIn terms of upstreaming, one question is where the `tiny_tools.jar` file should live.  We could create a separate Maven artifact for it, or add it to the Buck repo.  It was created via a fairly manual process, and it could requiring updating when Error Prone uses a new javac version.  We could also add some scripting around this to auto-generate the jar.\r\n\r\nOther feedback / comments welcome.  Thanks!"},"comment":{"url":"https://api.github.com/repos/facebook/buck/issues/comments/371344528","html_url":"https://github.com/facebook/buck/issues/1781#issuecomment-371344528","issue_url":"https://api.github.com/repos/facebook/buck/issues/1781","id":371344528,"user":{"login":"msridhar","id":193105,"avatar_url":"https://avatars1.githubusercontent.com/u/193105?v=4","gravatar_id":"","url":"https://api.github.com/users/msridhar","html_url":"https://github.com/msridhar","followers_url":"https://api.github.com/users/msridhar/followers","following_url":"https://api.github.com/users/msridhar/following{/other_user}","gists_url":"https://api.github.com/users/msridhar/gists{/gist_id}","starred_url":"https://api.github.com/users/msridhar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/msridhar/subscriptions","organizations_url":"https://api.github.com/users/msridhar/orgs","repos_url":"https://api.github.com/users/msridhar/repos","events_url":"https://api.github.com/users/msridhar/events{/privacy}","received_events_url":"https://api.github.com/users/msridhar/received_events","type":"User","site_admin":false},"created_at":"2018-03-08T01:20:55Z","updated_at":"2018-03-08T01:20:55Z","author_association":"CONTRIBUTOR","body":"Some further clarity on classloader stuff.  My understanding of `bootstrap_deploy.jar` was way off in the above comment.  What actually happens is:\r\n1. Bazel places the full javac jar in the bootclasspath [here](https://github.com/bazelbuild/bazel/blob/43fd34062f3e1a4eae57209e80aefadf00c1ade6/src/java_tools/buildjar/BUILD#L100)\r\n2. Separate code manages the bootclasspath used when running javac, through a mix of passing the `-bootclasspath` parameter and calling the file manager APIs, e.g., [here](https://github.com/bazelbuild/bazel/blob/57a2ad72d954b6986fbc857d44694ffb516cdb1b/src/java_tools/buildjar/java/com/google/devtools/build/java/bazel/BazelJavaCompiler.java#L60) and [here](https://github.com/bazelbuild/bazel/blob/57a2ad72d954b6986fbc857d44694ffb516cdb1b/src/java_tools/buildjar/java/com/google/devtools/build/java/bazel/BazelJavaCompiler.java#L206).  This makes sense, as for example if you're targeting 1.6, you want the bootclasspath seen by the compiler to match a 1.6 JVM.\r\n\r\nAnyway, wanted to clarify that.  Still thinking about the right integration for Buck; will post back when I have something."}}
{"actor":{"display_login":"msridhar"}}