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: Verifier error using define-simple-class


Hi,

A bug is already open regarding a similary issue (#4881) on Savannah. A here
is simple work-around: when accessing fields or calling methods in a
lambda-expression inside the body of a method, I usually wrap the whole
method body with (let ((self (this))) ..):

(define-simple-class <A> ()
   ((workaround)
    (let ((self (this)))                 ; <-----
      (let ((fn (lambda (o)
                  (invoke self 'get-identity-property-name o))))    ; <-----
         fn)))
   ...
   ((get-identity-property-name property-name)
    (string-append property-name "Identity")))


Suggestion: maybe Kawa could do this automatically (or something similar),
so that a 'self' variable is always visible in method bodies?

Dominique
 

> -----Original Message-----
> From: kawa-owner@sources.redhat.com 
> [mailto:kawa-owner@sources.redhat.com] On Behalf Of Dean Ferreyra
> Sent: 9 juin 2005 19:49
> To: 'Kawa List'
> Subject: Verifier error using define-simple-class
> 
> Hello,
> 
> I'm using a recent CVS pull of Kawa and I'm getting verifier 
> errors in some circumstances.  I've attached a distilled example.
> 
> It seems to revolve around having a define-simple-class that 
> generates a lambda that calls another method.  Here's a 
> snippet from the example:
> 
> --------------------
> (define-simple-class <A> ()
>    ((trouble)
>     (let ((fn (lambda (o)
>                 (get-identity-property-name o))))
>       fn))
>    ...
>    ((get-identity-property-name property-name)
>     (string-append property-name "Identity")))
> --------------------
> 
> The call to "get-identity-property-name" in the lambda seems 
> to be the trigger.  It's the compiled class, not the 
> define-simple-class class, that gives the verifier error.
> 
> If I replace the "trouble" method with this:
> 
> --------------------
>    ((okay)
>     (let ((fn (lambda (o)
>                 (invoke (this) 'get-identity-property-name o))))
>       fn))
> --------------------
> 
> the compiled class is clean.
> 
> Below I've pasted in what I see at the command line.
> 
> Dean
> 
> 
> ----------
> % make PURE=1 default
> rm -f *.class
> CLASSPATH=.:~/kawa/cvs/kawa-pure-build/kawa-1.7.91.jar java 
> kawa.repl --warn-undefined-variable --main -C classthis.scm 
> (compiling classthis.scm) 
> CLASSPATH=.:~/kawa/cvs/kawa-pure-build/kawa-1.7.91.jar java 
> classthis Exception in thread "main" java.lang.VerifyError: 
> (class: classthis,
> method: lambda1fn signature: (Ljava/lang/Object;)Ljava/lang/Object;)
> Incompatible object argument for function call
> make: *** [run] Error 1
> ----------
> 



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