summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorStuart Halloway <stu@thinkrelevance.com>2010-07-01 13:56:35 -0400
committerStuart Halloway <stu@thinkrelevance.com>2010-07-09 15:02:42 -0400
commit0d39db4990e5ca2d3f4450f57ab15941e03b2e3b (patch)
treeb57e7080af0dbe4c29961fe594644fa9763b3c1e /src
parent31b6fb557a3c524c447d312f5c51b6262ffb9b0f (diff)
#392 fix reflection warnings and tests + minor cleanup
Signed-off-by: Stuart Halloway <stu@thinkrelevance.com>
Diffstat (limited to 'src')
-rw-r--r--src/clj/clojure/java/io.clj4
-rw-r--r--src/clj/clojure/java/shell.clj21
2 files changed, 10 insertions, 15 deletions
diff --git a/src/clj/clojure/java/io.clj b/src/clj/clojure/java/io.clj
index 4d6c551f..7af37ccd 100644
--- a/src/clj/clojure/java/io.clj
+++ b/src/clj/clojure/java/io.clj
@@ -33,8 +33,8 @@
(defprotocol ^{:added "1.2"} Coercions
"Coerce between various 'resource-namish' things."
- (^{:tag File, :added "1.2"} as-file [x] "Coerce argument to a file.")
- (^{:tag URL, :added "1.2"} as-url [x] "Coerce argument to a URL."))
+ (^{:tag java.io.File, :added "1.2"} as-file [x] "Coerce argument to a file.")
+ (^{:tag java.net.URL, :added "1.2"} as-url [x] "Coerce argument to a URL."))
(extend-protocol Coercions
nil
diff --git a/src/clj/clojure/java/shell.clj b/src/clj/clojure/java/shell.clj
index f20c72e9..a0f06f33 100644
--- a/src/clj/clojure/java/shell.clj
+++ b/src/clj/clojure/java/shell.clj
@@ -32,11 +32,6 @@ collecting its stdout"}
`(binding [*sh-env* ~env]
~@forms))
-(defn- stream-seq
- "Takes an InputStream and returns a lazy seq of integers from the stream."
- [stream]
- (take-while #(>= % 0) (repeatedly #(.read stream))))
-
(defn- aconcat
"Concatenates arrays of given type."
[type & xs]
@@ -54,7 +49,7 @@ collecting its stdout"}
[cmd opts] (split-with string? args)]
[cmd (merge default-opts (apply hash-map opts))]))
-(defn- as-env-string
+(defn- ^"[Ljava.lang.String;" as-env-strings
"Helper so that callers can pass a Clojure map for the :env to sh."
[arg]
(cond
@@ -116,21 +111,21 @@ collecting its stdout"}
[& args]
(let [[cmd opts] (parse-args args)
proc (.exec (Runtime/getRuntime)
- (into-array cmd)
- (as-env-string (:env opts))
+ ^"[Ljava.lang.String;" (into-array cmd)
+ (as-env-strings (:env opts))
(as-file (:dir opts)))
- in (:in opts)]
+ {:keys [in inenc outenc]} opts]
(if in
(future
(if (instance? (class (byte-array 0)) in)
(with-open [os (.getOutputStream proc)]
- (.write os in))
- (with-open [osw (OutputStreamWriter. (.getOutputStream proc) (:inenc opts))]
- (.write osw in))))
+ (.write os ^"[B" in))
+ (with-open [osw (OutputStreamWriter. (.getOutputStream proc) ^String inenc)]
+ (.write osw ^String in))))
(.close (.getOutputStream proc)))
(with-open [stdout (.getInputStream proc)
stderr (.getErrorStream proc)]
- (let [out (stream-to-enc stdout (:outenc opts))
+ (let [out (stream-to-enc stdout outenc)
err (stream-to-string stderr)
exit-code (.waitFor proc)]
{:exit exit-code :out out :err err}))))