Dear Clojurians, gen-class loads eg. foo/bar/Baz.clj for class foo.bar.Baz. However, maybe one also has support functions in the foo.bar namespace. Hence one needs also foo/bar/bar.clj. But now we are in trouble, since we have to duplicate any shared initialisation between bar.clj and Baz.clj. We cannot ensure, that the user "require"s the namespace before creating a new Baz object.
As Rich stated in other threads: the unit that matters is the namespace, not the file. So I think gen-class should also require the namespace not the file. I tried to implement this, but this since my knowledge of such low-level stuff is nearly non-existant, it's more a hack. It extracts the namespace and loads the corresponding file, foo/bar/bar.clj in the above example. The namespace foo.bar is then in charge to provide the implementation for foo.bar.Baz. I tried to "require" the namespace, but I don't know enough of the gen stuff. But since the original gen-class also uses loadResourceScript I can live with that... The patch is (hopefully) attached. Comments appreciated. Sincerely Meikel
gen-class-require.patch
Description: Binary data
smime.p7s
Description: S/MIME cryptographic signature