Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calling Java 8 interface default and static methods from Python is not fully tested #1205

Open
mhsmith opened this issue Jul 6, 2024 · 0 comments
Labels

Comments

@mhsmith
Copy link
Member

mhsmith commented Jul 6, 2024

Apart from the Android issue in #1204, there may also be some non-Android-specific corner cases that we still don't cover:

Both dynamic and static proxies should be able to leave a default method unimplemented, in which case calling the method on the the proxy class should go through to the default.

Default methods can be hidden by:

  • Abstract methods in the implementing class (normal methods can also be made abstract this way, e.g. AbstractSequentialList.listIterator).
  • Abstract methods inherited by the implementing class.
  • Unimplemented (non-"default") overrides of the method in a sub-interface.

In all cases, attempting to call the method should be an error.

An interface (unlike an abstract class) cannot force the implementing class to implement a public Object method. In Java it can force the implementing class to publicly implement a protected Object method, but that'll work differently in Python because we're treating protected as equivalent to public.

It's possible to inherit an interface method implementation from a superclass which doesn't implement that interface. So the MRO should go along the "extends" chain up to but not including Object, then through the interfaces, then Object. This would ensure that if the method exists (even abstractly) in an indirectly-extended class, then default methods (if any) of directly-inherited interfaces will not be called, and an abstract method error will not occur. It might not be possible to do this through the Python MRO rules, but we're currently not using them anyway (see reflect_member).

If a class inherits multiple default methods with the same signature, the JLS requires it to explicitly implement that method.

We may now need to search in multiple bases for inherited overloads of default and static interface methods: see what the JLS says about this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant