{"action":"created","issue":{"url":"https://api.github.com/repos/bazelbuild/bazel/issues/8313","repository_url":"https://api.github.com/repos/bazelbuild/bazel","labels_url":"https://api.github.com/repos/bazelbuild/bazel/issues/8313/labels{/name}","comments_url":"https://api.github.com/repos/bazelbuild/bazel/issues/8313/comments","events_url":"https://api.github.com/repos/bazelbuild/bazel/issues/8313/events","html_url":"https://github.com/bazelbuild/bazel/issues/8313","id":443785004,"node_id":"MDU6SXNzdWU0NDM3ODUwMDQ=","number":8313,"title":"Bazel apparently using wrong host JDK","user":{"login":"davidsantiago","id":151663,"node_id":"MDQ6VXNlcjE1MTY2Mw==","avatar_url":"https://avatars3.githubusercontent.com/u/151663?v=4","gravatar_id":"","url":"https://api.github.com/users/davidsantiago","html_url":"https://github.com/davidsantiago","followers_url":"https://api.github.com/users/davidsantiago/followers","following_url":"https://api.github.com/users/davidsantiago/following{/other_user}","gists_url":"https://api.github.com/users/davidsantiago/gists{/gist_id}","starred_url":"https://api.github.com/users/davidsantiago/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davidsantiago/subscriptions","organizations_url":"https://api.github.com/users/davidsantiago/orgs","repos_url":"https://api.github.com/users/davidsantiago/repos","events_url":"https://api.github.com/users/davidsantiago/events{/privacy}","received_events_url":"https://api.github.com/users/davidsantiago/received_events","type":"User","site_admin":false},"labels":[{"id":1020663976,"node_id":"MDU6TGFiZWwxMDIwNjYzOTc2","url":"https://api.github.com/repos/bazelbuild/bazel/labels/team-Rules-Java","name":"team-Rules-Java","color":"f1f442","default":false},{"id":1020665933,"node_id":"MDU6TGFiZWwxMDIwNjY1OTMz","url":"https://api.github.com/repos/bazelbuild/bazel/labels/untriaged","name":"untriaged","color":"c34ddd","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2019-05-14T08:40:56Z","updated_at":"2019-05-20T15:07:29Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"### Description of the problem / feature request:\r\n\r\nCaveat: I've been doing my best to read and understand Bazel's documentation for the three different Java environments, and toolchains, and so forth. So perhaps this winds up being a documentation request issue. \r\n\r\nI've been having a hard time getting Bazel to build using jdk8 as the host jdk, and don't think I've had success doing so. I only have jdk8 installed on my system: \r\n\r\n```bash\r\ndavid:code davidsantiago$ `which javac` -version\r\njavac 1.8.0_131\r\n```\r\n\r\nBut when I run `bazel build ... -java_toolchain=@bazel_tools//tools/jdk:toolchain_hostjdk8`, it apparently doesn't use jdk8. The reasons I think this are \r\n\r\n1. I get a [build error in Kotlin that happens when using jdk11](https://youtrack.jetbrains.com/issue/KT-28587)\r\n2. `bazel info` also thinks I am using jdk11: \r\n\r\n```bash\r\n$ bazel info --java_toolchain=@bazel_tools//tools/jdk:toolchain_hostjdk8 --verbose_failures\r\n...\r\njava-home: /private/var/tmp/_bazel_davidsantiago/install/1a037b6c0d8096293d1eecfde6528fbd/_embedded_binaries/embedded_tools/jdk\r\njava-runtime: OpenJDK Runtime Environment (build 11.0.2+7-LTS) by Azul Systems, Inc.\r\njava-vm: OpenJDK 64-Bit Server VM (build 11.0.2+7-LTS, mixed mode) by Azul Systems, Inc.\r\n...\r\n```\r\n\r\n3. When I run my build command with the `--toolchain_resolution_debug` flag, it repeatedly says \r\n\r\n```bash\r\nINFO: ToolchainResolver: Selected execution platform @bazel_tools//platforms:host_platform, type @bazel_tools//tools/jdk:toolchain_type -> toolchain @bazel_tools//tools/jdk:dummy_toolchain\r\n```\r\n\r\nWhich, I'm not sure what it is, but it is not what I asked for with the `--java_toolchain` flag above. \r\n\r\nSo I'm having a hard time thinking I'm not building with jdk11 as the host jdk, or at least I can't find any reason to think otherwise. I think I've followed the [docs](https://docs.bazel.build/versions/master/user-manual.html#flags-options), though I admit my understanding of the intricacies here is totally sketchy. \r\n\r\n### Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.\r\n\r\nI can see this just by running `bazel info` or `bazel info --java_toolchain=@bazel_tools//tools/jdk:toolchain_hostjdk8` or any of the other plausibly jdk8 toolchains defined in that package. \r\n\r\nI'm running Bazel 0.25.2, which I installed via `brew install bazelbuild/tap/bazel`, on Mac OS X 10.14.4.\r\n\r\nI'm using [these kotlin build rules](https://github.com/keith/rules_kotlin/tree/ks/bazel-fixups), and I realize that might have some involvement here. However, I don't think you need to reach the kotlin rules to see this issue, as evidenced by the `bazel info` command above. Also, I get the exact same java toolchain resolution messages from running \r\n\r\n`bazel build --java_toolchain=@bazel_tools//tools/jdk:toolchain_hostjdk8 examples/java-skylark/... --toolchain_resolution_debug` \r\n\r\nin the bazel repo, although that one will build successfully. Interestingly, if I try it on the `java-native` example instead, I get a build error using the --java_toolchain flag as above:\r\n\r\n```\r\n... Selected execution platform ... @bazel_tools//tools/jdk:dummy_toolchain blah blah blah ...\r\nERROR: /Users/davidsantiago/Documents/Work/bazel/examples/java-native/src/main/java/com/example/myproject/BUILD:3:1: Building examples/java-native/src/main/java/com/example/myproject/hello-world.jar () failed: Worker process returned an unparseable WorkResponse!\r\n\r\nDid you try to print something to stdout? Workers aren't allowed to do this, as it breaks the protocol between Bazel and the worker process.\r\n\r\n---8<---8<--- Exception details ---8<---8<---\r\ncom.google.protobuf.InvalidProtocolBufferException$InvalidWireTypeException: Protocol message tag had invalid wire type.\r\n\tat com.google.protobuf.InvalidProtocolBufferException.invalidWireType(InvalidProtocolBufferException.java:115)\r\n\tat com.google.protobuf.UnknownFieldSet$Builder.mergeFieldFrom(UnknownFieldSet.java:551)\r\n\tat com.google.protobuf.GeneratedMessageV3.parseUnknownFieldProto3(GeneratedMessageV3.java:305)\r\n\tat com.google.devtools.build.lib.worker.WorkerProtocol$WorkResponse.<init>(WorkerProtocol.java:1936)\r\n\tat com.google.devtools.build.lib.worker.WorkerProtocol$WorkResponse.<init>(WorkerProtocol.java:1886)\r\n\tat com.google.devtools.build.lib.worker.WorkerProtocol$WorkResponse$1.parsePartialFrom(WorkerProtocol.java:2503)\r\n\tat com.google.devtools.build.lib.worker.WorkerProtocol$WorkResponse$1.parsePartialFrom(WorkerProtocol.java:2497)\r\n\tat com.google.protobuf.AbstractParser.parsePartialFrom(AbstractParser.java:221)\r\n\tat com.google.protobuf.AbstractParser.parsePartialDelimitedFrom(AbstractParser.java:262)\r\n\tat com.google.protobuf.AbstractParser.parseDelimitedFrom(AbstractParser.java:275)\r\n\tat com.google.protobuf.AbstractParser.parseDelimitedFrom(AbstractParser.java:280)\r\n\tat com.google.protobuf.AbstractParser.parseDelimitedFrom(AbstractParser.java:49)\r\n\tat com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(GeneratedMessageV3.java:347)\r\n\tat com.google.devtools.build.lib.worker.WorkerProtocol$WorkResponse.parseDelimitedFrom(WorkerProtocol.java:2145)\r\n\tat com.google.devtools.build.lib.worker.WorkerSpawnRunner.execInWorker(WorkerSpawnRunner.java:349)\r\n\tat com.google.devtools.build.lib.worker.WorkerSpawnRunner.actuallyExec(WorkerSpawnRunner.java:172)\r\n\tat com.google.devtools.build.lib.worker.WorkerSpawnRunner.exec(WorkerSpawnRunner.java:121)\r\n\tat com.google.devtools.build.lib.exec.SpawnRunner.execAsync(SpawnRunner.java:224)\r\n\tat com.google.devtools.build.lib.exec.AbstractSpawnStrategy.exec(AbstractSpawnStrategy.java:113)\r\n\tat com.google.devtools.build.lib.exec.AbstractSpawnStrategy.exec(AbstractSpawnStrategy.java:78)\r\n\tat com.google.devtools.build.lib.actions.SpawnActionContext.beginExecution(SpawnActionContext.java:41)\r\n\tat com.google.devtools.build.lib.exec.ProxySpawnActionContext.beginExecution(ProxySpawnActionContext.java:60)\r\n\tat com.google.devtools.build.lib.actions.SpawnContinuation$1.execute(SpawnContinuation.java:80)\r\n\tat com.google.devtools.build.lib.rules.java.JavaCompileAction$JavaActionContinuation.execute(JavaCompileAction.java:514)\r\n\tat com.google.devtools.build.lib.rules.java.JavaCompileAction.beginExecution(JavaCompileAction.java:310)\r\n\tat com.google.devtools.build.lib.rules.java.JavaCompileAction.execute(JavaCompileAction.java:317)\r\n\tat com.google.devtools.build.lib.skyframe.SkyframeActionExecutor$4.execute(SkyframeActionExecutor.java:830)\r\n\tat com.google.devtools.build.lib.skyframe.SkyframeActionExecutor$ActionRunner.continueAction(SkyframeActionExecutor.java:965)\r\n\tat com.google.devtools.build.lib.skyframe.SkyframeActionExecutor$ActionRunner.run(SkyframeActionExecutor.java:937)\r\n\tat com.google.devtools.build.lib.skyframe.ActionExecutionState.runStateMachine(ActionExecutionState.java:114)\r\n\tat com.google.devtools.build.lib.skyframe.ActionExecutionState.getResultOrDependOnFuture(ActionExecutionState.java:78)\r\n\tat com.google.devtools.build.lib.skyframe.SkyframeActionExecutor.executeAction(SkyframeActionExecutor.java:563)\r\n\tat com.google.devtools.build.lib.skyframe.ActionExecutionFunction.checkCacheAndExecuteIfNeeded(ActionExecutionFunction.java:707)\r\n\tat com.google.devtools.build.lib.skyframe.ActionExecutionFunction.compute(ActionExecutionFunction.java:253)\r\n\tat com.google.devtools.build.skyframe.AbstractParallelEvaluator$Evaluate.run(AbstractParallelEvaluator.java:453)\r\n\tat com.google.devtools.build.lib.concurrent.AbstractQueueVisitor$WrappedRunnable.run(AbstractQueueVisitor.java:387)\r\n\tat java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)\r\n\tat java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)\r\n\tat java.base/java.lang.Thread.run(Unknown Source)\r\n---8<---8<--- End of exception details ---8<---8<---\r\n\r\n---8<---8<--- Start of log ---8<---8<---\r\n-Xbootclasspath/p is no longer a supported option.\r\nion.\r\n---8<---8<--- End of log ---8<---8<---\r\nINFO: Elapsed time: 0.497s, Critical Path: 0.10s\r\nINFO: 0 processes.\r\nFAILED: Build did NOT complete successfully\r\n```\r\n\r\nI'm unsure what to make of this difference in results, but I'd love to get to a point where I feel confident in what jdk is being used. Quite likely I'm confused out of my mind here. \r\n\r\n### What operating system are you running Bazel on?\r\n\r\nMac OS X 10.14.4\r\n\r\n### What's the output of `bazel info release`?\r\n\r\nrelease 0.25.2\r\n\r\n###  Have you found anything relevant by searching the web?\r\n\r\nI have not, the only thing has been Bazel's own documentation on toolchains, which doesn't cover the Java situation in detail. I did ask in the Bazel slack #general channel, and @laszlocsomor [was very helpful](https://bazelbuild.slack.com/archives/CA31HN1T3/p1557819548223800)\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/bazelbuild/bazel/issues/comments/494027394","html_url":"https://github.com/bazelbuild/bazel/issues/8313#issuecomment-494027394","issue_url":"https://api.github.com/repos/bazelbuild/bazel/issues/8313","id":494027394,"node_id":"MDEyOklzc3VlQ29tbWVudDQ5NDAyNzM5NA==","user":{"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},"created_at":"2019-05-20T15:07:29Z","updated_at":"2019-05-20T15:07:29Z","author_association":"CONTRIBUTOR","body":"@davidsantiago thank you for your feedback! I agree that documentation on Java toolchains is long due and should be prioritized."}}
{"actor":{"display_login":"iirina"}}