Status Update
Comments
sg...@google.com <sg...@google.com>
sg...@google.com <sg...@google.com> #2
This is working as intended. When --no-desugaring
is used R8 will not do any desugaring, also no invokedynamic
desugaring of invokedynamic
with known bootstrap methods. When this desugaring does not happen the invokedynamic
will be translated directly to invoke-custom
. As ART has no implementation of any of the common JVM bootstrap methods you will see the BootstrapMethodError
at runtime. The code above will end up having the following two invoke-custom
instructions:
invoke-custom {}, call_site_0("apply", ()Ljava/util/function/BinaryOperator;, (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;, invoke-static@Ljava/lang/Integer;->sum(II)I, (Ljava/lang/Integer;Ljava/lang/Integer;)Ljava/lang/Integer;)@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;
invoke-custom {p0}, call_site_1("makeConcatWithConstants", (I)Ljava/lang/String;, "c = \u0001")@Ljava/lang/invoke/StringConcatFactory;->makeConcatWithConstants(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/invoke/CallSite;
The first for the Integer::sum
lambda and the second for "c = " + c
.
The use of --no-desugaring
is to support code which has already been desugared and therefore desugaring is not needed. Currently the bazel
integration use this, as there desugaring happens separately producing class file output first.
With your example it will look like this:
java -cp r8.jar com.android.tools.r8.D8 --classfile --release --output output.jar ./classes.jar
java -cp r8.jar com.android.tools.r8.R8 --no-desugaring --pg-conf rules.pro --min-api 26 --release --output ./ ./output.jar
env ANDROID_LOG_TAGS=*:f ANDROID_DATA=./ path-to-art/art --64 --no-compile -cp ./classes.dex Test
You will get the warning Type
java.util.function.BinaryOperator was not found...
, which can be silenced by passing an android.jar
with the --lib
.
qi...@gmail.com <qi...@gmail.com> #3
Thank you for your explanation.
Description
Versions
Description
We are uncertain whether this is an issue with R8 or a misunderstanding of the
--no-desugaring
option. What we observed is that when running the class file directly with Java, the program outputs "c=0" correctly. However, when we first process the program with R8, using the--min-api 26
--no-desugaring
options, running the generated DEX file results in a java.lang.BootstrapMethodError. We believe this may not be related to desugaring, as the result when only using the--no-desugaring
option is java.lang.RuntimeException: Instruction is unrepresentable in DEX V35: invoke-dynamic. Could you please confirm if this is an issue?Step to Reproduce
Expected Result
Actual Result
Testcase Source Code
rules.pro