Hacktoberfest 2026 : les issues que les mainteneurs ont marquées pour octobre, ouvertes et accessibles aux débutants. Parcourir les issues Hacktoberfest

AbstractMethodError for abstract Widget class - since migration to byte-buddy

Ouverte
#2,372 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

Personne n'a encore pris cette issue.

Évaluation

Difficulté
4/5
Temps estimé
3-5 jours
Accessibilité débutants
50/100
Type d'issue
Bug
Clarté
Plutôt claire
Activité
À l'abandon
Stack technique
android, ios, java

Piste de recherche

Commencez par l’exemple de Widget abstrait de Page-objects.md et suivez la manière dont OverrideWidget, WidgetInterceptor et field.getType() sélectionnent la classe du widget. Reproduisez les cas Android et iOS de l’issue, puis vérifiez que les appels aux implémentations de la plateforme ne lèvent plus AbstractMethodError lors de l’utilisation de Byte Buddy.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

bug
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:

Image

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.

Langage dominant
Java
Étoiles
1.3k
Forks
755
Merge moyen
5 j 14 h
PR mergées (30 j)
8

Préparer son environnement

  • Aucun Dockerfile ni fichier Docker Compose
  • Propose un modèle de pull request
  • Aucun guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de appium/java-client

Toutes les issues de appium/java-client

Issues similaires

Plus d'issues Java

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.