Skip to content

Commit 101a2e1

Browse files
authored
Update Scala Native to 0.5.4, circe-* to 0.14.9, and scala-java-time-tzdb to 2.6.0 (#1152)
1 parent e9151fc commit 101a2e1

File tree

6 files changed

+57
-34
lines changed

6 files changed

+57
-34
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ view of an error context
162162
- Support of JVMs for Java 11+ versions
163163
- Support of compilation to a native image by GraalVM
164164
- Support of Scala.js 1.0+ for all supported Scala versions
165-
- Support of Scala Native 0.4+ for all supported Scala versions
165+
- Support of Scala Native 0.5+ for all supported Scala versions
166166
- Suppressing of all WartRemover warnings of generated codecs for Scala 2.12 and 2.13
167167

168168
There are configurable options that can be set in compile-time:
@@ -215,6 +215,10 @@ supports JDK 8+ and native image compilation with earlier versions of GraalVM.
215215
The [**v2.13.3.2**](https://github.com/plokhotnyuk/jsoniter-scala/releases/tag/v2.13.3.2) release is the last version that
216216
supports Scala 2.11.
217217

218+
The [**v2.30.2**](https://github.com/plokhotnyuk/jsoniter-scala/releases/tag/v2.30.2) release is the last version that
219+
supports Scala Native 0.4+.
220+
221+
218222
For upcoming features and fixes see [Commits](https://github.com/plokhotnyuk/jsoniter-scala/commits/master)
219223
and [Issues page](https://github.com/plokhotnyuk/jsoniter-scala/issues).
220224

build.sbt

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import com.typesafe.tools.mima.core.{DirectMissingMethodProblem, ProblemFilters}
22
import org.scalajs.linker.interface.{CheckedBehavior, ESVersion}
33
import sbt.*
4+
import scala.scalanative.build.*
45
import scala.sys.process.*
56

67
lazy val oldVersion = "git describe --abbrev=0".!!.trim.replaceAll("^v", "")
@@ -66,7 +67,7 @@ lazy val jsSettings = Seq(
6667
}
6768
},
6869
libraryDependencies ++= Seq(
69-
"io.github.cquiroz" %%% "scala-java-time-tzdb" % "2.5.0" % Test
70+
"io.github.cquiroz" %%% "scala-java-time-tzdb" % "2.6.0" % Test
7071
),
7172
scalaJSLinkerConfig ~= {
7273
_.withSemantics({
@@ -88,10 +89,14 @@ lazy val jsSettings = Seq(
8889
lazy val nativeSettings = Seq(
8990
scalacOptions ++= Seq("-P:scalanative:genStaticForwardersForNonTopLevelObjects"),
9091
libraryDependencies ++= Seq(
91-
"io.github.cquiroz" %%% "scala-java-time-tzdb" % "2.5.0" % Test
92+
"io.github.cquiroz" %%% "scala-java-time-tzdb" % "2.6.0" % Test
9293
),
93-
//nativeMode := "release-full", // Uncomment and test with these options
94-
//nativeLTO := "thin",
94+
nativeConfig ~= {
95+
_.withMode(Mode.releaseFast) // TODO: test with `Mode.releaseSize` and `Mode.releaseFull`
96+
.withLTO(LTO.none)
97+
.withGC(GC.immix)
98+
},
99+
mimaPreviousArtifacts := Set(), // FIXME: remove after release with Scala Native 0.5 support
95100
coverageEnabled := false // FIXME: Unexpected linking error
96101
)
97102

@@ -152,14 +157,14 @@ lazy val `jsoniter-scala-core` = crossProject(JVMPlatform, JSPlatform, NativePla
152157
.settings(
153158
crossScalaVersions := Seq("3.3.3", "2.13.14", "2.12.19"),
154159
libraryDependencies ++= Seq(
155-
"org.scala-lang.modules" %%% "scala-collection-compat" % "2.11.0" % Test,
156-
"org.scalatestplus" %%% "scalacheck-1-17" % "3.2.18.0" % Test,
160+
"org.scala-lang.modules" %%% "scala-collection-compat" % "2.12.0" % Test,
161+
"org.scalatestplus" %%% "scalacheck-1-18" % "3.2.18.0" % Test,
157162
"org.scalatest" %%% "scalatest" % "3.2.18" % Test
158163
)
159164
)
160165
.platformsSettings(JSPlatform, NativePlatform)(
161166
libraryDependencies ++= Seq(
162-
"io.github.cquiroz" %%% "scala-java-time" % "2.5.0"
167+
"io.github.cquiroz" %%% "scala-java-time" % "2.6.0"
163168
)
164169
)
165170

@@ -186,7 +191,7 @@ lazy val `jsoniter-scala-macros` = crossProject(JVMPlatform, JSPlatform, NativeP
186191
}) ++ Seq(
187192
"com.epam.deltix" % "dfp" % "1.0.3" % Test,
188193
"org.scalatest" %%% "scalatest" % "3.2.18" % Test,
189-
"org.scala-lang.modules" %%% "scala-collection-compat" % "2.11.0" % Test
194+
"org.scala-lang.modules" %%% "scala-collection-compat" % "2.12.0" % Test
190195
)
191196
)
192197

@@ -222,8 +227,8 @@ lazy val `jsoniter-scala-circe` = crossProject(JVMPlatform, JSPlatform, NativePl
222227
.settings(
223228
crossScalaVersions := Seq("3.3.3", "2.13.14", "2.12.19"),
224229
libraryDependencies ++= Seq(
225-
"io.circe" %%% "circe-core" % "0.14.7",
226-
"io.circe" %%% "circe-parser" % "0.14.7" % Test,
230+
"io.circe" %%% "circe-core" % "0.14.9",
231+
"io.circe" %%% "circe-parser" % "0.14.9" % Test,
227232
"org.scalatest" %%% "scalatest" % "3.2.18" % Test
228233
)
229234
)
@@ -254,9 +259,9 @@ lazy val `jsoniter-scala-benchmark` = crossProject(JVMPlatform, JSPlatform)
254259
"dev.zio" %%% "zio-json" % "0.7.1",
255260
"com.evolutiongaming" %%% "play-json-jsoniter" % "0.10.3",
256261
"com.lihaoyi" %%% "upickle" % "3.3.1",
257-
"io.circe" %%% "circe-generic" % "0.14.8",
258-
"io.circe" %%% "circe-parser" % "0.14.8",
259-
"io.circe" %%% "circe-jawn" % "0.14.8",
262+
"io.circe" %%% "circe-generic" % "0.14.9",
263+
"io.circe" %%% "circe-parser" % "0.14.9",
264+
"io.circe" %%% "circe-jawn" % "0.14.9",
260265
"com.disneystreaming.smithy4s" %%% "smithy4s-json" % "0.18.23",
261266
"org.json4s" %% "json4s-jackson" % "4.1.0-M5",
262267
"org.json4s" %% "json4s-native" % "4.1.0-M5",
Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,42 @@
11
package com.github.plokhotnyuk.jsoniter_scala.core
22

3+
import scala.scalanative.annotation.alwaysinline
34
import scala.scalanative.runtime.Intrinsics._
45
import scala.scalanative.runtime.LLVMIntrinsics._
56
import scala.scalanative.runtime.RawPtr
7+
import scala.scalanative.meta.LinktimeInfo.isMultithreadingEnabled
68

79
private[core] object ByteArrayAccess {
8-
@inline
9-
private[this] def toPtr(buf: Array[Byte], pos: Int): RawPtr = elemRawPtr(castObjectToRawPtr(buf), pos + 16)
10+
// Borrowed from https://github.com/scala-native/scala-native/blob/2bb9cc6f032a5b00083d0a6bbc96aba2632f61d4/nativelib/src/main/scala/scala/scalanative/runtime/MemoryLayout.scala
11+
@alwaysinline
12+
private[this] def PtrSize: Int = castRawSizeToInt(sizeOf[RawPtr])
1013

11-
@inline
14+
@alwaysinline
15+
private[this] def ValuesOffset: Int =
16+
(if (isMultithreadingEnabled) PtrSize
17+
else 0) + PtrSize + 8
18+
19+
@alwaysinline
20+
private[this] def toPtr(buf: Array[Byte], pos: Int): RawPtr = elemRawPtr(castObjectToRawPtr(buf), pos + ValuesOffset)
21+
22+
@alwaysinline
1223
def setLong(buf: Array[Byte], pos: Int, value: Long): Unit = storeLong(toPtr(buf, pos), value)
1324

14-
@inline
25+
@alwaysinline
1526
def getLong(buf: Array[Byte], pos: Int): Long = loadLong(toPtr(buf, pos))
1627

17-
@inline
28+
@alwaysinline
1829
def setInt(buf: Array[Byte], pos: Int, value: Int): Unit = storeInt(toPtr(buf, pos), value)
1930

20-
@inline
31+
@alwaysinline
2132
def getInt(buf: Array[Byte], pos: Int): Int = loadInt(toPtr(buf, pos))
2233

23-
@inline
34+
@alwaysinline
2435
def setShort(buf: Array[Byte], pos: Int, value: Short): Unit = storeShort(toPtr(buf, pos), value)
2536

26-
@inline
37+
@alwaysinline
2738
def setLongReversed(buf: Array[Byte], pos: Int, value: Long): Unit = storeLong(toPtr(buf, pos), `llvm.bswap.i64`(value))
2839

29-
@inline
40+
@alwaysinline
3041
def getIntReversed(buf: Array[Byte], pos: Int): Int = `llvm.bswap.i32`(getInt(buf, pos))
3142
}

jsoniter-scala-core/native/src/main/scala/com/github/plokhotnyuk/jsoniter_scala/core/NativeMath.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import scala.scalanative.unsafe._
66
@extern
77
private[core] object NativeMath {
88
@name("jsoniter_scala_multiply_high")
9-
def multiplyHigh(x: CLong, y: CLong): CLong = extern
9+
def multiplyHigh(x: Long, y: Long): Long = extern
1010

1111
@name("jsoniter_scala_unsigned_multiply_high")
12-
def unsignedMultiplyHigh(x: CLong, y: CLong): CLong = extern
12+
def unsignedMultiplyHigh(x: Long, y: Long): Long = extern
1313
}

jsoniter-scala-core/shared/src/test/scala/com/github/plokhotnyuk/jsoniter_scala/core/JsonReaderSpec.scala

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -727,8 +727,9 @@ class JsonReaderSpec extends AnyWordSpec with Matchers with ScalaCheckPropertyCh
727727
}
728728
val sb = new StringBuilder
729729
sb.append('"')
730+
val l = (ReaderConfig.maxCharBufSize + 1) * 4
730731
var i = 0
731-
while (i < (ReaderConfig.maxCharBufSize + 1) * 4) {
732+
while (i < l) {
732733
sb.append('1')
733734
i += 1
734735
}
@@ -783,8 +784,9 @@ class JsonReaderSpec extends AnyWordSpec with Matchers with ScalaCheckPropertyCh
783784
checkError(""""000=!""", """expected '"', offset: 0x00000005""")
784785
val sb = new StringBuilder
785786
sb.append('"')
787+
val l = (ReaderConfig.maxCharBufSize + 1) * 3
786788
var i = 0
787-
while (i < (ReaderConfig.maxCharBufSize + 1) * 3) {
789+
while (i < l) {
788790
sb.append('1')
789791
i += 1
790792
}
@@ -1822,7 +1824,7 @@ class JsonReaderSpec extends AnyWordSpec with Matchers with ScalaCheckPropertyCh
18221824
check("2018-10-28T02:30+02:00[Europe/Warsaw]", ws)
18231825
check("2018-10-28T02:30+03:00[Europe/Warsaw]", ws)
18241826
}
1825-
forAll(genZonedDateTime, genWhitespaces, minSuccessful(10000))((x, ws) => {
1827+
forAll(genZonedDateTime, genWhitespaces, minSuccessful(100))((x, ws) => {
18261828
val s = x.toString
18271829
reader(s"""$ws"$s"""").readZonedDateTime(null) shouldBe x
18281830
reader(s"""$ws"$s":$ws""").readKeyAsZonedDateTime() shouldBe x
@@ -1938,7 +1940,7 @@ class JsonReaderSpec extends AnyWordSpec with Matchers with ScalaCheckPropertyCh
19381940
reader("null").readZoneId(default) shouldBe default
19391941
}
19401942
"parse ZoneId from a string representation according to ISO-8601 format for timezone offset or JDK format for IANA timezone identifier" in {
1941-
forAll(genZoneId, genWhitespaces, minSuccessful(10000)) { (x, ws) =>
1943+
forAll(genZoneId, genWhitespaces, minSuccessful(1000)) { (x, ws) =>
19421944
val s = x.toString
19431945
reader(s"""$ws"$s"""").readZoneId(null) shouldBe x
19441946
reader(s"""$ws"$s":""").readKeyAsZoneId() shouldBe x
@@ -2247,8 +2249,9 @@ class JsonReaderSpec extends AnyWordSpec with Matchers with ScalaCheckPropertyCh
22472249
"throw parsing exception for too long strings" in {
22482250
val sb = new StringBuilder
22492251
sb.append('"')
2252+
val l = ReaderConfig.maxCharBufSize
22502253
var i = 0
2251-
while (i < ReaderConfig.maxCharBufSize) {
2254+
while (i < l) {
22522255
sb.append(' ')
22532256
i += 1
22542257
}
@@ -2707,8 +2710,8 @@ class JsonReaderSpec extends AnyWordSpec with Matchers with ScalaCheckPropertyCh
27072710
}
27082711
"parse denormalized numbers with long mantissa and compensating exponent" in {
27092712
forAll(genWhitespaces) { ws =>
2710-
check("1" + "0" * 1000000 + "e-1000000", 1.0f, ws)
2711-
check("0." + "0" * 1000000 + "1e1000000", 0.1f, ws)
2713+
check("1" + "0" * 100000 + "e-100000", 1.0f, ws)
2714+
check("0." + "0" * 100000 + "1e100000", 0.1f, ws)
27122715
}
27132716
}
27142717
"throw parsing exception on illegal or empty input" in {
@@ -3109,7 +3112,7 @@ class JsonReaderSpec extends AnyWordSpec with Matchers with ScalaCheckPropertyCh
31093112
jsonReader.nextToken().toChar shouldBe s2.charAt(0)
31103113
}
31113114

3112-
forAll(Gen.size, minSuccessful(10000)) { n =>
3115+
forAll(Gen.size, minSuccessful(1000)) { n =>
31133116
check(n, "123456")(_.readBigInt(null))
31143117
check(n, """"UTC"""")(_.readZoneId(null))
31153118
check(n, "[true]")(_.readRawValAsBytes())

project/plugins.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "1.3.2")
44
addSbtPlugin("org.scala-js" % "sbt-jsdependencies" % "1.0.2")
55
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.16.0")
66
addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler" % "0.21.1")
7-
addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.17")
7+
addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.5.4")
88
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.11.0")
99
addSbtPlugin("com.github.sbt" % "sbt-release" % "1.4.0")
1010
addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.2.1")

0 commit comments

Comments
 (0)