This is the mail archive of the
kawa@sources.redhat.com
mailing list for the Kawa project.
RE: Class types
- From: Chris Dean <ctdean at sokitomi dot com>
- To: dominique dot boucher at nuecho dot com
- Cc: "'Kawa List'" <kawa at sources dot redhat dot com>
- Date: Thu, 13 May 2004 09:48:34 -0700
- Subject: RE: Class types
- References: <200405131312.i4DDCUx14071@almodovar.nuecho.ad>
> I guess you try to obtain the Java class object corresponding to a Kawa
> class.
Exactly.
> (define (foo)
> (invoke (as <gnu.bytecode.ClassType> <java.util.Date>) 'getClass))
This also gives a warning:
% java kawa.repl --warn-undefined-variable -C Foo.scm
(compiling Foo.scm)
Foo.scm:11:40: warning - no declaration seen for <java.util.Date>
The warning is a hint that Kawa will generate code to do a runtime
lookup of <java.util.Date> rather than generating more efficient compile
time code. In this case we generate Java byte code equivalent to:
public static Class foo() {
return ((ClassType)
Interpreter.getSymbolValue(id$$Lsjava$Dtutil$DtDate$Gr))
.getClass();
}
The best way might be to call Class.forName( "java.util.Date" ), but if
Kawa has an existing variable that has the class I'd prefer to use that.
Regards,
Chris Dean