This is no issue at runtime as this is not needed and the generic type of anything implementing the interface is still kept.
e.g.
###### Class com.airbnb.deeplinkdispatch.sample.handler.SampleKotlinDeepLinkHandler (com.airbnb.deeplinkdispatch.sample.handler.SampleKotlinDeepLinkHandler)
.class public final Lcom/airbnb/deeplinkdispatch/sample/handler/SampleKotlinDeepLinkHandler;
.super Lcom/airbnb/deeplinkdispatch/sample/handler/IntermediateDeepLinkHandler1;
# annotations
.annotation runtime Lcom/airbnb/deeplinkdispatch/sample/WebDeepLink;
.end annotation
.annotation system Ldalvik/annotation/Signature;
value = {
"Lcom/airbnb/deeplinkdispatch/sample/handler/IntermediateDeepLinkHandler1<",
"Lcom/airbnb/deeplinkdispatch/sample/handler/TestKotlinDeepLinkHandlerDeepLinkArgs;",
">;"
}
.end annotation
but the type is fully erased if it is just Any e.g.
###### Class com.airbnb.deeplinkdispatch.sample.handler.SampleNoParamsKotlinDeepLinkHandler (com.airbnb.deeplinkdispatch.sample.handler.SampleNoParamsKotlinDeepLinkHandler)
.class public final Lcom/airbnb/deeplinkdispatch/sample/handler/SampleNoParamsKotlinDeepLinkHandler;
.super Ljava/lang/Object;
# interfaces
.implements Lcom/airbnb/deeplinkdispatch/handler/DeepLinkHandler;
# annotations
.annotation runtime Lcom/airbnb/deeplinkdispatch/sample/WebDeepLink;
.end annotation
.annotation system Ldalvik/annotation/Signature;
value = {
"Ljava/lang/Object;",
"Lcom/airbnb/deeplinkdispatch/handler/DeepLinkHandler;"
}
.end annotation
Directly keeping the DeepLinkHandler class is fixing this issue.
I also added some other code to make this safer and allow error reporting when type determination does not work.
Keep deep link handler so tje signature attributes are also kept in the .dex file.
Make ErrorHandler an abstract class so we can add error when type of deeplink handler args class cannot be determined.
Fall back to Any::class.java when no type can be determined.
Switch on R8 full mode to allow visibility into errors caused by full mode.
The bytecode in the
.dex
file for the DeepLinkHander interface looks like this after normal compilation:If we run R8 with full mode enabled on this it looks like this:
The
dalvik/annotation/Signature
that describes the generic type got removed. (See https://r8.googlesource.com/r8/+/refs/heads/main/compatibility-faq.md).This is no issue at runtime as this is not needed and the generic type of anything implementing the interface is still kept.
e.g.
but the type is fully erased if it is just
Any
e.g.Directly keeping the
DeepLinkHandler
class is fixing this issue. I also added some other code to make this safer and allow error reporting when type determination does not work..dex
file.ErrorHandler
an abstract class so we can add error when type of deeplink handler args class cannot be determined.Any::class.java
when no type can be determined.