Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@stuartsierra
Created October 2, 2010 01:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stuartsierra/607161 to your computer and use it in GitHub Desktop.
Save stuartsierra/607161 to your computer and use it in GitHub Desktop.
#!/bin/sh
# reload-aot-error.sh
# This file demonstrates the problems that result from
# unloading-and-reloading Clojure namespaces whose source files are
# newer than their AOT-compiled .class files.
# To run the demonstration, copy this script and clojure.jar into an
# empty directory, then execute the script.
# When it fails, the exception will be:
# Exception in thread "main"
# java.lang.Exception:
# namespace 'project.alpha' not found after loading '/project/alpha'
# Failure behavior by version:
# FAILS on Clojure 1.0.0
# succeeds on Clojure 1.1.0
# FAILS on Clojure 1.2.0
# FAILS on Clojure 1.3.0-alpha1
# FAILS on Clojure 1.3.0-SNAPSHOT commit 167a73857a746e8dbeeb6d9ea8f99083aca7dc69
cd `dirname $0`
if [ ! -e clojure.jar ]; then
echo "Must have clojure.jar in this directory."
exit 1
fi
rm -rf classes src
mkdir -p src/project classes
cat > src/project/alpha.clj <<EOF
(ns project.alpha)
EOF
cat > src/project/beta.clj <<EOF
(ns project.beta (:use project.alpha))
EOF
cat > src/project/delta.clj <<EOF
(ns project.delta (:use project.beta))
(remove-ns (quote project.alpha))
(require (quote project.beta) :reload-all)
EOF
JAVA="java -cp src:classes:clojure.jar -Dclojure.compile.path=classes"
# If you comment out this line (don't AOT-compile), it works:
$JAVA clojure.lang.Compile project.beta
# If you comment out this line (don't modify source), it works:
touch src/project/beta.clj
# But if both lines are left uncommented, this fails:
$JAVA clojure.main src/project/delta.clj
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment