title: Android + coreLibraryDesugaring: which Java 11 APIs can I expect to work?
body: <p>I'm trying to migrate some Java library from 'normal' JVM to android and stuck with some Java11 APIs used in the code.</p>
  <p>The first thing I already got - Java11 language features seems to work only with Canary build of Android Studio, see answer <a href="https://stackoverflow.com/questions/66551892/android-sourcecompatibility-javaversion-version-11-error-package-android-os/66552352#66552352">here</a></p>
  <p>Now I need to get understanding about which APIs can be really used. Here are two use-cases which do not work for me and I can't get if I'm doing something wrong or it never should work:</p>
  <ol>
  <li><p><code>List.copyOf()</code> - introduced in Java11, method <code>copyOf</code> is not available on android. Methods 'List.of()', introduced with Java 9, work OK.</p>
  </li>
  <li><p>class <code>java.lang.invoke.LambdaMetafactory</code> - introduced with Java 1.8 - to be used for programmatic creation of lambdas for usage instead for reflection, is not visible on Android.</p>
  </li>
  </ol>
  <p>I see both of them in sources of <code>desugar_jdk_libs</code> here:</p>
  <ul>
  <li><a href="https://github.com/google/desugar_jdk_libs/blob/master/jdk11/src/java.base/share/classes/java/lang/invoke/LambdaMetafactory.java" rel="noreferrer">https://github.com/google/desugar_jdk_libs/blob/master/jdk11/src/java.base/share/classes/java/lang/invoke/LambdaMetafactory.java</a></li>
  <li><a href="https://github.com/google/desugar_jdk_libs/blob/master/src/share/classes/java/util/List.java" rel="noreferrer">https://github.com/google/desugar_jdk_libs/blob/master/src/share/classes/java/util/List.java</a></li>
  </ul>
  <p>So - the question is: how can I identify if some Java API is supposed to be available in 'desugared' android build or no? What really can be expected from <a href="https://medium.com/androiddevelopers/support-for-newer-java-language-apis-bca79fc8ef65" rel="noreferrer">'desugaring'</a>?</p>
  <p>Steps to reproduce:</p>
  <ol>
  <li>Using <a href="https://androidstudio.googleblog.com/2021/03/android-studio-arctic-fox-canary-9.html" rel="noreferrer">Android Studio Canary</a> generate a dummy &quot;Basic Activity&quot; project</li>
  <li>Make sure following is provided in <code>build.gradle</code></li>
  </ol>
  <pre><code>android {
      compileOptions {
          coreLibraryDesugaringEnabled true
          sourceCompatibility JavaVersion.VERSION_11
          targetCompatibility JavaVersion.VERSION_11
      }
  }
  dependencies {
      coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5'
  }
  </code></pre>
  <ol start="3">
  <li>Add following lines somewhere in code</li>
  </ol>
  <pre><code>        List&lt;Integer&gt; ints1 = List.of(1, 2, 3);
          Supplier&lt;List&lt;Object&gt;&gt; listSupplier = () -&gt; new ArrayList&lt;&gt;();
          List&lt;Object&gt; alist = listSupplier.get();
  
          List&lt;Integer&gt; ints2 = List.copyOf(ints1);
          LambdaMetafactory.metafactory(null,null,null,null,null,null);
  </code></pre>
  <p>Last 2 lines fail to compile for me.</p>
  <p>PS: final application is supposed to work on Android 10+.</p>