This is the mail archive of the
kawa@sources.redhat.com
mailing list for the Kawa project.
module extension
- To: kawa at sources dot redhat dot com
- Subject: module extension
- From: mgd at swarm dot org (Marcus G. Daniels)
- Date: 23 Nov 2000 13:22:28 -0800
The Kawa manual makes it sound as if it is possible to extend any Java
class as a Scheme module provided that class has a default
constructor. Is this really the intent? If so, should it also
be possible to make Scheme modules based on Java classes that have
constructors with arguments?
If MODULESPEC is `<CLASSNAME>' where CLASSNAME is an instance
module (it has a public default constructor), and if no module
instance for that class has been registered in the current
environment, then a new instance is created and registered (using
a "magic" identifier).
I've attached a test case that tries to do a module-extends in three
different ways 1) by having a default constructor, 2) by implementing
Runnable, and 3) by extending gnu.expr.ModuleBody. Only #3 works for
me. With Sun JDK 1.2.2 and JDK 1.3 on i386 Linux, #1 and #2 result in
a Verify error like this:
Exception in thread "main" java.lang.VerifyError: (class: testSimple, method: <init> signature: ()V) Incompatible object argument for function call
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:120)
at gnu.bytecode.ObjectType.getReflectClass(ObjectType.java:54)
at kawa.standard.require.scanForDefinitions(require.java:110)
at kawa.lang.Translator.scan_form(Translator.java:475)
at kawa.lang.Translator.scan_body(Translator.java:507)
at kawa.standard.Scheme.makeModuleExp(Scheme.java:793)
at kawa.Shell.run(Shell.java:72)
at kawa.Shell.runString(Shell.java:113)
at kawa.repl.main(repl.java:108)
To run the test case, do:
$ tar zxf moduleTest.tar.gz
$ cd moduleTest
$ ./run
test case of module-extends