<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -204,3 +204,20 @@ Raise an exception if any deletion fails unless silently is true.&quot;
 (defmethod as-url String [#^String x] (URL. x))
 
 (defmethod as-url File [#^File x] (.toURL x))
+
+(defn wall-hack-method
+  &quot;Calls a private or protected method.
+   params is a vector of class which correspond to the arguments to the method
+   obj is nil for static methods, the instance object otherwise
+   the method name is given as a symbol or a keyword (something Named)&quot;
+  [class-name method-name params obj &amp; args]
+  (-&gt; class-name (.getDeclaredMethod (name method-name) (into-array Class params))
+    (doto (.setAccessible true))
+    (.invoke obj (into-array Object args))))
+
+(defn wall-hack-field
+  &quot;Access to private or protected field.&quot;
+  [class-name field-name obj]
+  (-&gt; class-name (.getDeclaredField (name field-name))
+    (doto (.setAccessible true))
+    (.get obj)))</diff>
      <filename>src/clojure/contrib/java_utils.clj</filename>
    </modified>
    <modified>
      <diff>@@ -79,6 +79,7 @@ collecting its stdout&quot;}
    (map? arg) (into-array String (map (fn [[k v]] (str (as-env-key k) &quot;=&quot; v)) arg))
    true arg))
 
+
 (defn sh
   &quot;Passes the given strings to Runtime.exec() to launch a sub-process.
 
@@ -111,26 +112,26 @@ collecting its stdout&quot;}
         proc (.exec (Runtime/getRuntime) 
 		    (into-array (:cmd opts)) 
 		    (as-env-string (:env opts))
-		    (as-file (:dir opts)))
-        in-stream (.getInputStream proc)]
-    (when (:in opts)
+		    (as-file (:dir opts)))]
+    (if (:in opts)
       (with-open [osw (OutputStreamWriter. (.getOutputStream proc))]
-        (.write osw (:in opts))))
-    (let [stdout (.getInputStream proc)
-          stderr (.getErrorStream proc)
-          [[out err] combine-fn]
-            (if (= (:out opts) :bytes)
-              [(for [strm [stdout stderr]]
-                (into-array Byte/TYPE (map byte (stream-seq strm))))
-               #(aconcat Byte/TYPE %1 %2)]
-              [(for [strm [stdout stderr]]
-                (apply str (map char (stream-seq 
-                                       (InputStreamReader. strm (:out opts))))))
-                 str])
-           exit-code  (.waitFor proc)]
-      (if (:return-map opts)
-        {:exit exit-code :out out :err err}
-        (combine-fn out err)))))
+        (.write osw (:in opts)))
+      (.close (.getOutputStream proc)))
+    (with-open [stdout (.getInputStream proc)
+                stderr (.getErrorStream proc)]
+      (let [[[out err] combine-fn]
+                (if (= (:out opts) :bytes)
+                  [(for [strm [stdout stderr]]
+                    (into-array Byte/TYPE (map byte (stream-seq strm))))
+                  #(aconcat Byte/TYPE %1 %2)]
+                  [(for [strm [stdout stderr]]
+                    (apply str (map char (stream-seq 
+                                            (InputStreamReader. strm (:out opts))))))
+                  str])
+              exit-code (.waitFor proc)]
+        (if (:return-map opts)
+          {:exit exit-code :out out :err err}
+          (combine-fn out err))))))
 
 (comment
 </diff>
      <filename>src/clojure/contrib/shell_out.clj</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>12e935b5ed1d462a4a48f647e17315a0bb25b48b</id>
    </parent>
  </parents>
  <author>
    <name>Kevin Downey</name>
    <email>redchin@gmail.com</email>
  </author>
  <url>http://github.com/richhickey/clojure-contrib/commit/cc4e2ec2bf558f059330ebc97a031d7806a1e364</url>
  <id>cc4e2ec2bf558f059330ebc97a031d7806a1e364</id>
  <committed-date>2009-11-06T22:21:20-08:00</committed-date>
  <authored-date>2009-11-06T22:14:59-08:00</authored-date>
  <message>add wall-hack-method and wall-hack-field. fixes #43

Signed-off-by: Chouser &lt;chouser@n01se.net&gt;</message>
  <tree>48d33493a001e90645cd93fb60b2f645ce09b8bd</tree>
  <committer>
    <name>Chouser</name>
    <email>chouser@n01se.net</email>
  </committer>
</commit>
