Skip to content

Commit 7632d04

Browse files
authored
Merge pull request scala-js#598 from sjrd/scalajs-1.13.0
Announcing Scala.js 1.13.0.
2 parents a585b3d + c098138 commit 7632d04

File tree

7 files changed

+183
-17
lines changed

7 files changed

+183
-17
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: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
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 and `class`es 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+
In some rare situations, this may turn code that appeared to work into actively throwing an exception.
70+
71+
Further, these additional checks can and will slow down fastLink-generated code.
72+
Benchmarks show slowdowns of anywhere between 0% and 17%.
73+
As a reminder, we expect production code to be generated with `fullLinkJS`.
74+
fullLink-generated code is not affected by the checks and therefore not subject to this performance hit.
75+
76+
If the performance hit in `fastLinkJS` is too much to bear in your particular case, you can disable the checks even in fastLink with the following sbt setting:
77+
78+
{% highlight scala %}
79+
scalaJSLinkerConfig ~= {
80+
import org.scalajs.linker.interface.CheckedBehavior
81+
_.withSemantics(_
82+
.withNullPointers(CheckedBehavior.Unchecked)
83+
)
84+
}
85+
{% endhighlight %}
86+
87+
Like other checked behaviors, it is now possible to configure the linker so that these exceptions are *compliant*.
88+
In that case, they will be thrown as specified for the JVM, in both fastLink and fullLink.
89+
You may enable them with the following sbt settings:
90+
91+
{% highlight scala %}
92+
scalaJSLinkerConfig ~= {
93+
import org.scalajs.linker.interface.CheckedBehavior
94+
_.withSemantics(_
95+
.withNullPointers(CheckedBehavior.Compliant)
96+
)
97+
}
98+
{% endhighlight %}
99+
100+
This may have significant performance impact in fullLink, like other compliant behaviors.
101+
102+
### Changes to the IR and linker APIs
103+
104+
For tooling authors who directly manipulate the IR and linker APIs, there have been some breaking changes in that area.
105+
This is in line with our version policy for the linker APIs.
106+
107+
The most likely changes you may hit are:
108+
109+
* `ClassDef` has several distinct lists of members instead of a single `memberDefs` field.
110+
* Member defs are versioned using a dedicated `version: org.scalajs.ir.Version` instead of a `hash: Option[Hash]`.
111+
112+
## Improvements
113+
114+
### Export inner `object`s and `class`es in Scala classes
115+
116+
Scala.js 1.13.0 allows to use `@JSExport` on `object`s and `class`es that are members of Scala classes.
117+
For example:
118+
119+
{% highlight scala %}
120+
class Container {
121+
@JSExport
122+
object MemberObject
123+
124+
@JSExport
125+
class MemberClass
126+
}
127+
{% endhighlight %}
128+
129+
`@JSExportAll` on the container class now exports its `object` members, like other term members, but does not automatically export `class` members.
130+
Class members must be individually exported with `@JSExport`.
131+
132+
### New JDK APIs
133+
134+
This release adds support for the following JDK classes and methods:
135+
136+
* `java.util.TreeMap`
137+
* `java.nio.charset.Charset.availableCharsets()`
138+
* Default and static methods of `java.util.Comparator`
139+
* `java.util.concurrent.Flow`
140+
* `java.math.BigInteger.intValueExact()` and `longValueExact()`
141+
* Missing methods of `java.io.InputStream` and `java.io.OutputStream`
142+
143+
### Optimizations for exported methods and methods of JavaScript classes
144+
145+
Before Scala.js 1.13.0, `@JSExport`ed methods and methods within JavaScript classes (that extend `js.Any`) were not processed by our optimizer.
146+
This is now the case.
147+
148+
## Bug fixes
149+
150+
The following bugs have been fixed in 1.13.0:
151+
152+
* [#4784](https://github.com/scala-js/scala-js/issues/4784) SyntaxError on regex with an optional negative lookahead (only on JS)
153+
* [#4794](https://github.com/scala-js/scala-js/issues/4794) The output of the compiler/linker is not stable
154+
155+
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: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -90,29 +90,26 @@ If you are in that situation, we advise to use `Double`s instead of `Float`s as
9090

9191
The JVM is a very well specified environment, which even specifies how some
9292
bugs are reported as exceptions.
93-
The relevant exceptions are:
9493

95-
* `NullPointerException`
96-
* `ArrayIndexOutOfBoundsException` and `StringIndexOutOfBoundsException`
97-
* `ClassCastException`
98-
* `ArrayStoreException`
99-
* `NegativeArraySizeException`
100-
* `StackOverflowError` and `OutOfMemoryError`
94+
There are two groups of relevant exceptions:
95+
96+
* Exceptions thrown on unsatisfied preconditions of core language features:
97+
* `NullPointerException`
98+
* `ArrayIndexOutOfBoundsException` and `StringIndexOutOfBoundsException`
99+
* `ClassCastException`
100+
* `ArrayStoreException`
101+
* `NegativeArraySizeException`
102+
* System errors:
103+
* `StackOverflowError` and `OutOfMemoryError`
101104

102105
Because Scala.js does not receive VM support to detect such erroneous
103106
conditions, checking them is typically too expensive.
104107

105-
Therefore, all of these are considered
108+
Therefore, conditions that would throw one of these exceptions are considered
106109
[undefined behavior](http://en.wikipedia.org/wiki/Undefined_behavior).
107110

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.
111+
However, the first group can be configured to be compliant with the JVM specification using sbt settings.
112+
System errors are not handled by Scala.js, which inherits their behavior from the host JavaScript engine.
116113

117114
Every configurable undefined behavior has 3 possible modes:
118115

0 commit comments

Comments
 (0)