This is the mail archive of the
kawa@sources.redhat.com
mailing list for the Kawa project.
warnings when calling methods from Java interfaces, not classes
- From: "Hoehle, Joerg-Cyril" <Joerg-Cyril dot Hoehle at t-systems dot com>
- To: kawa at sources dot redhat dot com
- Date: Fri, 31 Oct 2003 17:05:00 +0100
- Subject: warnings when calling methods from Java interfaces, not classes
Hi,
I'm running Kawa interactively as usual, e.g. loading *.scm files -- I didn't try to see what messages I would get if I were to compile the Scheme files -- and running into warnings about unknown methods.
The problem is that these methods come from interfaces, not classes, so a cast using (as <class.x> y) is of no help here.
E.g. Java.security is full of interfaces:
http://java.sun.com/j2se/1.4.2/docs/api/java/security/interfaces/RSAPublicKey.html
E.g.
(define (rnd-pkcs1 bytes)
(let* ((keypair :: <java.security.KeyPair> akey)
(pubkey :: <java.security.PublicKey> (invoke keypair 'getPublic)))
`((KeyMod ,(make <u8vector> (bigint-n-bytes 128 (invoke pubkey 'getModulus))))
(KeyExp ,(make <u8vector> (bigint-n-bytes 8 (invoke pubkey 'getPublicExponent))))
(Signature ,(make <u8vector>
(gen-pkcs1 (invoke keypair 'getPrivate) bytes))))))
;;(rnd-pkcs1 (Base64:decode "ABCD"))
<stdin>:114:17: warning - no definitely applicable method `<init>' in gnu.lists.U8Vector
<stdin>:114:49: warning - no method `getModulus' in java.security.PublicKey
<stdin>:115:17: warning - no definitely applicable method `<init>' in gnu.lists.U8Vector
<stdin>:115:49: warning - no method `getPublicExponent' in java.security.PublicKey
<stdin>:116:22: warning - no definitely applicable method `<init>' in gnu.lists.U8Vector
Is there some mean to get rid of the "no method" warnings for methods provided by interfaces, e.g. RSAPublicKey or RSAKey?
The "no definitely applicable method `<init>'" comes from the fact that Kawa doesn't seem to know that gen-pkcs1 or that bigint-n-bytes returns a byte[]:
;;TODO KeyMod may have 129 bytes, need 128
(define (bigint-n-bytes n big :: <java.math.BigInteger>)
(invoke big 'toByteArray))
It further seems that type declarations for variables are ignored by subsequent code in interactive mode.
(define random-gen :: <java.security.SecureRandom>
(invoke-static <java.security.SecureRandom> 'getInstance "SHA1PRNG"))
(define ...
(... (invoke key-gen 'initialize 1024 random-gen) ...))
<stdin>:14:6: warning - no definitely applicable method `initialize' in java.security.KeyPairGenerator
Here I could get rid of the warning by explicit casts around both 1024 (!) and random-gen - quite ugly.
How can this situation be improved upon?
- go to file compilation
- other?
Thanks for your help,
Jorg Hohle.