Skip to content

Commit bef58a6

Browse files
committed
Merge branch '1-12-alpha10'
2 parents 5d72829 + 0e2d12e commit bef58a6

File tree

3 files changed

+85
-2
lines changed

3 files changed

+85
-2
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
= Clojure 1.12.0-alpha10
2+
Alex Miller
3+
2024-04-28
4+
:jbake-type: post
5+
6+
= Clojure 1.12.0-alpha10
7+
Fogus
8+
2024-04-??
9+
:jbake-type: post
10+
11+
Clojure 1.12.0-alpha10 is now available! Please read the release notes below.
12+
13+
[[method_values]]
14+
== Method values
15+
16+
Clojure programmers often want to use Java methods in higher-order functions (e.g. passing a Java method to `map`). Until now, programmers have had to manually wrap methods in functions. This is verbose, and might require manual hinting for overload disambiguation, or incur incidental reflection or boxing.
17+
18+
Programmers can now use Java <clojure-1-12-alpha10#qualified_methods,qualified methods>> as ordinary functions in value contexts - the compiler will automatically generate the wrapping function. When you supply <<clojure-1-12-alpha10#param-tags,:param-tags metadata>> on a qualified method symbol, the metadata must allow the compiler to resolve the symbol to a single method at compile time.
19+
20+
New in this release: the compiler will generate a reflective call when param tags are not supplied on a qualified method that does not resolve due to overloading.
21+
22+
See: https://clojure.atlassian.net/browse/CLJ-2793[CLJ-2793], https://clojure.atlassian.net/browse/CLJ-2844[CLJ-2844], https://clojure.atlassian.net/browse/CLJ-2835[CLJ-2835]
23+
24+
[[qualified_methods]]
25+
=== Qualified methods - `Class/method`, `Class/.method`, and `Class/new`
26+
27+
Java members inherently exist in a class. For methods as values we need a way to explicitly specify the class of an instance method because there is no possibility for inference.
28+
29+
Qualified methods have value semantics when used in non-invocation positions:
30+
31+
* `Classname/method` - value is a Clojure function that invokes a static method
32+
* `Classname/.method` - value is a Clojure function that invokes an instance method
33+
* `Classname/new` - value is a Clojure function that invokes a constructor
34+
35+
New in this release: developers may use `Classname/method` and `Classname/.method` syntax to differentiate between static and instance methods.
36+
37+
Qualified method invocations with param-tags use only the tags to resolve the method. Without param-tags they behave like the equivalent dot syntax, except the qualifying class takes precedence over hints of the target object, and over its runtime type when invoked via reflection.
38+
39+
Note: Static fields are values and should be referenced without parens unless they are intended as function calls, e.g `(System/out)` should be `System/out`. Future Clojure releases will treat the field's value as something invokable and invoke it.
40+
41+
See: https://clojure.atlassian.net/browse/CLJ-2844[CLJ-2844]
42+
43+
[[param-tags]]
44+
=== :param-tags metadata
45+
46+
When used as values, qualified methods supply only the class and method name, and thus cannot resolve overloaded methods.
47+
48+
Developers can supply `:param-tags` metadata on qualified methods to specify the signature of a single desired method, 'resolving' it. The `:param-tags` metadata is a vector of zero or more tags: `[... tag ...]`. A tag is any existing valid `:tag` metadata value. Each tag corresponds to a parameter in the desired signature (arity should match the number of tags). Parameters with non-overloaded types can use the placeholder `_` in lieu of the tag.
49+
50+
A new metadata reader syntax `^[ ... ]` attaches `:param-tags` metadata to member symbols, just as `^tag` attaches `:tag` metadata to a symbol.
51+
52+
See: https://clojure.atlassian.net/browse/CLJ-2805[CLJ-2805]
53+
54+
[[array-class-syntax]]
55+
== Array class syntax
56+
57+
Clojure supports symbols naming classes both as a value (for class object) and as a type hint, but has not provided syntax for array classes other than strings.
58+
59+
Developers can now refer to an array class using a symbol of the form `ComponentClass/#dimensions`, eg `String/2` refers to the class of a 2 dimensional array of Strings. Component classes can be fully-qualified classes, imported classes, or primitives. Array class syntax can be used as both type hints and values.
60+
61+
Examples: `String/1`, `java.lang.String/1`, `long/2`.
62+
63+
See: https://clojure.atlassian.net/browse/CLJ-2807[CLJ-2807]
64+
65+
== Bug fixes
66+
67+
* https://clojure.atlassian.net/browse/CLJ-2843[CLJ-2843] - Reflective calls to Java methods that take primitive long or double now work when passed a narrower boxed number at runtime (Integer, Short, Byte, Float). Previously, these methods were not matched during reflection and an error was thrown.
68+
* https://clojure.atlassian.net/browse/CLJ-2841[CLJ-2841] - IDeref should also implement DoubleSupplier

content/releases/devchangelog.adoc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,21 @@ Note: All dev releases are subject to breaking changes for new work since the pr
1919

2020
== Release 1.12.0
2121

22+
=== 1.12.0-alpha10 (Apr 28, 2024) [[v1.12.0-alpha10]]
23+
24+
https://clojure.org/news/2024/04/28/clojure-1-12-alpha10[Release notes]
25+
26+
Features:
27+
28+
* https://clojure.atlassian.net/browse/CLJ-2807[CLJ-2807] - Array class syntax
29+
* https://clojure.atlassian.net/browse/CLJ-2844[CLJ-2844] - Qualified methods w/o param-tags may use reflection and inference
30+
* https://clojure.atlassian.net/browse/CLJ-2835[CLJ-2835] - Error message for constructor method value arity mismatch says "method" instead of "constructor"
31+
32+
Fixes:
33+
34+
* https://clojure.atlassian.net/browse/CLJ-2843[CLJ-2843] - Reflective calls to Java methods that take primitive long or double now work when passed a narrower boxed number at runtime (Integer, Short, Byte, Float). Previously, these methods were not matched during reflection and an error was thrown.
35+
* https://clojure.atlassian.net/browse/CLJ-2841[CLJ-2841] - IDeref should also implement DoubleSupplier
36+
2237
=== 1.12.0-alpha9 (Mar 8, 2024) [[v1.12.0-alpha9]]
2338

2439
Fix for CVE https://nvd.nist.gov/vuln/detail/CVE-2024-22871[CVE-2024-22871] detailed in https://github.com/advisories/GHSA-vr64-r9qj-h27f[GHSA-vr64-r9qj-h27f]:

content/releases/downloads.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ Clojure depends on Java and all Clojure code is compiled to Java 8 compatible by
5353

5454
Read the https://github.com/clojure/clojure/blob/master/changes.md[Changelog] for detailed release information.
5555

56-
== Development Release: 1.12.0-alpha9 (Mar 8, 2024)
56+
== Development Release: 1.12.0-alpha10 (Apr 28, 2024)
5757

58-
* Clojure 1.12.0-alpha9
58+
* Clojure 1.12.0-alpha10
5959
* https://search.maven.org/#search%7Cga%7C1%7Cg%3A%22org.clojure%22%20AND%20a%3A%22clojure%22%20AND%20v%3A1.12.0*[Clojure 1.12.0 pre-release builds]
6060
* <<devchangelog#,Dev changelog>>
6161
* Dependencies:

0 commit comments

Comments
 (0)