Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 4 commits
  • 3 files changed
  • 0 comments
  • 3 contributors
12  liverepl-agent/src/net/djpowell/liverepl/agent/Agent.java
@@ -150,7 +150,7 @@ public static void agentmain(String agentArgs, Instrumentation inst) {
150 150
             if (!clojureLoaded) { // if clojure wasn't loaded before, print current status
151 151
                 TRC.fine("Clojure is " + (isClojureLoaded() ? "" : "not ") + "loaded");
152 152
             }
153  
-            startRepl(port);
  153
+            startRepl(port, inst);
154 154
         } finally {
155 155
             popClassLoader(old);
156 156
         }
@@ -169,14 +169,16 @@ public static void agentmain(String agentArgs, Instrumentation inst) {
169 169
         return urls;
170 170
     }
171 171
 
172  
-    private static void startRepl(int port) {
  172
+    private static void startRepl(int port, Instrumentation inst) {
173 173
         // avoids making load-time references to Clojure classes from the system classloader
174 174
         try {
175 175
             ClassLoader cl = Thread.currentThread().getContextClassLoader();
176 176
             Class<?> repl = Class.forName("net.djpowell.liverepl.server.Repl", true, cl);
177  
-            Method method = repl.getMethod("main", InetAddress.class, Integer.TYPE);
178  
-            method.invoke(null, Main.LOCALHOST, port);
179  
-        } catch (Exception e) {
  177
+            Method method = repl.getMethod("main", InetAddress.class, Integer.TYPE, Instrumentation.class);
  178
+            method.invoke(null, Main.LOCALHOST, port, inst);
  179
+        } catch (RuntimeException e) {
  180
+	    throw e;
  181
+	} catch (Exception e) {
180 182
             throw new RuntimeException(e);
181 183
         }
182 184
     }
23  liverepl-server/src/net/djpowell/liverepl/server/Repl.java
... ...
@@ -1,6 +1,7 @@
1 1
 package net.djpowell.liverepl.server;
2 2
 
3 3
 import java.net.InetAddress;
  4
+import java.lang.instrument.Instrumentation;
4 5
 
5 6
 import clojure.lang.Namespace;
6 7
 import clojure.lang.PersistentArrayMap;
@@ -9,21 +10,19 @@
9 10
 import clojure.lang.Var;
10 11
 
11 12
 public class Repl {
12  
-
13 13
     private final static Symbol REPL_NS = Symbol.create("net.djpowell.liverepl.server.repl");
14 14
     private final static Namespace NS = Namespace.findOrCreate(REPL_NS);
15 15
     private final static Var REQUIRE = Var.intern(RT.CLOJURE_NS, Symbol.create("require"));
16 16
     private final static Var REPL = Var.intern(NS, Symbol.create("repl"));
  17
+
  18
+    private final static Symbol AGENT_NS_NAME = Symbol.create("jvm.agent");
  19
+    private final static Namespace AGENT_NS = Namespace.findOrCreate(AGENT_NS_NAME);
17 20
     
18  
-	public static void main(InetAddress host, int port) throws Exception {
19  
-		// not really needed in clojure 1.1, as context class loaders are the default
20  
-		Var.pushThreadBindings(new PersistentArrayMap(new Object[] {RT.USE_CONTEXT_CLASSLOADER, Boolean.TRUE}));
21  
-		try {
22  
-			REQUIRE.invoke(REPL_NS);
23  
-			REPL.invoke(port, 0, host);
24  
-		} finally {
25  
-			Var.popThreadBindings();
26  
-		}
27  
-	}
28  
-	
  21
+    public static void main(InetAddress host, int port, Instrumentation inst)
  22
+	throws Exception {
  23
+	final Var instv = Var.intern(AGENT_NS, Symbol.create("instrumentation"));
  24
+	instv.bindRoot(inst);
  25
+	REQUIRE.invoke(REPL_NS);
  26
+	REPL.invoke(port, 0, host);
  27
+    }
29 28
 }
33  liverepl.sh 100644 → 100755
@@ -3,13 +3,34 @@
3 3
 
4 4
 [ -z "$JDK_HOME" ] && JDK_HOME=/usr/lib/jvm/default-java
5 5
 LIVEREPL_HOME="$(cd -P -- "$(dirname -- "$0")" && pwd -P)"
6  
-CLOJURE_JAR="$LIVEREPL_HOME/clojure.jar"
7 6
 
8  
-if [ ! -f "$JDK_HOME/lib/tools.jar" ]; then
9  
-   echo 'Unable to find $JDK_HOME/lib/tools.jar'
10  
-   echo "Please set the JDK_HOME environment variable to the location of your JDK."
11  
-   exit 1
  7
+MAIN=net.djpowell.liverepl.client.Main
  8
+CLOJURE_JAR=$(find $LIVEREPL_HOME/build -name 'clojure-*[0-9].jar' | head -1)
  9
+AGENT_JAR="$LIVEREPL_HOME/build/liverepl-agent.jar"
  10
+SERVER_JAR="$LIVEREPL_HOME/build/liverepl-server.jar"
  11
+
  12
+
  13
+if [ "Darwin" = "`uname -s`" ]; then
  14
+    CLASSPATH="${CLASSPATH}${JAVA_HOME}/bundle/Classes/classes.jar"
  15
+elif [ ! -f "$JDK_HOME/lib/tools.jar" ]; then
  16
+    echo 'Unable to find $JDK_HOME/lib/tools.jar'
  17
+    echo "Please set the JDK_HOME environment variable to the location of your JDK."
  18
+    exit 1
  19
+else
  20
+    CLASSPATH="${CLASSPATH}${JDK_HOME}/lib/tools.jar"
  21
+fi
  22
+
  23
+if [ "$TERM" != "dumb" ]; then
  24
+    if which rlwrap >/dev/null ; then
  25
+        echo "Found rlwrap"
  26
+        breakchars="(){}[],^%$#@\"\";:''|\\"
  27
+        WRAP="exec rlwrap --remember -c -b \"$breakchars\" "
  28
+    fi
12 29
 fi
13 30
 
14  
-java -cp "$LIVEREPL_HOME/liverepl-agent.jar:$JDK_HOME/lib/tools.jar" net.djpowell.liverepl.client.Main "$CLOJURE_JAR" "$LIVEREPL_HOME/liverepl-agent.jar" "$LIVEREPL_HOME/liverepl-server.jar" "$@"
  31
+CLASSPATH="$CLASSPATH:$AGENT_JAR"
  32
+
  33
+${WRAP}java -cp $CLASSPATH $MAIN "$CLOJURE_JAR" "$AGENT_JAR" "$SERVER_JAR" "$@"
  34
+
  35
+
15 36
 

No commit comments for this range

Something went wrong with that request. Please try again.