pyjnius icon indicating copy to clipboard operation
pyjnius copied to clipboard

JavaMultipleMethod mismatch for Interface arguments

Open miohtama opened this issue 8 years ago • 7 comments

JavaMultipleMethod resolves to a wrong method signature in a case where matching should be done by the interfaces. Consider the following Cipher.init:

    Cipher = autoclass("javax.crypto.Cipher")
    SecretKeySpec = autoclass("javax.crypto.spec.SecretKeySpec")

    default_key = [0x00] * 16
    secret_key_spec = SecretKeySpec(default_key, "DESede")

    # The signature we want is (int, java.security.Key) [Key is interface]
    # the signature this resolves is (int, java.security.Certificate)
    # JavaException: Invalid instance of u'javax/crypto/spec/SecretKeySpec' passed for a u'java/security/cert/Certificate'
    cipher.init(Cipher.DECRYPT_MODE, secret_key_spec)

A (temporary) solution would be manually pull out the correct underlying call signature from JavaMultipleMethod object using the interface name in the signature. However is this possible? I did not find any examples doing this and my poking from console did not yield results.

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/31513645-javamultiplemethod-mismatch-for-interface-arguments?utm_campaign=plugin&utm_content=tracker%2F77133&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F77133&utm_medium=issues&utm_source=github).

miohtama avatar Mar 02 '16 05:03 miohtama