Hello,
I am running into a redex error when enabling SingleImplPass as part of the redex config. Any ideas what is happening?
WARNING: Unable to find RequiresApi annotation. It's either unused (okay) or been deleted (not okay)
terminate called after throwing an instance of 'RedexException'
what(): opt/singleimpl/SingleImplOptimize.cpp:370: void OptimizationImpl::rewrite_annotations(Scope&, const SingleImplConfig&): assertion `method_value->method()->is_def()' failed.
Found methodref Lcom/dxo/scan/ui/Unlockables$observeCLCards$2$1$1;.apply:(Ljava/util/List;)Lcom/dxo/scan/cards/models/ScanCCLItemViewModel; in annotation of class Laeee;, this is not supported by SingleImplPass.
/home/gydeveloper/redex_workspace_fb/redex/redex-all[0xbd03d8]
/home/gydeveloper/redex_workspace_fb/redex/redex-all(_Z23crash_backtrace_handleri+0x8)[0xbd0418]
/lib/x86_64-linux-gnu/libc.so.6(+0x354b0)[0x7f7739e8c4b0]
/lib/x86_64-linux-gnu/libc.so.6(gsignal+0x38)[0x7f7739e8c428]
/lib/x86_64-linux-gnu/libc.so.6(abort+0x16a)[0x7f7739e8e02a]
/usr/lib/x86_64-linux-gnu/libstdc++.so.6(_ZN9__gnu_cxx27__verbose_terminate_handlerEv+0x16d)[0x7f773a7cf84d]
/usr/lib/x86_64-linux-gnu/libstdc++.so.6(+0x8d6b6)[0x7f773a7cd6b6]
/usr/lib/x86_64-linux-gnu/libstdc++.so.6(+0x8d701)[0x7f773a7cd701]
/usr/lib/x86_64-linux-gnu/libstdc++.so.6(+0x8d919)[0x7f773a7cd919]
/home/gydeveloper/redex_workspace_fb/redex/redex-all(_Z11assert_failPKcS0_jS0_10RedexErrorS0_z+0x15c)[0xbd07bc]
/home/gydeveloper/redex_workspace_fb/redex/redex-all(_ZN16OptimizationImpl19rewrite_annotationsERSt6vectorIP8DexClassSaIS2_EERK16SingleImplConfig+0x2bf)[0xa2937f]
/home/gydeveloper/redex_workspace_fb/redex/redex-all(_ZN16OptimizationImpl8optimizeERSt6vectorIP8DexClassSaIS2_EERK16SingleImplConfig+0x416)[0xa2ee36]
/home/gydeveloper/redex_workspace_fb/redex/redex-all(_Z8optimizeSt10unique_ptrI18SingleImplAnalysisSt14default_deleteIS0_EERKSt13unordered_mapIPK7DexTypeSt3setIS7_19dextypes_comparatorSaIS7_EESt4hashIS7_ESt8equal_toIS7_ESaISt4pairIKS7_SB_EEERSt6vectorIP8DexClassSaISP_EERK16SingleImplConfig+0xbe)[0xa2f57e]
/home/gydeveloper/redex_workspace_fb/redex/redex-all(_ZN14SingleImplPass8run_passERSt6vectorI8DexStoreSaIS1_EER11ConfigFilesR11PassManager+0x916)[0xa1d586]
/home/gydeveloper/redex_workspace_fb/redex/redex-all(_ZN11PassManager10run_passesERSt6vectorI8DexStoreSaIS1_EER11ConfigFiles+0xb07)[0xc88687]
/home/gydeveloper/redex_workspace_fb/redex/redex-all(main+0x19e9)[0x761409]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0)[0x7f7739e77830]
/home/gydeveloper/redex_workspace_fb/redex/redex-all(_start+0x29)[0x767939]
Traceback (most recent call last):
File "./redex.py", line 785, in <module>
run_redex(args)
File "./redex.py", line 762, in run_redex
run_redex_binary(state)
File "./redex.py", line 224, in run_redex_binary
'by running %(lldb_script_name)s') % script_filenames)
RuntimeError: redex-all crashed with exit code -6! You can re-run it under gdb by running /tmp/redex-gdb-k9cbj0.sh or under lldb by running /tmp/redex-lldb-B1pNld.sh
ScanCCLItemViewModel class is a kotlin sealed class. The apk is proguarded before redex, and a proguard mapping file is supplied as part of the redex config. This is the corresponding snippet in the mapping.txt:
com.dxo.scan.ui.Unlockables$observeCLCards$2$1$1$1 -> aeee:
com.dxo.scan.ui.Unlockables$observeCLCards$2$1$1$1 INSTANCE -> xod
java.lang.Object invoke(java.lang.Object) -> invoke
void <init>() -> <init>
void <clinit>() -> <clinit>
Here's the bytecode-
.class final Laeee;
.super Larix;
# interfaces
.implements Larhq;
# annotations
.annotation system Ldalvik/annotation/EnclosingMethod;
value = Lcom/dxo/scan/ui/Unlockables$observeCLCards$2$1$1;->apply(Ljava/util/List;)Lcom/dxo/scan/cards/models/ScanCCLItemViewModel;
.end annotation
.annotation system Ldalvik/annotation/InnerClass;
accessFlags = 0x18
name = null
.end annotation
.annotation system Ldalvik/annotation/Signature;
value = {
"Larix;",
"Larhq<",
"Laiow;",
"Ljava/lang/String;",
">;"
}
.end annotation
# static fields
.field public static final xod:Laeee;
# direct methods
.method static constructor <clinit>()V
.locals 1
new-instance v0, Laeee;
invoke-direct {v0}, Laeee;-><init>()V
sput-object v0, Laeee;->xod:Laeee;
return-void
.end method
.method constructor <init>()V
.locals 1
const/4 v0, 0x1
invoke-direct {p0, v0}, Larix;-><init>(I)V
return-void
.end method
# virtual methods
.method public final bridge synthetic invoke(Ljava/lang/Object;)Ljava/lang/Object;
.locals 0
check-cast p1, Laiow;
iget-object p1, p1, Laiow;->AtL:Lansj;
iget-object p1, p1, Lansj;->gYD:Ljava/lang/String;
return-object p1
.end method
Sorry we've missed this. Thanks for the detailed error report. It seems we don't support that case (method ref as annotation) and was updated fairly recently. You can work around this for now by blacklisting that interface or class. Will look into it or provide better feedback for the fix.
This should be fixed now. Feel free to reopen if you see that that is not the case. Thank you
Thanks for the update! Is there an example of how I can blacklist?
In your Redex Config (which is a json file), add this
"SingleImplPass": {
"black_list" : [
"Lcom/foo/SomeInterface;",
"Lcom/foo/SomeOtherInterface;"
],
"package_black_list" : [
"Lcom/some/package/bar"
]
}
Thanks!