-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Desugaring a method reference implicitly requires Java 7 APIs (Android API 19+). #2522
Comments
You should be able to avoid this by including -XDallowBetterNullChecks=false into the javacopts, either using bazel's --javacopts command line flag or your android_library target's javacopts attribute. could you give that a try please? we'll look into a fix that's more turnkey. |
Thanks for the detailed report! Some more background, (as provided by @kevin1e100), the bazel android desugarer is not actually writing out Objects.requireNonNull, but javac9 is synthetically adding it (see https://bugs.openjdk.java.net/browse/JDK-8074306). Bazel bundles javac9 in https://github.com/bazelbuild/bazel/blob/master/third_party/java/jdk/langtools, which is being used with javacopts -source 8 -target 8 if you use |
A quick try of that flag didn't seem to affect the output. And thanks for the info around the compiler. I should have known because the error-prone issue has been getting some activity of late as well. |
The allowBetterNullChecks flag that @kevin1e100 mentioned is a fork that is not in Bazel's javac and is not in the javac we have at https://github.com/bazelbuild/bazel/blob/master/third_party/java/jdk/langtools. One solution would be to have the desugaring tool remove this methods. @kevin1e100 do you think its worth patching Bazel's javac in the mean time to add that flag? |
Err sorry about that. I'll see how we can work around this, stay tuned |
I think we need this even with the javac patch; we're going to want it to work with stock JDK 9's eventually.
I'm on it. |
Support for |
b35a0c0 updated the desugarer to desugar calls to |
Description of the problem / feature request / question:
When desugaring a method reference for Android, the lambda meta factory emits a call to
Objects.requireNonNull
before passing the captured instance to the generated class. This method was added in Java 7 which is Android API 19+ only.I'm not sure what API level you're supporting with this feature, but all other emitted bytecode is certainly Java 6 compatible which would give you Android API 9+.
If possible, provide a minimal example to reproduce the problem:
Environment info
bazel info release
): master @ 89512a7Anything else, information or logs or outputs that would be helpful?
Here's the bytecode output after desugaring:
The text was updated successfully, but these errors were encountered: