{"action":"created","issue":{"url":"https://api.github.com/repos/bazelbuild/bazel/issues/5888","repository_url":"https://api.github.com/repos/bazelbuild/bazel","labels_url":"https://api.github.com/repos/bazelbuild/bazel/issues/5888/labels{/name}","comments_url":"https://api.github.com/repos/bazelbuild/bazel/issues/5888/comments","events_url":"https://api.github.com/repos/bazelbuild/bazel/issues/5888/events","html_url":"https://github.com/bazelbuild/bazel/issues/5888","id":350414573,"node_id":"MDU6SXNzdWUzNTA0MTQ1NzM=","number":5888,"title":"--javabase is not used for linking","user":{"login":"buchgr","id":1388179,"node_id":"MDQ6VXNlcjEzODgxNzk=","avatar_url":"https://avatars0.githubusercontent.com/u/1388179?v=4","gravatar_id":"","url":"https://api.github.com/users/buchgr","html_url":"https://github.com/buchgr","followers_url":"https://api.github.com/users/buchgr/followers","following_url":"https://api.github.com/users/buchgr/following{/other_user}","gists_url":"https://api.github.com/users/buchgr/gists{/gist_id}","starred_url":"https://api.github.com/users/buchgr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/buchgr/subscriptions","organizations_url":"https://api.github.com/users/buchgr/orgs","repos_url":"https://api.github.com/users/buchgr/repos","events_url":"https://api.github.com/users/buchgr/events{/privacy}","received_events_url":"https://api.github.com/users/buchgr/received_events","type":"User","site_admin":false},"labels":[{"id":192364831,"node_id":"MDU6TGFiZWwxOTIzNjQ4MzE=","url":"https://api.github.com/repos/bazelbuild/bazel/labels/P0","name":"P0","color":"b60205","default":false},{"id":455456251,"node_id":"MDU6TGFiZWw0NTU0NTYyNTE=","url":"https://api.github.com/repos/bazelbuild/bazel/labels/breakage","name":"breakage","color":"b60205","default":false},{"id":356757428,"node_id":"MDU6TGFiZWwzNTY3NTc0Mjg=","url":"https://api.github.com/repos/bazelbuild/bazel/labels/release%20blocker","name":"release blocker","color":"b60205","default":false}],"state":"open","locked":false,"assignee":{"login":"cushon","id":478458,"node_id":"MDQ6VXNlcjQ3ODQ1OA==","avatar_url":"https://avatars0.githubusercontent.com/u/478458?v=4","gravatar_id":"","url":"https://api.github.com/users/cushon","html_url":"https://github.com/cushon","followers_url":"https://api.github.com/users/cushon/followers","following_url":"https://api.github.com/users/cushon/following{/other_user}","gists_url":"https://api.github.com/users/cushon/gists{/gist_id}","starred_url":"https://api.github.com/users/cushon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cushon/subscriptions","organizations_url":"https://api.github.com/users/cushon/orgs","repos_url":"https://api.github.com/users/cushon/repos","events_url":"https://api.github.com/users/cushon/events{/privacy}","received_events_url":"https://api.github.com/users/cushon/received_events","type":"User","site_admin":false},"assignees":[{"login":"cushon","id":478458,"node_id":"MDQ6VXNlcjQ3ODQ1OA==","avatar_url":"https://avatars0.githubusercontent.com/u/478458?v=4","gravatar_id":"","url":"https://api.github.com/users/cushon","html_url":"https://github.com/cushon","followers_url":"https://api.github.com/users/cushon/followers","following_url":"https://api.github.com/users/cushon/following{/other_user}","gists_url":"https://api.github.com/users/cushon/gists{/gist_id}","starred_url":"https://api.github.com/users/cushon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cushon/subscriptions","organizations_url":"https://api.github.com/users/cushon/orgs","repos_url":"https://api.github.com/users/cushon/repos","events_url":"https://api.github.com/users/cushon/events{/privacy}","received_events_url":"https://api.github.com/users/cushon/received_events","type":"User","site_admin":false},{"login":"iirina","id":1687706,"node_id":"MDQ6VXNlcjE2ODc3MDY=","avatar_url":"https://avatars3.githubusercontent.com/u/1687706?v=4","gravatar_id":"","url":"https://api.github.com/users/iirina","html_url":"https://github.com/iirina","followers_url":"https://api.github.com/users/iirina/followers","following_url":"https://api.github.com/users/iirina/following{/other_user}","gists_url":"https://api.github.com/users/iirina/gists{/gist_id}","starred_url":"https://api.github.com/users/iirina/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iirina/subscriptions","organizations_url":"https://api.github.com/users/iirina/orgs","repos_url":"https://api.github.com/users/iirina/repos","events_url":"https://api.github.com/users/iirina/events{/privacy}","received_events_url":"https://api.github.com/users/iirina/received_events","type":"User","site_admin":false}],"milestone":null,"comments":13,"created_at":"2018-08-14T12:52:14Z","updated_at":"2018-08-15T05:52:54Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"We found that Bazel does *not* use the `java_runtime` specified via `--javabase` for \"linking\", but instead seems to use the `--host_javabase`. Below is a simple reproducer.\r\n\r\n```\r\n$ bazel version\r\nBuild label: 0.16.1\r\nBuild target: bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar\r\nBuild time: Mon Aug 13 13:43:36 2018 (1534167816)\r\nBuild timestamp: 1534167816\r\nBuild timestamp as int: 1534167816\r\n```\r\n\r\n```\r\n$ cat BUILD \r\njava_binary(\r\n    name = \"main\",\r\n    srcs = [\"Main.java\"],\r\n    main_class = \"app.Main\",\r\n)\r\n\r\njava_runtime(\r\n  name=\"jdk8\",\r\n  java_home=\"<PATH TO JDK8 INSTALL>\",\r\n  visibility = [\"//visibility:public\"],\r\n)\r\n```\r\n\r\n```\r\n$ cat Main.java \r\npackage app;\r\n\r\nimport java.nio.ByteBuffer;\r\n\r\npublic class Main {\r\n\r\n  public static void main(String... args) {\r\n    byte[] bytes = new byte[10];\r\n    ByteBuffer buffer = ByteBuffer.wrap(bytes);\r\n    buffer.limit(5);\r\n  }\r\n\r\n}\r\n```\r\n\r\n```\r\n$ bazel run :main --javabase=:jdk8\r\nINFO: Analysed target //:main (0 packages loaded).\r\nINFO: Found 1 target...\r\nTarget //:main up-to-date:\r\n  bazel-bin/main.jar\r\n  bazel-bin/main\r\nINFO: Elapsed time: 0.178s, Critical Path: 0.00s\r\nINFO: 0 processes.\r\nINFO: Build completed successfully, 1 total action\r\nINFO: Build completed successfully, 1 total action\r\nException in thread \"main\" java.lang.NoSuchMethodError: java.nio.ByteBuffer.limit(I)Ljava/nio/ByteBuffer;\r\n\tat app.Main.main(Main.java:10)\r\n```\r\n\r\nBazel generates bytecode based on the `--host_javabase` which is JDK9 and then tries to run it under JDK8. Below is the byte code that Bazel generates for invoking `ByteBuffer#limit(int)`. Note that `ByteBuffer limit(int)` only exists since JDK9 https://docs.oracle.com/javase/9/docs/api/java/nio/ByteBuffer.html#limit-int-. In JDK8 the method is inherited from `java.nio.Buffer` and had the signature `Buffer limit(int)` https://docs.oracle.com/javase/8/docs/api/java/nio/ByteBuffer.html\r\n\r\n```\r\ninvokevirtual #3                  // Method java/nio/ByteBuffer.limit:(I)Ljava/nio/ByteBuffer;\r\n```"},"comment":{"url":"https://api.github.com/repos/bazelbuild/bazel/issues/comments/413100951","html_url":"https://github.com/bazelbuild/bazel/issues/5888#issuecomment-413100951","issue_url":"https://api.github.com/repos/bazelbuild/bazel/issues/5888","id":413100951,"node_id":"MDEyOklzc3VlQ29tbWVudDQxMzEwMDk1MQ==","user":{"login":"davido","id":347173,"node_id":"MDQ6VXNlcjM0NzE3Mw==","avatar_url":"https://avatars1.githubusercontent.com/u/347173?v=4","gravatar_id":"","url":"https://api.github.com/users/davido","html_url":"https://github.com/davido","followers_url":"https://api.github.com/users/davido/followers","following_url":"https://api.github.com/users/davido/following{/other_user}","gists_url":"https://api.github.com/users/davido/gists{/gist_id}","starred_url":"https://api.github.com/users/davido/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davido/subscriptions","organizations_url":"https://api.github.com/users/davido/orgs","repos_url":"https://api.github.com/users/davido/repos","events_url":"https://api.github.com/users/davido/events{/privacy}","received_events_url":"https://api.github.com/users/davido/received_events","type":"User","site_admin":false},"created_at":"2018-08-15T05:52:54Z","updated_at":"2018-08-15T05:52:54Z","author_association":"CONTRIBUTOR","body":"It turns out that building Gerrit on JDK9 is failing on Bazel master without #5894 as well. I filed: #5896."}}
{"actor":{"display_login":"davido"}}