From 93e931f50da010e29e4f458edf3bcbec25a4c3b3 Mon Sep 17 00:00:00 2001
From: Mike Hinchey <hincheymg@gmail.com>
Date: Sun, 9 Aug 2009 23:43:25 -0700
Subject: [PATCH] fix #171: ns reflection warnings, and others that are easy

---
 build.xml                      |    1 +
 src/clj/clojure/core.clj       |   12 +++++++-----
 src/clj/clojure/core_proxy.clj |    2 +-
 src/clj/clojure/main.clj       |    6 +++---
 src/clj/clojure/test.clj       |    2 +-
 src/clj/clojure/test/tap.clj   |    2 +-
 src/clj/clojure/xml.clj        |   18 +++++++++---------
 7 files changed, 23 insertions(+), 20 deletions(-)

diff --git a/build.xml b/build.xml
index b37adef..df90600 100644
--- a/build.xml
+++ b/build.xml
@@ -87,6 +87,7 @@
     <java classname="clojure.lang.Compile"
           classpath="${build}:${cljsrc}">
       <sysproperty key="clojure.compile.path" value="${build}"/>
+      <!-- <sysproperty key="clojure.compile.warn-on-reflection" value="true"/> -->
       <arg value="clojure.core"/>
       <arg value="clojure.main"/>
       <arg value="clojure.set"/>
diff --git a/src/clj/clojure/core.clj b/src/clj/clojure/core.clj
index 3974204..0315bf3 100644
--- a/src/clj/clojure/core.clj
+++ b/src/clj/clojure/core.clj
@@ -357,12 +357,14 @@
 
 (defn symbol
   "Returns a Symbol with the given namespace and name."
+  {:tag clojure.lang.Symbol}
   ([name] (if (symbol? name) name (clojure.lang.Symbol/intern name)))
   ([ns name] (clojure.lang.Symbol/intern ns name)))
 
 (defn keyword
   "Returns a Keyword with the given namespace and name.  Do not use :
   in the keyword strings, it will be added automatically."
+  {:tag clojure.lang.Keyword}
   ([name] (if (keyword? name) name (clojure.lang.Keyword/intern name)))
   ([ns name] (clojure.lang.Keyword/intern ns name)))
 
@@ -2834,7 +2836,7 @@
                                 (conj (pop groups) (conj (peek groups) [k v]))
                                 (conj groups [k v])))
                             [] (partition 2 seq-exprs)))
