Status Update
Comments
sg...@google.com <sg...@google.com>
ma...@gmail.com <ma...@gmail.com> #2
Thank you for your patience while our engineering team worked to resolve this issue. A fix for this issue is now available in:
- Android Studio Ladybug Feature Drop | 2024.2.2 Canary 3
- Android Gradle Plugin 8.8.0-alpha03
We encourage you to try the latest update.
If you notice further issues or have questions, please file a new bug report.
Thank you for taking the time to submit feedback — we really appreciate it!
sg...@google.com <sg...@google.com> #3
I looked a bit at this today, and tried to add a few keep rules to narrow down where the issue happens. However, if I apply this diff:
diff --git a/libraries/apollo-gradle-plugin/rules.pro b/libraries/apollo-gradle-plugin/rules.pro
index 4b0867e580..af80c3ce44 100644
--- a/libraries/apollo-gradle-plugin/rules.pro
+++ b/libraries/apollo-gradle-plugin/rules.pro
@@ -45,3 +45,7 @@
# The Gradle API jar and other compileOnly dependencies aren't added to the classpath, ignore the missing symbols
-dontwarn **
+
+-keep class com.apollographql.apollo.ast.** {
+ *;
+}
the task :generateServiceApolloSources
starts failing throwing
java.lang.NoSuchMethodError: 'kotlin.jvm.internal.ClassReference kotlin.jvm.internal.Reflection.getOrCreateKotlinClass(java.lang.Class)'
You mentioned a pull request - does that mean that you have found the issue locally?
ma...@gmail.com <ma...@gmail.com> #4
the task :generateServiceApolloSources starts failing throwing
Right, I can also reproduce that. Not 100% sure what's happening there. I'll dig a bit.
You mentioned a pull request - does that mean that you have found the issue locally?
Kind of. I'm not 100% sure about the best way to fix it but I'm reliably confident this has to do invokedynamic
callsites.
This was some time ago so I'll need to refresh my memories but IIRC, it had to do with AffectedMethodUseRegistry
should implement registerCallSite()
and mark those as affected?
ma...@gmail.com <ma...@gmail.com> #5
java.lang.NoSuchMethodError: 'kotlin.jvm.internal.ClassReference kotlin.jvm.internal.Reflection.getOrCreateKotlinClass(java.lang.Class)'
I did a bit of digging around. I think what's happening here is that, for some reason, keeping com.apollographql.apollo.ast.**
disables relocation of kotlin.**
. Since this whole test is about testing kotlin.**
relocation, it fails bceause the Gradle embedded version of Kotlin takes over.
Interestingly enough, kotlin.**
is kept but there is some rewriting. In this case, getOrCreateKotlinClass
return type is changed from kotlin.reflect.KClass
to kotlin.jvm.internal.ClassReference
, which is what triggers the issue (but the real issue is that Gradle kotlin-stdlib
takes precedence bceuase kotlin.**
is not relocated).
I hope that makes sense? Let me know if you want me to dig into AffectedMethodUseRegistry
and I can try to suggest something.
sg...@google.com <sg...@google.com> #6
Thank you for the additional info and analysis of where this might go wrong.
Christoffer, can you take a look at the AffectedMethodUseRegistry
to check up on the analysis in
ch...@google.com <ch...@google.com> #7
Dump attached.
ch...@google.com <ch...@google.com> #8
Looking at the disassembly, it seems that most call sites have been rewritten correctly, but there is one call site that still seems to reference the old method name:
.class public final Lcom/apollographql/apollo/relocated/com/apollographql/apollo/ast/internal/Parser;
...
.method public final parseValue()Lcom/apollographql/apollo/relocated/com/apollographql/apollo/ast/GQLValue;
.locals 1
.line 1
invoke-custom {p0}, call_site_283("invoke", (Lcom/apollographql/apollo/relocated/com/apollographql/apollo/ast/internal/Parser;)Lcom/apollographql/apollo/relocated/kotlin/jvm/functions/Function0;, ()Ljava/lang/Object;, invoke-static@Lcom/apollographql/apollo/relocated/com/apollographql/apollo/ast/internal/Parser;->parseValue$lambda$1(Lcom/apollographql/apollo/relocated/com/apollographql/apollo/ast/internal/Parser;)Lcom/apollographql/apollo/relocated/com/apollographql/apollo/ast/GQLValue;, ()Lcom/apollographql/apollo/relocated/com/apollographql/apollo/ast/GQLValue;)@Ljava/lang/invoke/LambdaMetafactory;->metafactory(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite;
move-result-object v0
invoke-virtual {p0, v0}, Lcom/apollographql/apollo/relocated/com/apollographql/apollo/ast/internal/Parser;->parseTopLevel(Lcom/apollographql/apollo/relocated/kotlin/jvm/functions/Function0;)Ljava/lang/Object;
move-result-object p0
check-cast p0, Lcom/apollographql/apollo/relocated/com/apollographql/apollo/ast/GQLValue;
return-object p0
.end method
ch...@google.com <ch...@google.com> #9
From looking at this in more details, I agree that AffectedMethodUseRegistry
needs to account for call sites. In the concrete build this would not fix the issue, however, since the affected method java.util.ArrayList com.apollographql.apollo.ast.internal.Parser.parseDirectives(boolean)
is already marked for reprocessing. The (other) issue is that LensCodeRewriter#rewritePartialDefault
does not rewrite the method names in call sites that correspond to lambdas.
ma...@gmail.com <ma...@gmail.com> #10
Hi 👋 Thanks for looking into this 🙏.
I have a very limited understanding of the inner details here. I don't have much to add but thought I'd drop by to say I'm still around. Let me know if/how I can help.
This issue currently forces us on a very ancient version of R8 and I'd feel much better if we could update.
ch...@google.com <ch...@google.com> #11
Fixing this should be rather straight-forward. I expect to be able to look into this tomorrow.
ma...@gmail.com <ma...@gmail.com> #12
Excellent news, thanks! 💙
ch...@google.com <ch...@google.com>
ap...@google.com <ap...@google.com> #13
Project: r8
Branch: 8.6
Author: Christoffer Adamsen <
Link:
Version 8.6.35
Expand for full commit details
Version 8.6.35
Bug: b/366932318
Change-Id: I8e18fd6469749d4e3bb478415d370a157f3a6aeb
Files:
- M
src/main/java/com/android/tools/r8/Version.java
Hash: 8eee0f0fceb7e2a40be3d0f4a5290881aa262ae3
Date: Wed Nov 20 10:38:52 2024
ap...@google.com <ap...@google.com> #14
Project: r8
Branch: 8.6
Author: Christoffer Adamsen <
Link:
Pin methods called from lambdas in argument propagation
Expand for full commit details
Pin methods called from lambdas in argument propagation
Bug: b/366932318
Change-Id: Ie3888ec6788637b897ecdde1027bb1b9aef99305
Files:
- M
src/main/java/com/android/tools/r8/optimize/argumentpropagation/ArgumentPropagatorProgramOptimizer.java
Hash: d24b82662e766abcbaeebc4002f66eee18526993
Date: Wed Nov 20 10:38:46 2024
ap...@google.com <ap...@google.com> #15
Project: r8
Branch: 8.7
Author: Christoffer Adamsen <
Link:
Pin methods called from lambdas in argument propagation
Expand for full commit details
Pin methods called from lambdas in argument propagation
Bug: b/366932318
Change-Id: Ie3888ec6788637b897ecdde1027bb1b9aef99305
Files:
- M
src/main/java/com/android/tools/r8/optimize/argumentpropagation/ArgumentPropagatorProgramOptimizer.java
Hash: fd2cff0120d88a4275e5e9a3812bb017cdcae533
Date: Wed Nov 20 10:38:49 2024
ap...@google.com <ap...@google.com> #16
Project: r8
Branch: 8.7
Author: Christoffer Adamsen <
Link:
Version 8.7.22
Expand for full commit details
Version 8.7.22
Bug: b/366932318
Change-Id: I1236e2692269bc0159f4cbf1070de19eb3784fee
Files:
- M
src/main/java/com/android/tools/r8/Version.java
Hash: 582ed883e44e204b76b9ecc4c9e6a8b570d6bb04
Date: Wed Nov 20 10:38:54 2024
ap...@google.com <ap...@google.com> #17
Project: r8
Branch: 8.8
Author: Christoffer Adamsen <
Link:
Pin methods called from lambdas in argument propagation
Expand for full commit details
Pin methods called from lambdas in argument propagation
Bug: b/366932318
Change-Id: Ie3888ec6788637b897ecdde1027bb1b9aef99305
Files:
- M
src/main/java/com/android/tools/r8/optimize/argumentpropagation/ArgumentPropagatorProgramOptimizer.java
Hash: cee68977713ba669f9099a8fb2412ad87afae93b
Date: Wed Nov 20 10:38:52 2024
ap...@google.com <ap...@google.com> #18
Project: r8
Branch: 8.8
Author: Christoffer Adamsen <
Link:
Version 8.8.19
Expand for full commit details
Version 8.8.19
Bug: b/366932318
Change-Id: I11fdec29da7b98ed3b822661231cd729b9276c83
Files:
- M
src/main/java/com/android/tools/r8/Version.java
Hash: 4650e0dbf088a5560f84d7a76b655757ebf85fa2
Date: Wed Nov 20 10:38:58 2024
ap...@google.com <ap...@google.com> #19
Project: r8
Branch: 8.6
Author: Christoffer Adamsen <
Link:
Pin methods called from lambdas in argument propagation
Expand for full commit details
Pin methods called from lambdas in argument propagation
Bug: b/366932318
Change-Id: Ie3888ec6788637b897ecdde1027bb1b9aef99305
Files:
- M
src/main/java/com/android/tools/r8/optimize/argumentpropagation/ArgumentPropagatorProgramOptimizer.java
Hash: d24b82662e766abcbaeebc4002f66eee18526993
Date: Wed Nov 20 10:38:46 2024
ap...@google.com <ap...@google.com> #20
Project: r8
Branch: 8.7
Author: Christoffer Adamsen <
Link:
Pin methods called from lambdas in argument propagation
Expand for full commit details
Pin methods called from lambdas in argument propagation
Bug: b/366932318
Change-Id: Ie3888ec6788637b897ecdde1027bb1b9aef99305
Files:
- M
src/main/java/com/android/tools/r8/optimize/argumentpropagation/ArgumentPropagatorProgramOptimizer.java
Hash: fd2cff0120d88a4275e5e9a3812bb017cdcae533
Date: Wed Nov 20 10:38:49 2024
ap...@google.com <ap...@google.com> #21
Project: r8
Branch: 8.5
Author: Christoffer Adamsen <
Link:
Pin methods called from lambdas in argument propagation
Expand for full commit details
Pin methods called from lambdas in argument propagation
Bug: b/366932318
Change-Id: Ie3888ec6788637b897ecdde1027bb1b9aef99305
Files:
- M
src/main/java/com/android/tools/r8/optimize/argumentpropagation/ArgumentPropagatorProgramOptimizer.java
Hash: f53bfc6bcde5ec53fa9489b9b77103ebe253bdc8
Date: Wed Nov 20 10:38:57 2024
ap...@google.com <ap...@google.com> #22
Project: r8
Branch: 8.5
Author: Christoffer Adamsen <
Link:
Version 8.5.47
Expand for full commit details
Version 8.5.47
Bug: b/366932318
Change-Id: Ib3884dfe3fcf4796a4c0c549e2fd2eaca21e8d8d
Files:
- M
src/main/java/com/android/tools/r8/Version.java
Hash: 4a9267032bd00ee006aabc896a002ab998b40835
Date: Wed Nov 20 10:39:03 2024
ma...@gmail.com <ma...@gmail.com> #23
Hi 👋
I finally had the time to test the fix using r8:8.8.19
but sadly it doesn't seem to fix my issue. I just rebased the use-r8
branch:
git clone https://github.com/apollographql/apollo-kotlin
cd apollo-kotlin
git checkout 6980cf48a4600b06042054d9e6bbf8f013e5e68d
./gradlew :apollo-gradle-plugin:testJava11 --rerun --tests '*operationIdGenerator is working*' --no-build-cache --no-configuration-cache
Still outputs the same:
Caused by: java.lang.AbstractMethodError: Receiver class com.apollographql.apollo.relocated.com.apollographql.apollo.ast.internal.Parser$$Lambda$1679/0x0000000800d5fc40 does not define or inherit an implementation of the resolved method 'abstract java.lang.Object invoke$3()' of interface com.apollographql.apollo.relocated.kotlin.jvm.functions.Function0.
at com.apollographql.apollo.relocated.com.apollographql.apollo.ast.internal.Parser.parseTopLevel(SourceFile:4)
at com.apollographql.apollo.relocated.com.apollographql.apollo.ast.internal.Parser.parseValue(SourceFile:1)
at com.apollographql.apollo.relocated.com.apollographql.apollo.ast.ApolloParser__ApiKt.parseAsGQLValue$lambda$7$ApolloParser__ApiKt(SourceFile:1)
Is there something I'm missing?
ma...@apollographql.com <ma...@apollographql.com> #24
Woops, bad commit, 8881b5481db7a66abcdabba7571fc7b72b3cf2dd
is the commit to use:
git clone https://github.com/apollographql/apollo-kotlin
cd apollo-kotlin
git checkout 8881b5481db7a66abcdabba7571fc7b72b3cf2dd
./gradlew :apollo-gradle-plugin:testJava11 --rerun --tests '*operationIdGenerator is working*' --no-build-cache --no-configuration-cache
ch...@google.com <ch...@google.com>
ap...@google.com <ap...@google.com> #25
Project: r8
Branch: main
Author: Christoffer Adamsen <
Link:
Account for lambda call sites in argument propagation
Expand for full commit details
Account for lambda call sites in argument propagation
Bug: b/366932318
Change-Id: I7d6378034d4bf7e607badbe266653e273fdcd14a
Files:
- M
src/main/java/com/android/tools/r8/ir/desugar/LambdaDescriptor.java
- M
src/main/java/com/android/tools/r8/optimize/argumentpropagation/ArgumentPropagatorMethodReprocessingEnqueuer.java
- M
src/main/java/com/android/tools/r8/optimize/argumentpropagation/ArgumentPropagatorProgramOptimizer.java
Hash: 887704078a06fc0090e7772c921a30602bf1a49f
Date: Wed Nov 20 06:09:06 2024
ch...@google.com <ch...@google.com> #26
Sorry about that. This should be fixed by
Can you check if the main version fixes your issue (jar is at
Running tests seems to work for me:
> Task :apollo-gradle-plugin:testJava11
OperationIdGeneratorTests > operationIdGenerator is working PASSED
ma...@gmail.com <ma...@gmail.com> #27
Works like a charm, thanks again!
ap...@google.com <ap...@google.com> #28
Project: r8
Branch: 8.5
Author: Christoffer Adamsen <
Link:
Version 8.5.48
Expand for full commit details
Version 8.5.48
Bug: b/366932318
Change-Id: Iddbe33a40bee481c66e67030690c704d69ce35b3
Files:
- M
src/main/java/com/android/tools/r8/Version.java
Hash: 06bef98a52ed82a92587f70f74de6e3ea4a660f1
Date: Mon Nov 25 20:21:04 2024
ap...@google.com <ap...@google.com> #29
Project: r8
Branch: 8.5
Author: Christoffer Adamsen <
Link:
Account for lambda call sites in argument propagation
Expand for full commit details
Account for lambda call sites in argument propagation
Bug: b/366932318
Change-Id: I7d6378034d4bf7e607badbe266653e273fdcd14a
Files:
- M
src/main/java/com/android/tools/r8/ir/desugar/LambdaDescriptor.java
- M
src/main/java/com/android/tools/r8/optimize/argumentpropagation/ArgumentPropagatorMethodReprocessingEnqueuer.java
- M
src/main/java/com/android/tools/r8/optimize/argumentpropagation/ArgumentPropagatorProgramOptimizer.java
Hash: 1f01e4cba3e840b5ba0647f53906b8f27ed477ac
Date: Mon Nov 25 20:20:58 2024
an...@google.com <an...@google.com> #30
Thank you for your patience while our engineering team worked to resolve this issue. A fix for this issue is now available in:
- Android Studio Ladybug Feature Drop | 2024.2.2 Patch 1
- Android Gradle Plugin 8.8.1
We encourage you to try the latest update.
If you notice further issues or have questions, please file a new bug report.
Thank you for taking the time to submit feedback — we really appreciate it!
Description
Hi!
I've just bumped into another edge case trying to relocate the Apollo Gradle Plugin jar with a recent version of R8.
Looks like some
invokedynamic
calls are not always rename.Sadly I haven't found a way to make a minimal reproducer but for the full reproducer, you can always try with this commit:https://github.com/apollographql/apollo-kotlin/commit/4aa521df0037eea13ba09b5dfe4a3c2746b28023
My understanding is that
kotlin.jvm.functions.Function0
was repackaged (so far so good) but also had its single abstract method renamed frominvoke
toinvoke$3
(this is the part I'm not sure how to reproduce without the full example). And the renaming was not taken into account in theinvokedynamic
callsite, leading to the exception above.Debugging has led me to ArgumentPropagatorMethodReprocessingEnqueuer.AffectedMethodUseRegistry , used to rewrite code after the argument propagation optimization has run.
I'm tempted to say
AffectedMethodUseRegistry
would need to implementregisterCallSite()
and callmarkAffected()
somewhere in there to rewrite the methods that contain callsites? Does that make any sense?