Skip to content
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

Upgrade of JDK11 to >11.0.9.1 breaks android desugarer #12880

Closed
comius opened this issue Jan 22, 2021 · 4 comments · Fixed by sakibguy/bazel#7
Closed

Upgrade of JDK11 to >11.0.9.1 breaks android desugarer #12880

comius opened this issue Jan 22, 2021 · 4 comments · Fixed by sakibguy/bazel#7
Assignees
Labels
P2 We'll consider working on this in future. (Assignee optional) team-Android Issues for Android team type: bug

Comments

@comius
Copy link
Contributor

comius commented Jan 22, 2021

Description of the problem / feature request:

Upgrade of JDK11 to version 11.0.9.1, 11.0.10 breaks Android desugarer. (Versions up to 11.0.9 work)
Problem is in Desugar.java#L108,
which attempts to set system property jdk.internal.lambda.dumpProxyClasses in static initializer before it is read by java.lang.invoke.InnerClassLambdaMetafactory static initializer. The latter initializer is invoked first.

Target //src/test/java/com/google/devtools/build/android/desugar:desugar_testdata fails to build, with exception:

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.google.devtools.build.android.desugar.Desugar (file:/usr/local/google/home/ilist/.cache/bazel/_bazel_ilist/e9eba874c4fa4205502c6d2768696dfb/execroot/io_bazel/bazel-out/host/bin/src/tools/android/java/com/google/devtools/build/android/desugar/libdesugar.jar) to field java.lang.invoke.InnerClassLambdaMetafactory.dumper
WARNING: Please consider reporting this to the maintainers of com.google.devtools.build.android.desugar.Desugar
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
Exception in thread "main" java.lang.NullPointerException: Failed to register lambda dump directory '/tmp/lambdas17634769287980916750'

While tests

  • //src/test/java/com/google/devtools/build/android/desugar:DesugarMainClassTestLambdaDirectoryCorrectlySet, and
  • //src/test/java/com/google/devtools/build/android/desugar:DesugarMainClassTestLambdaDirectoryIncorrectlySet

continue to work (because property is set using jvm_opts).

Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

Checkout https://github.com/comius/bazel/tree/bazel_issue_12880
and run bazel test //src/test/java/com/google/devtools/build/android/desugar:desugar_testdata

What operating system are you running Bazel on?

Linux

What's the output of bazel info release?

Bazel@a181dd4

Related issue #12512

@comius comius changed the title Upgrade of JDK11 to >11.0.6 breaks android desugarer Upgrade of JDK11 to >11.0.9.1 breaks android desugarer Jan 22, 2021
@comius
Copy link
Contributor Author

comius commented Jan 22, 2021

cc @cushon, @dx404

@comius
Copy link
Contributor Author

comius commented Aug 23, 2021

This is blocking JDK upgrade, which is required by some organisations.

Bazel 4.1.0 comes with JDK 11.0.6 which has known security vulnerabilities. Our organization requires that we stay up to date with dependencies that have CVEs, and JDK 11.0.6 is flagged as prohibted.

@cushon
Copy link
Contributor

cushon commented Aug 23, 2021

Failed to register lambda dump directory '/tmp/lambdas17634769287980916750'

This was fixed internally in cl/164671681, which added a sh_binary wrapper around desugar to set the property:

# A wrapper around the desugar binary that sets
# jdk.internal.lambda.dumpProxyClasses.

# exit on errors and uninitialized variables
set -eu

readonly TMPDIR="$(mktemp -d)"
trap "rm -rf ${TMPDIR}" EXIT
"${0}.runfiles/bazel/src/tools/android/java/com/google/devtools/build/android/desugar/Desugar_java" \
  "--jvm_flag=-Djdk.internal.lambda.dumpProxyClasses=${TMPDIR}" "$@"

@comius
Copy link
Contributor Author

comius commented Aug 23, 2021

Thanks @cushon, I'll take a look if I can do the same in Bazel and upgrade the JDK.

@comius comius self-assigned this Oct 4, 2021
bazel-io pushed a commit that referenced this issue Oct 9, 2021
…at sets jdk.internal.lambda.dumpProxyClasses

In JDK11 >11.0.9.1, the platform uses lambdas early enough that the LambdaMetaFactory
class gets loaded by desugar's main is reached, so it doesn't get a chance
to set the dump directory.

The wrapper script let's us upgrade JDK version.

Fixes #12880

PiperOrigin-RevId: 401933663
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P2 We'll consider working on this in future. (Assignee optional) team-Android Issues for Android team type: bug
Projects
None yet
4 participants