AbstractMethodError for abstract Widget class - since migration to byte-buddy
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 50/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 領域
- mobile-dev, testing-qa
調査の方向性
Page-objects.md の抽象 Widget の例から始め、OverrideWidget、WidgetInterceptor、field.getType() がどのように Widget クラスを選択するかを追跡します。issue にある Android と iOS のケースを再現し、その後、Byte Buddy を使用した場合にプラットフォーム実装への呼び出しで AbstractMethodError が発生しなくなったことを確認します。
索引モデルが issue の本文から書いたものです。
説明
Is there an existing issue for this?
- I have searched the existing issues
Appium Version
2.0.1
Appium Host Type
Command Line
Are you using Appium components not maintained by the Appium team?
No response
Is this issue reproducible using the latest components?
- I confirm the issue is still reproducible with the latest component versions
Current Behavior
Currently my repo(Android & iOS combined) is using java-client version: 8.3.0
I did not update my version since I got issues with the new byte buddy library. I tried to update to the latest java client version(10.0.0) and still, I get the same issue.
The issue:
I am working according to this docs: PO - abstract Widget class.
When I run my tests using a java client with byte buddy I get AbstractMethodError.
Expected Behavior
To work as it did with cglib.
Appium Log
No response
Environment Details
- Debug details (
appium --show-debug-info): - Last component version(s) which did not exhibit the problem: appium 2.0.1, java-client 10.0.0
- Platform and version of device under test: android
- Real device or emulator/simulator: emulator
Minimal Reproducible Example
Reproduction:
Consider the following setup in your PO:
public class MyPO {
@OverrideWidget(androidUIAutomator = CustomWidget.AndroidCustomWidget.class, iOSXCUITAutomation = CustomWidget.IOSCustomWidget.class)
private CustomWidget myCustomWidget;
}
Your Widget class:
public abstract class CustomWidget extends Widget {
public abstract void abstractTest();
public static class AndroidCustomWidget extends CustomWidget {
@Override
public void abstractTest() {
//android implementation
}
}
public static class IOSCustomWidget extends CustomWidget {
@Override
public void abstractTest() {
//iOS implementation
}
}
}
Then in the test class just call:
myPO.getCustomWidget().abstractTest();
You'll get AbstractMethodError since byte buddy tries to call the original abstract method signature
Further Information
I also managed to find the issue and fix it locally. I will detail my steps here.
First, acording to this Callable implements no-abstract methods by default ByteBuddy's proxies(which are essentially just subclasses) subclass the Widget class and passing calls to the Interceptor(in our case Appium's WidgetInterceptor) for non-abstract methods. The issue is that it subclasses the original CustomWidget and thus it cannot call myWidget.abstractTest() and throwing AbstractMethodError. Instead, it needs to subclass AndroidCustomWidget or IOSCustomWidget according to the platform we are currently using. Since the abstractTest method is non-abstract in AndroidCustomWidget and IOSCustomWidget, byte buddy will override and intercept those methods as well - resulting in the desired behavior.
Fix example:
I was just testing and found out that the java client passes widgetType = (Class<? extends Widget>) field.getType(); which in our case is the abstract class CustomWidget, I added a check for android OverrideWidget and it worked perfectly(since the widgetType is now of type AndroidCustomWidget). In cglib it used to work but I guess byte buddy implements things differently so the the code needs to take into consideration the current platform and the Widget class that overrides it.
- 主要言語
- Java
- スター
- 1.3k
- フォーク
- 755
- 平均マージ
- 5日 14時間
- マージ済み PR(30日)
- 8
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドなし
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
appium/java-client のほかの issue
-
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
appium/java-client#2426 ·
メンテナーはふだん 1 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 30/100
appium/java-client#2368 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 30/100
appium/java-client#2341 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 15/100
appium/java-client#2323 ·
メンテナーはふだん 1 日以内に返信
-
java-client 启动报错オープン
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
appium/java-client#2288 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
appium/java-client の issue をすべて見る
似ている issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
openhab/openhab-core#5847 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
apache/parquet-java#3820 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
beehive-lab/jllm#187 ·