This is the mail archive of the kawa@sourceware.org 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]

Weird bug for default constructor


Hi,

When compiling the code below with "kawa -C c_image.scm" I get the 
following error:

[kjetism@iannis src]$ kawa -C bug.scm
(compiling bug.scm to c_image)
bug.scm:50: internal error while compiling bug.scm
java.lang.NullPointerException
        at gnu.bytecode.CodeAttr.emitLoad(CodeAttr.java:1175)
        at gnu.expr.ClassExp.compile(ClassExp.java:413)
        at gnu.expr.ClassInitializer.<init>(ClassInitializer.java:16)
        at gnu.expr.ClassExp.compileSetField(ClassExp.java:655)
        at gnu.expr.SetExp.compile(SetExp.java:170)
        at gnu.expr.Expression.compileNotePosition(Expression.java:157)
        at gnu.expr.Expression.compileWithPosition(Expression.java:128)
        at gnu.kawa.functions.AppendValues.compile(AppendValues.java:49)
        at gnu.expr.ApplyExp.compile(ApplyExp.java:171)
        at gnu.expr.ApplyExp.compile(ApplyExp.java:110)
        at gnu.expr.Expression.compileWithPosition(Expression.java:146)
        at gnu.expr.LambdaExp.compileBody(LambdaExp.java:1508)
        at gnu.expr.Compilation.generateBytecode(Compilation.java:2005)
        at gnu.expr.Compilation.process(Compilation.java:1879)
        at gnu.expr.ModuleInfo.loadByStages(ModuleInfo.java:302)
        at gnu.expr.ModuleInfo.loadByStages(ModuleInfo.java:287)
        at kawa.repl.compileFiles(repl.java:773)
        at kawa.repl.processArgs(repl.java:426)
        at kawa.repl.main(repl.java:828)


I can not guarantee that you are able to reproduce it, because it seems
to be rather random when the internal error strikes or not. But I hope
that this example is reproducable...

This is also the smallest example I could make (!). However, after trying 
various things, I think it may be related to the default constructor
((*init*) #!void) , because when removing the default constructor, it 
allways seems to work.

I won't be surprised if its related to the garbage collector either, 
since I had so much trouble making a reproducable example.

Or, perhaps I have just screwed up something. Hopefully someone tells me 
if I have done something obviously stupid.

Also, is there any "super" kind of function available? Because then 
I can get away with only one constructor. (<c_image> is a superclass)



"
(define (c-for-each func . lists)
  (let ((n 0))
    (apply for-each (cons (lambda els
			    (apply func (cons n els))
			    (set! n (1+ n)))
			  lists))))
(define (c-display . args)
  (let ((printfunc display))
    (c-for-each (lambda (n arg)
		  (if (> n 0)
		      (printfunc " "))
		  (printfunc arg))
		args)
    (newline)))
(define-simple-class <c_image> ()
  ( ll-image :: <java.awt.Image> #!null)
  ( x 0)
  ( y 0)
  ( width 0)
  ( height 0)
  ( g :: <java.awt.Graphics> #!null)
  ( (is-inside xp yp)
    (let ((x2 (+ x width))
	  (y2 (+ y width)))
      (c-display "is-inside called" xp yp x x2 y y2)
      (and (>= xp x)
	   (< xp x2)
	   (>= yp y)
	   (< yp y2))))
  ( (*das-init* *ll-image)
    (set! ll-image *ll-image)
    (set! g (invoke ll-image 'getGraphics)))
  ( (*init* *ll-image *x)
    (*das-init* *ll-image))
  ( (*init*) #!void))
"


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