On Thu Nov 17 09:06 2011, Terje Dahl wrote:
> What is the relationship between the .clj source-file(s) and its gen-
> class compiled class-files?
> 
> The reason I ask is that my app is an applet, written in Clojure
> (obviously), and compiled.
> The resulting class-files are then bundled into a jar-file, but
> without the source clj-file.
> (I don't want to incude my source-code in the deployed applet jar-file
> - for business reasons, obviously).
> 
> The applet loads and runs just fine, but not before requesting clj-
> files from the server.
> In my server log files I see failed requests for "user.clj" and
> "applet.clj" (the file containing all my source-code).
> The applet doesn't recieve the files from the server, but runs just
> fine all the same, so obviously doesn't need them.
> 
> 1.  Why are these files requested in the first place, when not needed?

By default, when loading a namespace, Clojure will try to find both the
source file and a class that loads the namespace.  For example, given
the namespace "example.core", it will look for both "example/core.clj"
and "example/core__init.class".  I believe the reasoning goes that if
the source file is more recent than the AOT-compiled class, it will
recompile the namespace at runtime.

The reason why its looking for "user.clj" is that by default when
Clojure loads up it will create the "user" namespace that is used in the
REPL.

> 2. How do I prevent these files from being requested at all?

I don't think there is a way to do this without modifying Clojure's
code.  If you're up to making your own custom build of Clojure, the
changes should be relatively simple to do.

To prevent the lookup of the Clojure file, I think you might be able to
just change line 405 of RT.java
<https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/RT.java#L405>
so that "cljURL" is simply set to null.  I haven't tested it, but I
think it should work.

To prevent the "user" namespace from being created, you should be able
to remove lines 436-452 of RT.java
<https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/RT.java#L436-452>.
I do not remember if this change will keep you from being able to
compile your applet, but I do think it'd keep the REPL from running.

> 
> (When I have 100 kids in the same school, loading my applet at the
> same time, all the extra failed and unneccessary request are unwelcome
> on an already slow school network)
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en

Attachment: signature.asc
Description: Digital signature

Reply via email to