AOT compiled classes and jars

1 view
Skip to first unread message

Justin Balthrop

unread,
Sep 9, 2010, 6:52:09 PM9/9/10
to Clojure Dev
Hi All,

Lau Jenson and I spent some time a few weeks back debugging a problem
with AOT compiled classes and jars. The bug arises from the following
two facts:

1) AOT classes are not used within clojure.lang.RT/load unless the
modification time is greater than the corresponding .clj file.
2) maven-shade-plugin (which we were using to generate uberjars) uses
the current time as the modification time for all files added to the
jar it creates.

This means clojure will always prefer the .clj file to the .class file
when loading from the jar. The fix is simple: just change > to >=

http://gist.github.com/572726

This seems like the expected behavior to me. If the source file and
AOT compiled file have the exact same modtime, there is no reason not
to use the compiled file. Can anyone see a case where the fixed code
would cause problems? I've been using the patched clojure-1.2.0.jar
locally for a few days and nothing has blown up.

I plan to switch from using maven-shade-plugin, so this fix doesn't
really affect me, but fixing it may save others the headache we went
through.

-Justin

Stephen C. Gilardi

unread,
Sep 12, 2010, 1:48:57 AM9/12/10
to cloju...@googlegroups.com

On Sep 9, 2010, at 6:52 PM, Justin Balthrop wrote:

> 1) AOT classes are not used within clojure.lang.RT/load unless the
> modification time is greater than the corresponding .clj file.
> 2) maven-shade-plugin (which we were using to generate uberjars) uses
> the current time as the modification time for all files added to the
> jar it creates.

The case of the mod times being equal is an ambiguous one. Having given this some thought in the past, I think the fix you proposed would not cause any intended current behavior to break.

> http://gist.github.com/572726
> [...]


> If the source file and AOT compiled file have the exact same modtime, there is no reason not to use the compiled file.

I agree.

--Steve

Reply all
Reply to author
Forward
0 new messages