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

Clarity in Implementation of interfaces with default methods #1181

Closed
petrushy opened this issue Apr 20, 2024 · 1 comment · Fixed by #1182
Closed

Clarity in Implementation of interfaces with default methods #1181

petrushy opened this issue Apr 20, 2024 · 1 comment · Fixed by #1182

Comments

@petrushy
Copy link

petrushy commented Apr 20, 2024

I can not find how jpype behaves for interfaces with default methods?

I have a class in EventHandler (https://www.orekit.org/site-orekit-12.0.1/jacoco/org.orekit.propagation.events.handlers/EventHandler.java.html) which has one required and two default methods, of which one is init(). It seems like in the JImplements of this class, the jpype requires the required + init (which is a method with default implementation). Why is init part of required methods? Is the other default method optional to implement in python - will the python code be used if it is implemented?

Many thanks for a very interesting tool.

@Thrameos
Copy link
Contributor

I believe the problem is that type resolution function is unable to reach init due to its meta data. I replicated the problem locally, though I currently don’t know the source. Default methods are wired into Java in a rather odd way because they didn’t exist in the original specification, thus instead they appear more like methods in the derived class which in the case of Proxy doesn’t exist. It doesn’t seem to require them to consider the class complete as jpype isn’t producing a warning. Meaning if we can call the method, it would be fine.
Investigating further the problem is not actually JPype, but instead Java itself. There is no easy way to access default methods of a proxy because any attempt to call the default method simply redirects back to the proxy at least last time I checked. I managed to patch something in using MethodHandles. Hopefully that addresses the issue.

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

Successfully merging a pull request may close this issue.

2 participants