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]

define-simple-class vs modules


Once upon a time (before 1.10, probably), I was able to do something like this:

$ cat Test.scm
(define-simple-class Test ()
  ((*init*) (display "Created an instance") (newline)))

but now when I try to compile it:

$ java kawa.repl -C Test.scm
(compiling Test.scm to Test)
Test.scm:2: internal error while compiling Test.scm
java.lang.Error: calling <init> on already-initialized object
	at gnu.bytecode.CodeAttr.emitInvokeMethod(CodeAttr.java:1498)
	at gnu.bytecode.CodeAttr.emitInvokeSpecial(CodeAttr.java:1543)
	at gnu.expr.ClassExp.invokeDefaultSuperConstructor(ClassExp.java:732)
	at gnu.expr.ClassExp.compileMembers(ClassExp.java:538)
	at gnu.expr.ClassInitializer.<init>(ClassInitializer.java:16)
	at gnu.expr.ClassExp.compileSetField(ClassExp.java:782)
	at gnu.expr.SetExp.compile(SetExp.java:167)
	at gnu.expr.Expression.compileNotePosition(Expression.java:156)
	at gnu.expr.Expression.compileWithPosition(Expression.java:142)
	at gnu.expr.LambdaExp.compileBody(LambdaExp.java:1619)
	at gnu.expr.Compilation.generateBytecode(Compilation.java:2015)
	at gnu.expr.Compilation.process(Compilation.java:1893)
	at gnu.expr.ModuleInfo.loadByStages(ModuleInfo.java:305)
	at gnu.expr.ModuleInfo.loadByStages(ModuleInfo.java:290)
	at kawa.repl.compileFiles(repl.java:783)
	at kawa.repl.processArgs(repl.java:412)
	at kawa.repl.main(repl.java:829)

It seems I can no longer define-simple-class a Java class with the name of the Scheme file. That name gets reserved for a mandatory "module" class, even if the simple-class is the only definition in the whole file. Was it just an accident that it worked before?

Relatedly, if I wanted to use module-extends and module-implements instead of define-simple-class: How would I define constructors? Can I use (this) in the body of a function? Are annotations supported?

Thanks,
Jamie

--
Jamison Hope
The PTR Group
www.theptrgroup.com




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