-        err (fn [& msg] (throw (IllegalArgumentException. (apply str msg))))
+        err (fn [& msg] (throw (IllegalArgumentException. #^String (apply str msg))))
         emit-bind (fn emit-bind [[[bind expr & mod-pairs]
                                   & [[_ next-expr] :as next-groups]]]
                     (let [giter (gensym "iter__")
@@ -3589,7 +3591,7 @@
 (defmacro with-loading-context [& body]
   `((fn loading# [] 
         (. clojure.lang.Var (pushThreadBindings {clojure.lang.Compiler/LOADER  
-                                                 (-> loading# .getClass .getClassLoader)}))
+                                                 (.getClassLoader (.getClass #^Object loading#))}))
         (try
          ~@body
          (finally
@@ -4264,9 +4266,9 @@
                                            "clojure/version.properties")
       properties     (doto (new java.util.Properties) (.load version-stream))
       prop (fn [k] (.getProperty properties (str "clojure.version." k)))
-      clojure-version {:major       (Integer/valueOf (prop "major"))
-                       :minor       (Integer/valueOf (prop "minor"))
-                       :incremental (Integer/valueOf (prop "incremental"))
+      clojure-version {:major       (Integer/valueOf #^String (prop "major"))
+                       :minor       (Integer/valueOf #^String (prop "minor"))
+                       :incremental (Integer/valueOf #^String (prop "incremental"))
                        :qualifier   (prop "qualifier")}]
   (def *clojure-version* 
     (if (not (= (prop "interim") "false"))
diff --git a/src/clj/clojure/core_proxy.clj b/src/clj/clojure/core_proxy.clj
index 93e3e0b..8d03790 100644
--- a/src/clj/clojure/core_proxy.clj
+++ b/src/clj/clojure/core_proxy.clj
@@ -255,7 +255,7 @@
           pname (proxy-name super interfaces)]
       (or (RT/loadClassForName pname)
           (let [[cname bytecode] (generate-proxy super interfaces)]
-            (. (deref clojure.lang.Compiler/LOADER) (defineClass pname bytecode))))))
+            (. #^DynamicClassLoader (deref clojure.lang.Compiler/LOADER) (defineClass pname bytecode))))))
 
 (defn construct-proxy
   "Takes a proxy class and any arguments for its superclass ctor and
diff --git a/src/clj/clojure/main.clj b/src/clj/clojure/main.clj
index 58fa0a3..633c21e 100644
--- a/src/clj/clojure/main.clj
+++ b/src/clj/clojure/main.clj
@@ -93,7 +93,7 @@
 (defn- root-cause
   "Returns the initial cause of an exception or error by peeling off all of
   its wrappers"
-  [throwable]
+  [#^Throwable throwable]
   (loop [cause throwable]
     (if-let [cause (.getCause cause)]
       (recur cause)
@@ -161,7 +161,7 @@
   (let [{:keys [init need-prompt prompt flush read eval print caught]
          :or {init        #()
               need-prompt (if (instance? LineNumberingPushbackReader *in*)
-                            #(.atLineStart *in*)
+                            #(.atLineStart #^LineNumberingPushbackReader *in*)
                             #(identity true))
               prompt      repl-prompt
               flush       flush
@@ -203,7 +203,7 @@
 (defn load-script
   "Loads Clojure source from a file or resource given its path. Paths
   beginning with @ or @/ are considered relative to classpath."
-  [path]
+  [#^String path]
   (if (.startsWith path "@")
     (RT/loadResourceScript
      (.substring path (if (.startsWith path "@/") 2 1)))
diff --git a/src/clj/clojure/test.clj b/src/clj/clojure/test.clj
index 7195034..0d7c460 100644
--- a/src/clj/clojure/test.clj
+++ b/src/clj/clojure/test.clj
@@ -505,7 +505,7 @@ Chas Emerick, Allen Rohner, and Stuart Halloway",
   "Returns a vector [filename line-number] for the nth call up the
   stack."
   [n]
-  (let [s (nth (.getStackTrace (new java.lang.Throwable)) n)]
+  (let [#^StackTraceElement s (nth (.getStackTrace (new java.lang.Throwable)) n)]
     [(.getFileName s) (.getLineNumber s)]))
 
 (defn testing-vars-str
diff --git a/src/clj/clojure/test/tap.clj b/src/clj/clojure/test/tap.clj
index 6f4b57a..11550db 100644
--- a/src/clj/clojure/test/tap.clj
+++ b/src/clj/clojure/test/tap.clj
@@ -51,7 +51,7 @@
   "Prints a TAP diagnostic line.  data is a (possibly multi-line)
   string."
   [data]
-  (doseq [line (.split data "\n")]
+  (doseq [line (.split #^String data "\n")]
     (println "#" line)))
 
 (defn print-tap-pass
diff --git a/src/clj/clojure/xml.clj b/src/clj/clojure/xml.clj
index 251f16c..caac770 100644
--- a/src/clj/clojure/xml.clj
+++ b/src/clj/clojure/xml.clj
@@ -26,7 +26,7 @@
                        (assoc e :content (conj (or (:content e) []) c)))
         push-chars (fn []
                      (when (and (= *state* :chars)
-                                (some (complement #(. Character (isWhitespace %))) (str *sb*)))
+                                (some (complement #(Character/isWhitespace (char %))) (str *sb*)))
                        (set! *current* (push-content *current* (str *sb*)))))]
     (new clojure.lang.XMLHandler
          (proxy [ContentHandler] []
@@ -34,14 +34,14 @@
              (let [attrs (fn [ret i]
                            (if (neg? i)
                              ret
-                             (recur (assoc ret 
-                                           (. clojure.lang.Keyword (intern (symbol (. atts (getQName i)))))
-                                           (. atts (getValue i)))
+                             (recur (assoc ret
+                                           (clojure.lang.Keyword/intern (symbol (.getQName atts i)))
+                                           (.getValue atts (int i)))
                                     (dec i))))
-                   e (struct element 
+                   e (struct element
                              (. clojure.lang.Keyword (intern (symbol q-name)))
-                             (when (pos? (. atts (getLength)))
-                               (attrs {} (dec (. atts (getLength))))))]
+                             (when (pos? (.getLength atts))
+                               (attrs {} (dec (.getLength atts)))))]
                (push-chars)
                (set! *stack* (conj *stack* *current*))
                (set! *current* e)
@@ -53,11 +53,11 @@
              (set! *stack* (pop *stack*))
              (set! *state* :between)
              nil)
-           (characters [ch start length]
+           (characters [#^chars ch start length]
              (when-not (= *state* :chars)
                (set! *sb* (new StringBuilder)))
              (let [#^StringBuilder sb *sb*]
-               (. sb (append ch start length))
+               (.append sb ch (int start) (int length))
                (set! *state* :chars))
              nil)
            (setDocumentLocator [locator])
-- 
1.6.0.4

