Skip to content

Commit

Permalink
Do not generating singletons for stateless lambdas when desugaring fo…
Browse files Browse the repository at this point in the history
…r Android

RELNOTE: Stateless lambdas are no longer desugared as singletons when building for Android, see https://issuetracker.google.com/222081665.
PiperOrigin-RevId: 625603411
Change-Id: Ie5fcfb9b04f5229cea5ebd940892900b5d2dd180
  • Loading branch information
sgjesse authored and copybara-github committed Apr 17, 2024
1 parent a10a169 commit 8c28023
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,15 @@ function generate_java_file_with_many_synthetic_classes() {
echo " () -> $i,"
done

echo " };"
echo " }"
echo " public IntSupplier[] bar() {"
echo " return new IntSupplier[] {"

for ((i = 0; i < $lambda_count; i++ )) do
echo " () -> $i,"
done

echo " };"
echo " }"
echo " }"
Expand Down Expand Up @@ -169,8 +178,8 @@ function test_DexMapper_synthetic_classes_crossing_dexfiles() {
bazel build java/com/testapp || fail "Test app should have built succesfully"

dex_file_count=$(unzip -l bazel-bin/java/com/testapp/testapp.apk | grep "classes[0-9]*.dex" | wc -l)
if [[ ! "$dex_file_count" -eq "5" ]]; then
echo "Expected 5 dexes in app, found: $dex_file_count"
if [[ ! "$dex_file_count" -eq "4" ]]; then
echo "Expected 4 dexes in app, found: $dex_file_count"
exit 1
fi
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ java_binary(
"-Dcom.android.tools.r8.allowAllDesugaredInput",
"-Dcom.android.tools.r8.noCfMarkerForDesugaredCode",
"-Dcom.android.tools.r8.lambdaClassFieldsNotFinal",
"-Dcom.android.tools.r8.createSingletonsForStatelessLambdas",
],
main_class = "com.google.devtools.build.android.r8.Desugar",
visibility = ["//src/test/java/com/google/devtools/build/android/r8:__pkg__"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ java_binary(
"-Dcom.android.tools.r8.allowAllDesugaredInput",
"-Dcom.android.tools.r8.noCfMarkerForDesugaredCode",
"-Dcom.android.tools.r8.lambdaClassFieldsNotFinal",
"-Dcom.android.tools.r8.createSingletonsForStatelessLambdas",
],
main_class = "com.google.devtools.build.android.r8.Desugar",
visibility = ["//visibility:public"],
Expand Down

0 comments on commit 8c28023

Please sign in to comment.