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: static blocks in define-simple-class


That worked. However, I seem to get a verification error when I have a
static method with a parameter which is used in the body (if I don't
have a parameter or if I don't use that parameter in the body, then it
seems to be fine). Below is the sample code

(define-simple-class a ()
  ((f b :: <int>) :: <int> allocation: 'class
     b))

This compiles. But when I load the class into kawa using (load 'a), I
get the following error.

java.lang.VerifyError: (class: a, method: f signature: (I)I) Accessing value
from uninitialized register 1
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:141)
        at kawa.standard.load.loadClassFile(load.java:37)
        at kawa.standard.load.apply(load.java:294)
        at kawa.standard.load.apply2(load.java:194)
        at kawa.standard.load.apply1(load.java:184)
        at gnu.mapping.Procedure.apply(Procedure.java:133)
        at gnu.mapping.Procedure.apply(Procedure.java:115)
        at gnu.mapping.CallContext.runUntilDone(CallContext.java:244)
        at gnu.expr.ModuleExp.evalModule(ModuleExp.java:235)
        at kawa.Shell.run(Shell.java:231)
        at kawa.Shell.run(Shell.java:177)
        at kawa.Shell.run(Shell.java:164)
        at kawa.Shell.run(Shell.java:151)
        at kawa.repl.main(repl.java:673)



On Sun, 27 Mar 2005 15:02:27 -0800, Per Bothner <per@bothner.com> wrote:
> S D wrote:
> > Is there a way to define static blocks within the define-simple-class
> > with the same semantics as in Java which gets executed when that class
> > is loaded.
> 
> There's an example in the manual (though not yet in the online vesion):
> 
> (define-simple-class <my-class> ()
>    (allocation: 'class
>     init: (perform-actions-when-the-class-is-initizalized))
>    (x init: 10)
>    (init: (if (some-condition) (set! x (* x 2)))))
>


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