This is the mail archive of the kawa@sources.redhat.com mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Class types


> 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]