pyjnius
pyjnius copied to clipboard
JavaMultipleMethod mismatch for Interface arguments
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.