This is the mail archive of the
kawa@sources.redhat.com
mailing list for the Kawa project.
Re: java.lang.VerifyError for keyword with type
- From: Vladimir Tsichevski <wowa at jet dot msk dot su>
- To: Chris Dean <Chris dot Dean at sokitomi dot com>
- Cc: Kawa List <kawa at sources dot redhat dot com>
- Date: Tue, 08 Apr 2003 11:47:42 +0400
- Subject: Re: java.lang.VerifyError for keyword with type
- References: <28436.1049763678@mercedsystems.com>
Chris Dean wrote:
Looks like we can generate invalid code for procedures that have
keywords. In the case where we specify the type of the keyword
parameter we get this error when loading:
<skipped>
+
+(define (proc-with-keywords x #!key (y :: <int> 1))
+ (list x y))
+
The problem is that the following code is produced by kawa:
Object object
= Keyword.searchForKeyword(argsArray, 0, Lit0, /*TYPE_ERROR*/ 1);
int i;
try {
i = ((Number) object).intValue();
} catch (ClassCastException classcastexception) {
throw WrongType.make(classcastexception, "proc-with-keywords", 1);
}
int y = i;
so, as you may see, the default value is passed to
Keyword.searchForKeyword, and it
must be Java object, not a Java primitive. The keyword arguments are
passed as Object[], so all values are passed
also as Java objects.
So, until this bug is patched, use the following variant:
(define (proc-with-keywords1 x #!key y)
(let((y :: <int> (or y 1)))
(list x y)))
This variant compiles into correct (and more adequate) bytecode:
public static Object procWithKeywords1$V(Object x, Object[] argsArray) {
Object y = Keyword.searchForKeyword(argsArray, 0, Lit0, Boolean.FALSE);
Object GS$Dt1 = y;
int y_0_ = GS$Dt1 != Boolean.FALSE ? ((Number) GS$Dt1).intValue() : 1;
Regards,
Vladimir