Include changes from clojure-1.10.3
jfacorro opened this issue Β· comments
Once #793 is done
Go over the changelog for Clojure 1.10.0-1.10.3 and apply the changes to Clojerl.
Review the code changes by checking out tag clojure-1.10.3
and then running git dif clojure-1.9.0
.
Reference:
Applicable π©
Maybe Applicable π¨
Not Applicable π₯
Changes to Clojure in Version 1.10.3
1 Changes reverted
- CLJ-2564
Improve error message for case π¨
2 Fixes
- CLJ-2453
Enable reader conditionals in Clojure prepl π¨
Changes to Clojure in Version 1.10.2
1 Dependencies
Updated dependencies:
- spec.alpha dependency to 0.2.194 - changes π©
- core.specs.alpha dependency to 0.2.56 - changes π©
2 Fixes
2.1 Interop / JVM
- CLJ-1472
Ensure monitor object is on stack, for verifiers π₯ - CLJ-2517
More fixes for invocation of static interface methods with primitive args π₯ - CLJ-2492
Remove uses of deprecated Class.newInstance() π₯ - CLJ-2534
Fix javadoc urls for JDK 11+ π₯ - CLJ-2571
Add Throwable return type hint to ex-cause π¨ - CLJ-2572
Avoid reflection in clojure.data π¨ - CLJ-2502
Fix reflection warnings in clojure.stacktrace/print-stack-trace π¨ - CLJ-2597
proxy should emit Java 1.8 bytecode π₯
2.2 Core
- CLJ-2580
Fix case expression branch analysis that resulted in compilation error π¨ - CLJ-2564
Improve error message for case π¨ - CLJ-2585
nth with not-found on regex matcher returns not-found on last group index π¨ - CLJ-1364
vector-of does not implement equals or hashing methods π₯
There is no support forvector-of
in Clojerl. - CLJ-2549
vector-of does not implement IObj for metadata π₯
There is no support forvector-of
in Clojerl. - CLJ-1187
quoted metadata on empty literal colls is lost π¨ - CLJ-2459
ExceptionInInitializerError if jars executed with java -jar π₯
2.3 Printing
- CLJ-2469
Fix errors in printing some maps with namespace syntax π© - CLJ-1445
pprint doesn't print collection metadata when*print-meta*
is true π©
2.4 Docstrings
- CLJ-2295
Eliminate duplicate doc string printing for special forms π© - CLJ-2495
prepl docstring is incorrect π© - CLJ-2169
conj has out-of-date :arglists π©
3 Performance
- CLJ-1005
Use transient map in zipmap π¨
Changes to Clojure in Version 1.10.1
1 Features and Major Changes
1.1 Workaround Java Performance Regression When Loading user.clj
Recent builds of Java 8 (u202), 11 (11.0.2), 12, and 13 included
some changes that drastically affect
optimization performance of calls from static initializers to static fields.
Clojure provides support for loading code on startup from a user.clj file and this
occurred in the static initializer of the Clojure runtime (RT) class and was thus
affected.
This issue may eventually be resolved in Java, but in Clojure we have
modified runtime initialization to avoid loading user.clj in a static
initializer, which mitigates the case where this caused a performance
degradation.
- CLJ-2484
Significant performance regression of code loaded in user.clj in Java 8u202/11.0. π₯
1.2 clojure.main Error Reporting
clojure.main is frequently used as a Clojure program launcher by external tools.
Previously, uncaught exceptions would be automatically printed by the JVM, which
would also print the stack trace.
This release will now catch exceptions and use the same error triage and printing
functionality as the Clojure repl. The full stack trace, ex-info, and other
information will be printed to a target specified by the configuration.
The three available error targets are:
- file - write to a temp file (default, falls back to stderr)
- stderr - write to stderr stream
- none - don't write
These error targets can be specified either as options to clojure.main, or as
Java system properties (flags take precedence). When invoking clojure.main
(or using the clj tool), use --report <target>
. For Java system property,
use -Dclojure.main.report=<target>
.
- CLJ-2463
Improve error printing in clojure.main with -m, -e, etc π© - CLJ-2497
Put error report location on its own line π© - CLJ-2504
Provide more options for error reporting in clojure.main π©
2 Fixes
- CLJ-2499
Some compiler expr evals report as wrong error phase π¨ - CLJ-2491
Updated fragile tests so Clojure test suite runs on Java 12 π¨
Changes to Clojure in Version 1.10
1 Compatibility and Dependencies
1.1 Java
Clojure 1.10 now requires Java 8 or above. There were a number of updates related to this change and/or Java compatibility fixes for Java 8, 9, 10, and 11:
- CLJ-2363
Bump to Java 8 as minimum requirement, update embedded ASM to 6.2,
remove reliance on jsr166 jar, update javadoc links, and remove
conditional logic. π₯ - CLJ-2367
ASM regression fix π₯ - CLJ-2284
Fix invalid bytecode generation for static interface method calls in Java 9+ π₯ - CLJ-2066
Add reflection fallback for --illegal-access warnings in Java 9+ π₯ - CLJ-2330
Fix brittle test that fails on Java 10 build due to serialization drift π₯ - CLJ-2374
Add type hint to address reflection ambiguity in JDK 11 π₯ - CLJ-2375
Fix usage of deprecated JDK apis π₯ - CLJ-2414
Regression in reflectively finding default methods π₯
1.2 Dependencies
Updated dependencies:
- spec.alpha dependency to 0.2.176 - changes π¨
- core.specs.alpha dependency to 0.2.44 - changes π¨
2 Features and major changes
2.1 Error messages
Clojure errors can occur in several distinct "phases" - reading source, macroexpansion, compilation, execution, and result printing. Clojure (and the REPL) now identify these phases in the exception and the message.
The read/macroexpand/compile phases produce a CompilerException and indicate the location in the caller source code where the problem occurred (previously macroexpansion reported the error in the macroexpansion stack). CompilerException now implements IExceptionInfo and ex-data will report exception data including the following (optional) keys:
- :clojure.error/phase - phase (:read-source, :macro-syntax-check, :macroexpansion, :compile-syntax-check, :compilation, :execution, :read-eval-result, :print-eval-result)
- :clojure.error/source - source file
- :clojure.error/line - line in source file
- :clojure.error/column - column of line in source file
- :clojure.error/symbol - symbol being macroexpanded or compiled
- :clojure.error/class - cause exception class symbol
- :clojure.error/cause - cause exception message
- :clojure.error/spec - explain-data for spec errors
clojure.main also contains two new functions: ex-triage
and ex-str
that can be used by external tools to mimic some or all of the Clojure repl reporting. ex-triage
takes the output of Throwable->map
and produces a concise analysis of the error phase, cause, etc (same keys as above). ex-str
takes that analysis data and produces a message to print at the repl.
- CLJ-2373 π©
Detect phase and overhaul exception message and printing - CLJ-2415 π©
Error cause should always be on 2nd line of error message - CLJ-2420 π©
Refinement of error phases,ex-triage
, execution error line reporting - CLJ-2427 π¨
CompilerException.toString() can throw if making message during initialization - CLJ-2430 π¨
Elevate phase in throwable data and conveyance for prepl - CLJ-2435 π¨
Include root cause class name in compilation and macroexpansion error phases - CLJ-2438 π¨
Demunge source symbol in execution error messages
2.2 Protocol extension by metadata
defprotocol
has a new option :extend-via-metadata
. When :extend-via-metadata is true, values can extend protocols by adding metadata where keys are fully-qualified protocol function symbols and values are function implementations. Protocol implementations are checked first for direct definitions (defrecord, deftype, reify), then metadata definitions, then external extensions (extend, extend-type, extend-protocol).
- Protocol extension by metadata π©
2.3 tap
tap is a shared, globally accessible system for distributing a series of informational or diagnostic values to a set of (presumably effectful) handler functions. It can be used as a better debug prn, or for facilities like logging etc.
tap>
sends a value to the set of taps. Taps can be added with add-tap
and will be called with any value sent to tap>
. The tap function may (briefly) block (e.g. for streams) and will never impede calls to tap>
, but blocking indefinitely may cause tap values to be dropped. If no taps are registered, tap>
discards. Remove taps with remove-tap
.
- tap π©
2.4 Read string capture mode
read+string
is a new function that mimics read
but also captures the string that is read and returns both the read value and the (whitespace-trimmed) read string. read+string
requires a LineNumberingPushbackReader.
- Read string capture mode π©
2.5 prepl (alpha)
prepl is a new stream-based REPL with structured output (suitable for programmatic use). Forms are read from the reader, evaluated, and return data maps for the return value (if successful), output to *out*
(possibly many), output to *err*
(possibly many), or tap> values (possibly many).
New functions in clojure.core.server:
prepl
- the replio-prepl
- a prepl bound to*in*
and*out*
suitable for use with the Clojure socket serverremote-prepl
- a prepl that can be connected to a remote prepl over a socket
prepl is alpha and subject to change.
- prepl π©
2.6 datafy and nav
clojure.datafy is a facility for object to data transformation. The datafy
and nav
functions can be used used to transform and (lazily) navigate through object graphs. The data transformation process can be influenced by consumers using protocols or metadata.
datafy is alpha and subject to change.
- CLJ-2429 π©
Datafy JavaReflector
2.6 Other new functions in core
These functions have been added to match existing functions in ClojureScript to increase the portability of error-handling code:
-
ex-cause
- extract the cause exception π¨ -
ex-message
- extract the cause message π¨
This function has been added to construct a PrintWriter implementation whose behavior on flush and close is provided as functions:
- [ ]
PrintWriter-on
- create a PrintWriter from flush-fn and close-fn π¨
The following function has been added, extending resolve
:
-
requiring-resolve
- resolve or, if needed, require symbol's namespace, then resolve π¨ -
serialized-require
- likerequire
but for use in asynchronous load uses π¨
3 Enhancements
3.1 Error messages
- CLJ-1279 π¨
Report correct arity count for function arity errors inside macros - CLJ-2386 π¨
Omit ex-info construction frames - CLJ-2394 π¨
Warn in pst that stack trace for syntax error failed before execution - CLJ-2396 π¨
Omit :in clauses when printing spec function errors if using default explain printer - CLJ-1797 π¨
Mention cljc in error when require fails - CLJ-1130
Improve error message when unable to match static method π¨
3.2 Documentation
- CLJ-2044 π¨
clojure.instant - add arglist meta for functions - CLJ-2257 π₯
proxy
- fix typo
There is noproxy
in Clojerl. - CLJ-2332 π¨
remove-tap
- fix repetition - CLJ-2122 π©
flatten
- describe result as lazy
3.3 Performance
- CLJ-1654 π¨
Reuse seq insome
- CLJ-1366 π¨
The empty map literal is read as a different map each time - CLJ-2362 π¨
with-meta
should return identity when new meta is identical to prior
3.4 Other enhancements
-
symbol
can now take a var or a keyword argument π¨ - CLJ-1209 π¨
Print ex-data in clojure.test error reports - CLJ-2163 π¨
Add test for var serialization - CLJ-2417 π¨
sort
andsort-by
should retain meta
4 Fixes
4.1 Collections
- CLJ-2297 π¨
PersistentHashMap leaks memory when keys are removed withwithout
- CLJ-1587 π¨
PersistentArrayMapβs assoc doesnβt respect HASHTABLE_THRESHOLD - CLJ-2050 π¨
Remove redundant key comparisons in HashCollisionNode - CLJ-2089 π¨
Sorted colls with default comparator donβt check that first element is Comparable
4.2 API
- CLJ-2031 π¨
clojure.walk/postwalk does not preserve MapEntry type objects - CLJ-2349 π¨
Report correct line number for uncaught ExceptionInfo in clojure.test - CLJ-1764 π¨
partition-by runs infinite loop when one element of infinite partition is accessed - CLJ-1832 π₯
unchecked-* functions have different behavior on primitive longs vs boxed Longs
Clojerl has no unchecked math.