Skip to content

Commit e972a17

Browse files
authored
Merge pull request #585 from sjrd/scalajs-1.11.0
Announcing Scala.js 1.11.0.
2 parents 7067046 + 08467ed commit e972a17

File tree

8 files changed

+149
-7
lines changed

8 files changed

+149
-7
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.10.1
67+
scalaJS: 1.11.0
6868
scalaJSBinary: 1
6969
scalaJS06x: 0.6.33
7070
scalaJS06xBinary: 0.6

_data/library/versions.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,4 @@
2929
- 1.6.0
3030
- 1.7.0
3131
- 1.8.0
32+
- 1.11.0
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
---
2+
layout: post
3+
title: Announcing Scala.js 1.11.0
4+
category: news
5+
tags: [releases]
6+
permalink: /news/2022/09/15/announcing-scalajs-1.11.0/
7+
---
8+
9+
10+
We are excited to announce the release of Scala.js 1.11.0!
11+
12+
This release brings a number of bug fixes and enhancements.
13+
The highlights are:
14+
15+
* Dead code elimination of unused fields, bringing code size improvements, and perhaps small performance improvements.
16+
* Checked exceptions for `StringIndexOutOfBoundsException`s: `String.charAt()`, `substring()`, and all their derivatives now report better errors in development mode.
17+
18+
Read on for more details.
19+
20+
<!--more-->
21+
22+
## Getting started
23+
24+
If you are new to Scala.js, head over to [the tutorial]({{ BASE_PATH }}/tutorial/).
25+
26+
If you need help with anything related to Scala.js, you may find our community [on Gitter](https://gitter.im/scala-js/scala-js) and [on Stack Overflow](https://stackoverflow.com/questions/tagged/scala.js).
27+
28+
Bug reports can be filed [on GitHub](https://github.com/scala-js/scala-js/issues).
29+
30+
## Release notes
31+
32+
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.
33+
34+
This is a **minor** release:
35+
36+
* It is backward binary compatible with all earlier versions in the 1.x series: libraries compiled with 1.0.x through 1.10.x can be used with 1.11.0 without change.
37+
* It is *not* forward binary compatible with 1.10.x: libraries compiled with 1.11.0 cannot be used with 1.10.x or earlier.
38+
* It is *not* entirely backward source compatible: it is not guaranteed that a codebase will compile *as is* when upgrading from 1.10.x (in particular in the presence of `-Xfatal-warnings`).
39+
40+
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.
41+
42+
## Enhancements with compatibility concerns
43+
44+
### Checked exceptions for `StringIndexOutOfBoundsException`
45+
46+
As documented in [the semantics of Scala.js]({{ BASE_PATH }}/doc/semantics.html#undefined-behaviors), `StringIndexOutOfBoundsException`s are Undefined Behavior in Scala.js,
47+
similarly to `ClassCastException`s and `ArrayIndexOutOfBoundsException`s.
48+
Prior to Scala.js 1.11.0, we made no effort internally to provide decent error messages, or any other kind of checks.
49+
50+
Starting with this release, erroneous conditions leading to a `StringIndexOutOfBoundsException` are checked in development (fastLink) mode.
51+
They will be reported as `UndefinedBehaviorError`s in fastLink mode, and unchecked in fullLink mode.
52+
53+
For `String.charAt`, this strictly improves the error message.
54+
55+
For `String.substring`, this throws in situations that previously would, by chance, succeed.
56+
**This may cause issues** in your codebase if your code unknowingly relied on the undefined behavior.
57+
For code cross-compiling on the JVM, this is unlikely to happen, as the JVM would have already thrown exceptions in those cases.
58+
59+
Like other checked behaviors, it is now possible to configure the linker so that `StringIndexOutOfBoundsException`s are *compliant*.
60+
In that case, they will be thrown as specified for the JVM, in both fastLink and fullLink.
61+
You may enable them with the following sbt setting:
62+
63+
{% highlight scala %}
64+
scalaJSLinkerConfig ~= {
65+
_.withSemantics(_.withStringIndexOutOfBounds(
66+
org.scalajs.linker.interface.CheckedBehavior.Compliant))
67+
}
68+
{% endhighlight %}
69+
70+
This may have significant performance impact in fullLink, like other compliant behaviors.
71+
72+
### The sbt setting `envVars` is taken into account
73+
74+
In sbt, the `envVars` setting of type `Map[String, String]` defines environment variables to set when running and testing an application.
75+
Until now, it was ignored by Scala.js.
76+
77+
When using `run` or `test`, the Scala.js sbt plugin will now forward the defined variables to the configured `jsEnv`.
78+
Not all `JSEnv` implementations support environment variables.
79+
If the configured `jsEnv` does not support them, and `envVars` is non-empty, an error will be reported.
80+
81+
In some cases, this may cause issues with builds that relied on `envVars` being ignored by sbt-scalajs.
82+
83+
## Improvements
84+
85+
### Unused fields are dead-code-eliminated
86+
87+
Fields of Scala classes that are never read are now dead-code-eliminated.
88+
This can bring substantial code size improvements, although the extent of which will vary with the codebases.
89+
90+
As all other optimizations performed by Scala.js, this is a semantics-preserving transformation.
91+
The initial value of the field, as well as any other assignments to it, are still evaluated for their side effects.
92+
That code can only be removed if the optimizer can prove that it is pure.
93+
94+
## Miscellaneous
95+
96+
### New JDK APIs
97+
98+
* The method `java.net.URLDecoder(String, Charset)` was added, to complement the existing overloads.
99+
* The class `java.net.URLEncoder` was added.
100+
101+
### Independent `scalajs-javalib.jar`
102+
103+
Prior to Scala.js 1.11.0, the implementation of the `java.*` classes supported by the core were bundled inside the `scalajs-library_2.x.jar` artifact.
104+
This was necessary because they internally referred to features of the Scala- and Scala.js standard libraries.
105+
106+
Starting with Scala.js 1.11.0, our implementation of the `java.*` classes is self-contained.
107+
Therefore, they are extracted in a unique new artifact `scalajs-javalib.jar`.
108+
The various `scalajs-library_2.x.jar`s depend on `scalajs-javalib.jar`, so this change should be transparent for most users.
109+
110+
If you have a special use case where you directly look inside `scalajs-library_2.x.jar` and expect to find the `java.*` classes there, you may have to adjust your code.
111+
112+
The new `scalajs-javalib.jar` is completely Scala-agnostic, and the Scala.js IR (stored in `.sjsir` files) as well.
113+
Therefore, this jar could be used by other languages targeting JavaScript from a JVM-like language without depending on Scala, if they compile to the Scala.js IR.
114+
115+
## Bug fixes
116+
117+
The following bugs have been fixed in 1.11.0:
118+
119+
* [#4726](https://github.com/scala-js/scala-js/issues/4726) `BigDecimal.floatValue()` may be 1 ULP away from the best approximation
120+
* [#4716](https://github.com/scala-js/scala-js/issues/4716) Duplicate argument name in generated JavaScript code
121+
* [#4705](https://github.com/scala-js/scala-js/issues/4705) Variable named `await` emitted in ESModule mode
122+
123+
You can find the full list [on GitHub](https://github.com/scala-js/scala-js/issues?q=is%3Aissue+milestone%3Av1.11.0+is%3Aclosed).

assets/badges/scalajs-1.11.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.11.0
9+
* [1.11.0 scalajs-library]({{ site.production_url }}/api/scalajs-library/1.11.0/scala/scalajs/js/index.html)
10+
* [1.11.0 scalajs-test-interface]({{ site.production_url }}/api/scalajs-test-interface/1.11.0/)
11+
* [1.11.0 scalajs-javalib-intf]({{ site.production_url }}/api/scalajs-javalib-intf/1.11.0/)
12+
* [1.11.0 scalajs-ir]({{ site.production_url }}/api/scalajs-ir/1.11.0/org/scalajs/ir/index.html)
13+
* [1.11.0 scalajs-linker-interface]({{ site.production_url }}/api/scalajs-linker-interface/1.11.0/org/scalajs/linker/interface/index.html) ([Scala.js version]({{ site.production_url }}/api/scalajs-linker-interface-js/1.11.0/org/scalajs/linker/interface/index.html))
14+
* [1.11.0 scalajs-linker]({{ site.production_url }}/api/scalajs-linker/1.11.0/org/scalajs/linker/index.html) ([Scala.js version]({{ site.production_url }}/api/scalajs-linker-js/1.11.0/org/scalajs/linker/index.html))
15+
* [1.11.0 scalajs-test-adapter]({{ site.production_url }}/api/scalajs-sbt-test-adapter/1.11.0/org/scalajs/testing/adapter/index.html)
16+
* [1.11.0 sbt-scalajs]({{ site.production_url }}/api/sbt-scalajs/1.11.0/#org.scalajs.sbtplugin.package)
17+
818
### Scala.js 1.10.1
919
* [1.10.1 scalajs-library]({{ site.production_url }}/api/scalajs-library/1.10.1/scala/scalajs/js/index.html)
1020
* [1.10.1 scalajs-test-interface]({{ site.production_url }}/api/scalajs-test-interface/1.10.1/)

doc/api.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ title: Scala.js API
99

1010
* [scalajs-library]({{ site.production_url }}/api/scalajs-library/latest/scala/scalajs/js/index.html)
1111
* [scalajs-test-interface]({{ site.production_url }}/api/scalajs-test-interface/latest/)
12+
* [scalajs-javalib-intf]({{ site.production_url }}/api/scalajs-javalib-intf/latest/)
1213
* [scalajs-ir]({{ site.production_url }}/api/scalajs-ir/latest/org/scalajs/ir/index.html)
1314
* [scalajs-linker-interface]({{ site.production_url }}/api/scalajs-linker-interface/latest/org/scalajs/linker/interface/index.html) ([Scala.js version]({{ site.production_url }}/api/scalajs-linker-interface-js/latest/org/scalajs/linker/interface/index.html))
1415
* [scalajs-linker]({{ site.production_url }}/api/scalajs-linker/latest/org/scalajs/linker/index.html) ([Scala.js version]({{ site.production_url }}/api/scalajs-linker-js/latest/org/scalajs/linker/index.html))

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.11.0](/news/2022/09/15/announcing-scalajs-1.11.0/)
89
- [1.10.1](/news/2022/06/25/announcing-scalajs-1.10.1/)
910
- [1.10.0](/news/2022/04/04/announcing-scalajs-1.10.0/)
1011
- [1.9.0](/news/2022/02/14/announcing-scalajs-1.9.0/)

doc/semantics.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,24 +90,29 @@ 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-
Currently known exhaustive list of exceptions are:
93+
The relevant exceptions are:
9494

9595
* `NullPointerException`
9696
* `ArrayIndexOutOfBoundsException` and `StringIndexOutOfBoundsException`
9797
* `ClassCastException`
9898
* `ArrayStoreException`
99-
* `StackOverflowError` and other `VirtualMachineError`s
99+
* `NegativeArraySizeException`
100+
* `StackOverflowError` and `OutOfMemoryError`
100101

101102
Because Scala.js does not receive VM support to detect such erroneous
102103
conditions, checking them is typically too expensive.
103104

104105
Therefore, all of these are considered
105106
[undefined behavior](http://en.wikipedia.org/wiki/Undefined_behavior).
106107

107-
Some of these, however, can be configured to be compliant with the JVM
108-
specification using sbt settings.
109-
Currently, only `ClassCastException`s (thrown by invalid `asInstanceOf` calls) and `ArrayIndexOutOfBoundsException`s (thrown by array indexing)
110-
are configurable, but the list will probably expand in future versions.
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.
111116

112117
Every configurable undefined behavior has 3 possible modes:
113118

0 commit comments

Comments
 (0)