title: Release version 11 not supported while using Gradle on MacOS with AdoptOpenJDK 11
body: <p>When running gradle build (that works for other developers in my team) I'm getting:</p>
  <pre><code>Execution failed for task ':compileJava'.
  &gt; error: release version 11 not supported
  </code></pre>
  <p>This is with installation of AdoptOpenJDK11 on MacOS.</p>
  <pre><code>java -version
  openjdk version &quot;11.0.11&quot; 2021-04-20
  OpenJDK Runtime Environment AdoptOpenJDK-11.0.11+9 (build 11.0.11+9)
  OpenJDK 64-Bit Server VM AdoptOpenJDK-11.0.11+9 (build 11.0.11+9, mixed mode)
  </code></pre>
  <pre><code> ./gradlew -version                    
  
  ------------------------------------------------------------
  Gradle 6.8.2
  ------------------------------------------------------------
  
  Build time:   2021-02-05 12:53:00 UTC
  Revision:     b9bd4a5c6026ac52f690eaf2829ee26563cad426
  
  Kotlin:       1.4.20
  Groovy:       2.5.12
  Ant:          Apache Ant(TM) version 1.10.9 compiled on September 27 2020
  JVM:          11.0.11 (AdoptOpenJDK 11.0.11+9)
  OS:           Mac OS X 10.14.6 x86_64
  
  </code></pre>
  <pre><code>echo $JAVA_HOME
  /Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home
  </code></pre>
  <p>Relevant part of <code>build.grade</code></p>
  <pre><code>...
  java {
      toolchain {
          languageVersion.set(JavaLanguageVersion.of(11))
      }
  }
  ...
  </code></pre>
  <pre><code>gradle -q javaToolchains
  executing gradlew instead of gradle
  
   + Options
       | Auto-detection:     Enabled
       | Auto-download:      Enabled
  
   + AdoptOpenJDK 11.0.11
       | Location:           /Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home
       | Language Version:   11
       | Vendor:             AdoptOpenJDK
       | Is JDK:             true
       | Detected by:        Current JVM
  </code></pre>
  <p>It seems that java toolchain feature of gradle is causing issues.</p>
  <ul>
  <li>If the java toolchains block is completely removed, project builds fine using current JVM.</li>
  <li>If java toolchains is set to use java 12, gradle will download jdk12 and again it builds fine.</li>
  <li>Running javac from existing JDK11 via command line to compile a dummy hello world file also works fine (e.g. <code>/Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home/bin/javac --release 11 HelloWorld.java</code>)</li>
  </ul>
  <p>I suspect reinstalling JDK would solve this but I would really appreciate any clues on how to debug this further and understand why it is happening.</p>
  <p><strong>UPDATE</strong></p>
  <p>After attempting several debugging steps, build now works, for reasons unknown to me. Unfortunately I do not know why it didn't work initially and can't reproduce the issues again to debug further. For future reference to people who may encounter this issue, here are some of the steps I did in the debugging process. One of these apparently fixed the issue, though I don't know how:</p>
  <ul>
  <li>Removed java toolchains section and trying build that way, then adding back the java toolchains section</li>
  <li>Trying the build setting java toolchains to use java 12 (this resulted in automatic provisioning of jdk12 by gradle)</li>
  <li>Running <code>gradle -q javaToolchains</code></li>
  <li>Removing jdk12 (that was automatically provisioned by gradle) from <code>~/.gradle/jdks</code></li>
  </ul>