diff --git a/CHANGELOG.md b/CHANGELOG.md index 1ecd5eb..97b9c61 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## 0.4.2-SNAPSHOT (20XX-XX-XX) + +* Upgrade JMH to version `1.35` +* Explicit support for JDK 15, 16, 17, and 18 +* Explicit support for Clojure 1.11 +* Improve error message when benchmark `:name` is invalid Java method identifier ([#10][issue10]) + ## 0.4.1 (2021-08-24) * Upgrade JMH to version `1.32` @@ -70,5 +77,6 @@ -[issue1]: https://github.com/jgpc42/jmh-clojure/issues/1 -[issue2]: https://github.com/jgpc42/jmh-clojure/issues/2 +[issue1]: https://github.com/jgpc42/jmh-clojure/issues/1 +[issue2]: https://github.com/jgpc42/jmh-clojure/issues/2 +[issue10]: https://github.com/jgpc42/jmh-clojure/issues/10 diff --git a/README.md b/README.md index 82abe91..04f6c3b 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ ``` -JDK versions 8 to 16 and Clojure versions 1.7 to 1.10 are currently [tested against][ci]. +JDK versions 8 to 18 and Clojure versions 1.7 to 1.11 are currently [tested against][ci]. ### What is it? @@ -133,7 +133,7 @@ Or, `lein test-all` for all supported Clojure versions. ### License -Copyright © 2017-2022 Justin Conklin +Copyright © 2017-2023 Justin Conklin Distributed under the Eclipse Public License, the same as Clojure. diff --git a/src/jmh/env.clj b/src/jmh/env.clj index 05dab99..96a5d97 100644 --- a/src/jmh/env.clj +++ b/src/jmh/env.clj @@ -168,6 +168,19 @@ (concat (->> benchmarks (remove (set warmups))) (->> warmups (map #(assoc % :warmup true)))))) +(defn- java-identifier? [^String s] + (let [xs (-> s .codePoints .iterator iterator-seq)] + (and xs + (Character/isJavaIdentifierStart ^int (first xs)) + (every? #(Character/isJavaIdentifierPart ^int %) (next xs))))) + +(defn- munge-method-suffix [b] + (let [s (munge (name (:name b (:fn b))))] + (if (or (not (:name b)) (java-identifier? s)) + s + (throw (ex-info (format "benchmark name %s, after munging, is invalid identifier" (:name b)) + {:name (:name b), :munged s}))))) + (defn finalize-benchmarks "Return the final benchmarks for running." [{resolver :jmh/resolver :as env}] @@ -176,7 +189,7 @@ finalize (fn [idx b] - (let [meth (format "_%03d_%s" idx (munge (name (:name b (:fn b))))) + (let [meth (format "_%03d_%s" idx (munge-method-suffix b)) merged (merge-options (:options b) opt-selectors opts)] (assoc b :class (:jmh/benchmark-class env) :method meth, :index idx, :options merged