title: Is it possible to compile Java11 code to Java8 bytecode and run on 8?
body: <p>I'm playing with some dependencies and compilation to older releases using java 11. I migrated one dependency to Java 11 and works fine, but we still have to run it Tomcat 7 or 8 on Java8. Is it possible to use the <code>--release</code> flag to compile code which uses <code>var</code>, <code>stream().dropwhile(...)</code> or <code>Map.of(...)</code> and run on 8?</p>
  
  <p>Release flag suggest that it should be possible:</p>
  
  <blockquote>
    <p>--release release Compiles against the public, supported and documented API for a specific VM version. Supported release targets
    are 6, 7, 8, and 9.</p>
  </blockquote>
  
  <p>This project is a dependency, stand-alone works fine with SprinBoot2.1 and Java11, but needs to be run in Java8.</p>
  
  <p>My maven plugin compiler settings:</p>
  
  <pre><code>&lt;plugin&gt;
      &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
      &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
      &lt;version&gt;3.8.0&lt;/version&gt;
      &lt;configuration&gt;
          &lt;release&gt;8&lt;/release&gt;
      &lt;/configuration&gt;
  &lt;/plugin&gt;
  </code></pre>
  
  <p>but this forbids compiling >jdk8 specific code. I'm using latest maven 3.6.0 and mvn compiler as above.</p>
  
  <p>Attempt to compile:</p>
  
  <pre><code>return List.of("dsadas", "dasdadddds", "£dsada", "dasdas")
          .stream()
          .dropWhile(s -&gt; s.contains("das"))
          .collect(Collectors.toList());
  </code></pre>
  
  <p>throws error:</p>
  
  <pre><code>[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) on project api: Compilation failure: Compilation failure: 
  [ERROR] /home/agilob/Projects/.....java:[58,13] cannot find symbol
  [ERROR]   symbol:   class var
  [ERROR]   location: 
  [ERROR] /home/agilob/Projects/....java:[43,20] cannot find symbol
  [ERROR]   symbol:   method of(java.lang.String,java.lang.String,java.lang.String,java.lang.String)
  [ERROR]   location: interface java.util.List
  [ERROR] -&gt; [Help 1]
  </code></pre>