Comments (6)
You do have Instant implementation of your own :) avdv/scalals@
main
/native/src/main/scala/javatime.scala#L7
Oh really? I totally forgot about that... 😆
Thank you @keynmol !
from scala-native.
Scala Native does not emit any Bytecode or Tasty for javalib (Java standard library) so it cannot affect compilation of Java methods. It seems like an issue in the compiler / setup, but I cannot reproduce it. Instant. ofEpochSecond
has two variants long
and long,long
, both of this are present in all JDK distributions between JDK 8 and 21.
I think that these kind of issues can only exist when there is some Bytecode for symbols defined in JDK but coming from the Scala code (eg. library dependenices, custom JDK definitions) - a that point we might get duplicated definitions for some types/methods in the compiler which might affect compilation.
I'll start with checking the dependencyTree
in sbt to check the classpath and check which dependencies can introduce duplicates. I'm aware that scala-java-time
defines java.time.Instant
, but I'm not aware how their artifacts are published
from scala-native.
Thank you for the quick response, @WojciechMazur!
I tried to create a minimal reproducer and started with sbt new scala-native/scala-native.g8
.
Basically I hit the same problem (with scala-native 0.4.16).
And even linking this simple program:
λ cat src/main/scala/Main.scala
import java.time.Instant
object Main {
def main(args: Array[String]): Unit =
println(Instant.ofEpochSecond(12345345L))
}
leads to this error:
[info] welcome to sbt 1.9.4 (N/A Java 19.0.2)
[info] loading settings for project scala-native-seed-project-build from plugins.sbt ...
[info] loading project definition from /home/claudio/code/scalals/repro-1/scala-native-seed-project/project
[info] loading settings for project scala-native-seed-project from build.sbt ...
[info] set current project to scala-native-seed-project (in build file:/home/claudio/code/scalals/repro-1/scala-native-seed-project/)
[info] sbt server started at local:///home/claudio/.sbt/1.0/server/7a16653207cb96270333/sock
[info] started sbt server
sbt:scala-native-seed-project> run
[info] compiling 1 Scala source to /home/claudio/code/scalals/repro-1/scala-native-seed-project/target/scala-3.3.3/classes ...
[warn] Found a call to not defined static method Member(Top(java.time.Instant),D13ofEpochSecondjL17java.time.InstantEo). Static methods are generated since Scala Native 0.4.3, report this bug in the Scala Native issues. Call defined at file:/home/claudio/code/scalals/repro-1/scala-native-seed-project/src/main/scala/Main.scala:5:34
[error] Found 2 missing definitions while linking
[error] Not found Top(java.time.Instant)
[error] at file:/home/claudio/code/scalals/repro-1/scala-native-seed-project/src/main/scala/Main.scala:4
[error] Not found Member(Top(java.time.Instant),D13ofEpochSecondjL17java.time.InstantEo)
[error] at file:/home/claudio/code/scalals/repro-1/scala-native-seed-project/src/main/scala/Main.scala:4
[error] at file:/home/claudio/code/scalals/repro-1/scala-native-seed-project/src/main/scala/Main.scala:5
[error] Undefined definitions found in reachability phase
[error] (Compile / nativeLink) Undefined definitions found in reachability phase
[error] Total time: 25 s, completed Mar 20, 2024, 9:00:08 PM
🤔
from scala-native.
@avdv The java.time.*
classes in general are not implemented in either Scala.js or Scala Native, given their size, complexity, and the need to handle lots of locales.
For that, you should add a dependency to a pure Scala implementation of those, such as https://github.com/cquiroz/scala-java-time
For example, here's your code in Scala CLI with this dependency:
//> using platform scala-native
//> using dep io.github.cquiroz::scala-java-time::2.5.0
import java.time.Instant
object Main {
def main(args: Array[String]): Unit =
println(Instant.ofEpochSecond(12345345L))
}
And it works fine:
> scli run .
Compiling project (Scala 3.3.1, Scala Native 0.4.17)
Compiled project (Scala 3.3.1, Scala Native 0.4.17)
[info] Linking (1193 ms)
[info] Checking intermediate code (quick) (88 ms)
[info] Discovered 1329 classes and 8939 methods
[info] Optimizing (debug mode) (1196 ms)
[info] Generating intermediate code (1133 ms)
[info] Produced 10 files
[info] Compiling to native code (1832 ms)
[info] Linking with [pthread, dl]
[info] Total (6797 ms)
1970-05-23T21:15:45Z
When that library is published for Scala Native 0.5.x (final release), you'll be able to use it in your project using SN 0.5.x
from scala-native.
@avdv The
java.time.*
classes in general are not implemented in either Scala.js or Scala Native, given their size, complexity, and the need to handle lots of locales.
Oh really ? I use java.time.Instant for quite some time now in my project (https://github.com/avdv/scalals) and as far as I can tell I don't use any external library...
from scala-native.
You do have Instant implementation of your own :) https://github.com/avdv/scalals/blob/main/native/src/main/scala/javatime.scala#L7
from scala-native.
Related Issues (20)
- Explore the possibility to emit compiler warnings for missing javalib classes HOT 1
- javalib Files#walkFileTree method has mutiple opportunities for improvement
- javalib Files#list result stream is not lazy on non-Windows
- posixlib dirent.scala is missing the declaration of POSIX readdir() HOT 1
- Static library can't use exceptions internally with GNU C++ toolchain HOT 5
- javalib Files#list result stream is not lazy on Windows
- javalib Files#list result stream is not lazy on Windows HOT 1
- javalib Files.move does not follow JVM practice when target is a directory with contents. HOT 1
- Hide/deal with posix.sys.stat as it's not binary compatible with POSIX standard HOT 4
- javalib Files#walk FileSystemLoop detection is probably wrong/broken. HOT 1
- Please take over Scala Native java.util.logging port HOT 3
- Implementations of javalib `fileKey` has at least two defects. HOT 2
- Windows javalib fileKey appears to always be NULL HOT 2
- Inline assembly support
- javalib: `java.nio.file.Files.copy(Path, Path)` should handle symbolic links
- javalib `Files.copy()` methods should use bulk read & write methods. HOT 1
- delimcc/setjmp_amd32 compilation defect HOT 6
- javalib Files#walk FileSystemLoop detection has at least two defects HOT 1
- Add missing java.net.HttpCookie HOT 1
- Support Cosmopolitan libc
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from scala-native.