-
Notifications
You must be signed in to change notification settings - Fork 256
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
Defining method overload,JavaMultipleMethod, after autoclass #743
Comments
ok did it like below. got it working. MyClass = autoclass('io.MyClass')
MyClass.myMethod = JavaMethod('(Lio/Class2;)Lio/Builder'') now calls to myMethod are using second of the overloaded method. |
It might be good to have a test case if you think there is indeed a problem. there is some method selection code that tries to do the right thing... Isnt this a case of just casting the object to the correct type? pyjnius.cast("Lio.Class1", obj)? Or is this a problem with static methods? |
@cmacdonald its a fairly complex usage. AFAIK not related to casting or static method in this PR you could see full code, commented the fix. @cmacdonald im worried about the correct usage of pyjnius . especially around the garbage collected classes and usage of proxy class. not sure if this code follows all the practices. If you have time, could you do a review of the code? will appreciate your review. |
You have two notifying methods in DebeziumEngine$Builder. I'm confused about your code - you are overriding the notifying method with one from a different class. If its because the actual calling code is ending up calling DebeziumEngine$Builder.notifying() rather than DebeziumEngine$ChangeConsumer.notifying(), then you should try also casting to DebeziumEngine$ChangeConsumer first? |
exactly this is the case. i will check the example
this is correct, however
Edit: |
So I think you want something like: builder = pt.autoclass("my.class")() # remember to construct the instance from the class
builder.notifying(handler, signature="(Lcom/mine/ChangeConsumer;)V") More details: JavaMultipleMethod calls calculate_score() to decide which method to invoke. Exact matches score highly; the assignability of an object to the class of an argument is not considered: Lines 390 to 402 in 17563c6
In short, the Specify the signature simply tells jnius which method you want. PS: Perhaps a PR for the documentation that tells people about signature kwarg? |
is it possible define overloaded methods, after autoclass?
im passing and python implementation of an interface(
io/Class2
) but its not given to the right method.it takes it as a
io/Class1
The text was updated successfully, but these errors were encountered: