Skip to content

Commit 08f6857

Browse files
committed
Announcing Scala.js 1.13.0.
1 parent a585b3d commit 08f6857

File tree

7 files changed

+156
-15
lines changed

7 files changed

+156
-15
lines changed

_config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ colors: #in hex code if not noted else
6464

6565
### VERSIONS ###
6666
versions:
67-
scalaJS: 1.12.0
67+
scalaJS: 1.13.0
6868
scalaJSBinary: 1
6969
scalaJS06x: 0.6.33
7070
scalaJS06xBinary: 0.6

_data/library/versions.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,5 @@
3030
- 1.7.0
3131
- 1.8.0
3232
- 1.11.0
33+
- 1.12.0
34+
- 1.13.0
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
---
2+
layout: post
3+
title: Announcing Scala.js 1.13.0
4+
category: news
5+
tags: [releases]
6+
permalink: /news/2023/01/26/announcing-scalajs-1.13.0/
7+
---
8+
9+
10+
We are excited to announce the release of Scala.js 1.13.0!
11+
12+
**This release drops support for Scala 2.11.**
13+
Finally, 5 years after Scala 2.11 was declared end-of-life, we decided to drop support for it in Scala.js.
14+
We also dropped support for Scala 2.12.1 (Scala 2.12.2+ is still supported, of course).
15+
16+
Other than that, this release brings a number of bug fixes and enhancements.
17+
Notably:
18+
19+
* Ability to export inner `object`s in Scala classes
20+
* Checked exceptions for `NullPointerExceptions`s
21+
* Better optimizations for exported methods and methods in JavaScript classes
22+
23+
Read on for more details.
24+
25+
<!--more-->
26+
27+
## Getting started
28+
29+
If you are new to Scala.js, head over to [the tutorial]({{ BASE_PATH }}/tutorial/).
30+
31+
If you need help with anything related to Scala.js, you may find our community [in `#scala-js` on Discord](https://discord.com/invite/scala) and [on Stack Overflow](https://stackoverflow.com/questions/tagged/scala.js).
32+
33+
Bug reports can be filed [on GitHub](https://github.com/scala-js/scala-js/issues).
34+
35+
## Release notes
36+
37+
If upgrading from Scala.js 0.6.x, make sure to read [the release notes of Scala.js 1.0.0]({{ BASE_PATH }}/news/2020/02/25/announcing-scalajs-1.0.0/) first, as they contain a host of important information, including breaking changes.
38+
39+
This is a **minor** release:
40+
41+
* It is backward binary compatible with all earlier versions in the 1.x series: libraries compiled with 1.0.x through 1.12.x can be used with 1.13.0 without change.
42+
* It is *not* forward binary compatible with 1.12.x: libraries compiled with 1.13.0 cannot be used with 1.12.x or earlier.
43+
* It is *not* entirely backward source compatible: it is not guaranteed that a codebase will compile *as is* when upgrading from 1.12.x (in particular in the presence of `-Xfatal-warnings`).
44+
45+
As a reminder, libraries compiled with 0.6.x cannot be used with Scala.js 1.x; they must be republished with 1.x first.
46+
47+
## Breaking changes
48+
49+
### Drop support for Scala 2.11 and 2.12.1
50+
51+
5 years after the end-of-life of Scala 2.11, Scala.js 1.13.0 drops its support.
52+
Support for Scala 2.11 has slowly but steadily increased in cost over the year, and we arrived at the issue that broke the proverbial camel's back.
53+
54+
We announced a [request for comments issue](https://github.com/scala-js/scala-js/issues/4759) through all our usual communication channels.
55+
It gathered by far the highest number of upvotes any Scala.js issue ever received.
56+
57+
Along with it, we dropped support for Scala 2.12.1, as it then remained the only version that does not support trailing commas.
58+
59+
## Enhancements with compatibility concerns
60+
61+
### Checked exceptions for `NullPointerException`
62+
63+
As documented in [the semantics of Scala.js]({{ BASE_PATH }}/doc/semantics.html#undefined-behaviors), `NullPointerExceptions`s are Undefined Behavior in Scala.js, similarly to `ClassCastException`s and `ArrayIndexOutOfBoundsException`s.
64+
Since Scala.js 1.12.0 added checks for `ArrayStoreException`s and `NegativeArraySizeException`s, the `NullPointerException`s were the only remaining language-mandated exceptions that did not receive checks.
65+
66+
Scala.js 1.13.0 fills that gap, and now checks `NullPointerException`s in development (fastLink) mode.
67+
As other undefined behavior errors, they will be reported as `UndefinedBehaviorError`s in fastLink mode, and unchecked in fullLink mode.
68+
69+
These additional checks can and will slow down fastLink-generated code.
70+
Benchmarks show slowdowns of anywhere between 0% and 17%.
71+
As a reminder, we expect production code to be generated with `fullLinkJS`.
72+
fullLink-generated code is not affected by the checks and therefore not subject to this performance hit.
73+
74+
In some rare situations, this may turn code that appeared to work into actively throwing an exception.
75+
76+
Like other checked behaviors, it is now possible to configure the linker so that these exceptions are *compliant*.
77+
In that case, they will be thrown as specified for the JVM, in both fastLink and fullLink.
78+
You may enable them with the following sbt settings:
79+
80+
{% highlight scala %}
81+
scalaJSLinkerConfig ~= {
82+
import org.scalajs.linker.interface.CheckedBehavior
83+
_.withSemantics(_
84+
.withNullPointers(CheckedBehavior.Compliant)
85+
)
86+
}
87+
{% endhighlight %}
88+
89+
This may have significant performance impact in fullLink, like other compliant behaviors.
90+
91+
## Improvements
92+
93+
### Export inner `object`s in Scala classes
94+
95+
Scala.js 1.13.0 allows to use `@JSExport` on `object`s that are members of Scala classes.
96+
For example:
97+
98+
{% highlight scala %}
99+
class Container {
100+
@JSExport
101+
object MemberObject
102+
}
103+
{% endhighlight %}
104+
105+
For backward compatibility, adding `@JSExportAll` on the container class does *not* automatically export its `object` members.
106+
They must be individually exported with `@JSExport`.
107+
108+
### New JDK APIs
109+
110+
This release adds support for the following JDK classes and methods:
111+
112+
* `java.util.TreeMap`
113+
* `java.nio.charset.Charset.availableCharsets()`
114+
* Default and static methods of `java.util.Comparator`
115+
* `java.util.concurrent.Flow`
116+
* `java.math.BigInteger.intValueExact()` and `longValueExact()`
117+
* Missing methods of `java.io.InputStream` and `java.io.OutputStream`
118+
119+
### Optimizations for exported methods and methods of JavaScript classes
120+
121+
Before Scala.js 1.13.0, `@JSExport`ed methods and methods within JavaScript classes (that extend `js.Any`) were not processed by our optimizer.
122+
This is now the case.
123+
124+
## Bug fixes
125+
126+
The following bugs have been fixed in 1.13.0:
127+
128+
* [#4784](https://github.com/scala-js/scala-js/issues/4784) SyntaxError on regex with an optional negative lookahead (only on JS)
129+
* [#4794](https://github.com/scala-js/scala-js/issues/4794) The output of the compiler/linker is not stable
130+
131+
You can find the full list [on GitHub](https://github.com/scala-js/scala-js/issues?q=is%3Aissue+milestone%3Av1.13.0+is%3Aclosed).

assets/badges/scalajs-1.13.0.svg

Lines changed: 1 addition & 0 deletions
Loading

doc/all-api.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@ title: All previous versions of the Scala.js API
55

66
## All previous versions of the API
77

8+
### Scala.js 1.13.0
9+
* [1.13.0 scalajs-library]({{ site.production_url }}/api/scalajs-library/1.13.0/scala/scalajs/js/index.html)
10+
* [1.13.0 scalajs-test-interface]({{ site.production_url }}/api/scalajs-test-interface/1.13.0/)
11+
* [1.13.0 scalajs-javalib-intf]({{ site.production_url }}/api/scalajs-javalib-intf/1.13.0/)
12+
* [1.13.0 scalajs-ir]({{ site.production_url }}/api/scalajs-ir/1.13.0/org/scalajs/ir/index.html)
13+
* [1.13.0 scalajs-linker-interface]({{ site.production_url }}/api/scalajs-linker-interface/1.13.0/org/scalajs/linker/interface/index.html) ([Scala.js version]({{ site.production_url }}/api/scalajs-linker-interface-js/1.13.0/org/scalajs/linker/interface/index.html))
14+
* [1.13.0 scalajs-linker]({{ site.production_url }}/api/scalajs-linker/1.13.0/org/scalajs/linker/index.html) ([Scala.js version]({{ site.production_url }}/api/scalajs-linker-js/1.13.0/org/scalajs/linker/index.html))
15+
* [1.13.0 scalajs-test-adapter]({{ site.production_url }}/api/scalajs-sbt-test-adapter/1.13.0/org/scalajs/testing/adapter/index.html)
16+
* [1.13.0 sbt-scalajs]({{ site.production_url }}/api/sbt-scalajs/1.13.0/#org.scalajs.sbtplugin.package)
17+
818
### Scala.js 1.12.0
919
* [1.12.0 scalajs-library]({{ site.production_url }}/api/scalajs-library/1.12.0/scala/scalajs/js/index.html)
1020
* [1.12.0 scalajs-test-interface]({{ site.production_url }}/api/scalajs-test-interface/1.12.0/)

doc/internals/version-history.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ title: Version history
55

66
## Version history of Scala.js
77

8+
- [1.13.0](/news/2023/01/26/announcing-scalajs-1.13.0/)
89
- [1.12.0](/news/2022/11/23/announcing-scalajs-1.12.0/)
910
- [1.11.0](/news/2022/09/15/announcing-scalajs-1.11.0/)
1011
- [1.10.1](/news/2022/06/25/announcing-scalajs-1.10.1/)

doc/semantics.md

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -92,27 +92,23 @@ The JVM is a very well specified environment, which even specifies how some
9292
bugs are reported as exceptions.
9393
The relevant exceptions are:
9494

95-
* `NullPointerException`
96-
* `ArrayIndexOutOfBoundsException` and `StringIndexOutOfBoundsException`
97-
* `ClassCastException`
98-
* `ArrayStoreException`
99-
* `NegativeArraySizeException`
100-
* `StackOverflowError` and `OutOfMemoryError`
95+
* Language errors:
96+
* `NullPointerException`
97+
* `ArrayIndexOutOfBoundsException` and `StringIndexOutOfBoundsException`
98+
* `ClassCastException`
99+
* `ArrayStoreException`
100+
* `NegativeArraySizeException`
101+
* System errors:
102+
* `StackOverflowError` and `OutOfMemoryError`
101103

102104
Because Scala.js does not receive VM support to detect such erroneous
103105
conditions, checking them is typically too expensive.
104106

105107
Therefore, all of these are considered
106108
[undefined behavior](http://en.wikipedia.org/wiki/Undefined_behavior).
107109

108-
Some of these, however, can be configured to be compliant with the JVM specification using sbt settings.
109-
Currently, they are:
110-
111-
* `ClassCastException` (thrown by invalid `asInstanceOf` calls)
112-
* `ArrayIndexOutOfBoundsException` (thrown by array indexing)
113-
* `StringIndexOutOfBoundsException` (thrown by string indexing)
114-
115-
The list will probably expand in future versions.
110+
Language errors, however, can be configured to be compliant with the JVM specification using sbt settings.
111+
System errors are not handled by Scala.js, which inherits their behavior from the host JavaScript engine.
116112

117113
Every configurable undefined behavior has 3 possible modes:
118114

0 commit comments

Comments
 (0)