2

I'm trying out scala.js with zio using the sample app at https://github.com/wongelz/zio-scalajs-solarsystem

as soon as I update the sbt version from 1.2.8 to 1.3.13 or 1.4.4 I'm getting the following error:

[error] Referring to non-existent method java.time.LocalTime$.NANOS_PER_SECOND()long
[error]   called from private java.time.LocalDateTime.plusWithOverflow(java.time.LocalDate,long,long,long,long,int)java.time.LocalDateTime
[error]   called from java.time.LocalDateTime.plusNanos(long)java.time.LocalDateTime
[error]   called from java.time.LocalDateTime.plus(long,java.time.temporal.TemporalUnit)java.time.LocalDateTime
[error]   called from java.time.LocalDateTime.plus(long,java.time.temporal.TemporalUnit)java.time.temporal.Temporal
[error]   called from java.time.temporal.ChronoUnit.addTo(java.time.temporal.Temporal,long)java.time.temporal.Temporal
[error]   called from java.time.OffsetDateTime.plus(long,java.time.temporal.TemporalUnit)java.time.OffsetDateTime
[error]   called from java.time.OffsetDateTime.plus(long,java.time.temporal.TemporalUnit)java.time.temporal.Temporal
[error]   called from java.time.Duration.addTo(java.time.temporal.Temporal)java.time.temporal.Temporal
[error]   called from java.time.OffsetDateTime.plus(java.time.temporal.TemporalAmount)java.time.OffsetDateTime
[error]   called from private zio.Schedule$.$anonfun$fixed$2(scala.Option,java.time.OffsetDateTime,long,java.time.Duration,long,scala.runtime.LazyRef)zio.Schedule$Decision
[error]   called from private zio.Schedule$.$anonfun$fixed$1(scala.Option,long,java.time.Duration,long,scala.runtime.LazyRef,java.time.OffsetDateTime,java.lang.Object)zio.ZIO
[error]   called from private zio.Schedule$.loop$23(scala.Option,long,long,java.time.Duration,scala.runtime.LazyRef)scala.Function2
[error]   called from zio.Schedule$.fixed(java.time.Duration)zio.Schedule
[error]   called from private SolarSystemExample$.$anonfun$run$1(SolarSystemExample$SolarSystem)zio.ZIO
[error]   called from SolarSystemExample$.run(scala.collection.immutable.List)zio.ZIO
[error]   called from private zio.App.$anonfun$main$1([java.lang.String)zio.ZIO
[error]   called from zio.App.main([java.lang.String)void
[error]   called from SolarSystemExample$.main([java.lang.String)void
[error]   called from static SolarSystemExample.main([java.lang.String)void
[error]   called from core module module initializers
[error] involving instantiated classes:
[error]   java.time.LocalDateTime
[error]   java.time.temporal.ChronoUnit
[error]   java.time.OffsetDateTime
[error]   java.time.Duration
[error]   zio.Schedule$
[error]   SolarSystemExample$

Why does this bug happen? And where should I report it?

Dominik Dorn
  • 1,820
  • 12
  • 18
  • Does `show compile:fullClasspath` report different results in any 1.3+ versus 1.2, perhaps? – sjrd Nov 29 '20 at 23:06
  • the classpaths uses the same libraries. However, I figured out that the project includes `scalajs-java-time_sjs1_2.13-1.0.0.jar` as well as `scala-java-time_sjs1_2.13-2.0.0.jar`. The `scalajs-java-time` is marked as deprecated and incomplete on github. sbt 1.2.8 places it last in the classpath, while sbt 1.3.13 places it before the 'scala-java-time' library. So I think it is picked first in sbt >1.3 and because its less complete than the 'scala-java-time' library the compiler throws an error. So classpath ordering changed between 1.2.8 and 1.3.x. I removed the scalajs-java-time and it compiles – Dominik Dorn Dec 13 '20 at 12:01

1 Answers1

1

To answer my own question (for anybody strugling with the same problem):

Make sure you don't have scalajs-java-time (1.0.0) as a dependency in your classpath. It is a incomplete library and if it is picked before scala-java-time you will receive the error posted in the question.

The reason this error occurred, was, that at least on my system, the ordering of the classpath changed from sbt 1.2.8 to sbt 1.3.x, which resulted in the scalajs-java-time library being picked before scala-java-time which resulted in the

Referring to non-existent method java.time.LocalTime$.NANOS_PER_SECOND()long

Error

Dominik Dorn
  • 1,820
  • 12
  • 18