Skip to content

Commit

Permalink
fix #171: ns reflection warnings, and others that are easy
Browse files Browse the repository at this point in the history
Signed-off-by: Chouser <[email protected]>
  • Loading branch information
mikehinchey authored and Chouser committed Sep 28, 2009
1 parent 110b9c2 commit 040f083
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 20 deletions.
1 change: 1 addition & 0 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
classpath="${build}:${cljsrc}"
failonerror="true">
<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"/>
Expand Down
12 changes: 7 additions & 5 deletions src/clj/clojure/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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)))

Expand Down Expand Up @@ -2976,7 +2978,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__")
Expand Down Expand Up @@ -3768,7 +3770,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
Expand Down Expand Up @@ -4443,9 +4445,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"))
Expand Down
2 changes: 1 addition & 1 deletion src/clj/clojure/core_proxy.clj
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,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
Expand Down
6 changes: 3 additions & 3 deletions src/clj/clojure/main.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)))
Expand Down
2 changes: 1 addition & 1 deletion src/clj/clojure/test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/clj/clojure/test/tap.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 9 additions & 9 deletions src/clj/clojure/xml.clj
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,22 @@
(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] []
(startElement [uri local-name q-name #^Attributes atts]
(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)
Expand All @@ -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])
Expand Down

0 comments on commit 040f083

Please sign in to comment.