Questions tagged [scalac]

scalac - Compiler for the Scala 2 language

176 questions
0
votes
1 answer

How to compile a scala program without any builder?

I am trying to compile this simple code in scala to run it in spark: import org.apache.spark.sql.SparkSession …
HSILS
  • 11
  • 2
0
votes
0 answers

Can't add resources in jar generated by scalac

I have file in with an SQL query, which I need to run using SparkSQL. Since the file is too big, I don't want to copy it straight into the code. . ├──_main.scala ├──_resources │ └── query.sql Howewer when I compile it scalac -cp…
0
votes
0 answers

How to write scala jar executable by Java to fetch hostname of the machine?

I want to perform this activity in Scala and execute it with Java: hostname -i The scala code for this is: import java.net._ object HostName { def main(args: Array[String]){ val localhost: InetAddress = InetAddress.getLocalHost …
Aviral Srivastava
  • 4,058
  • 8
  • 29
  • 81
0
votes
1 answer

Running Scala function from command line

I'm working on an exercise. I need to create a java project that can be run from the scala command line. The final output should be this: scala> int2str(6) res0: String = six scala> int2str(65) res0: String = sixty-five How do I create a function…
0
votes
1 answer

Compiling with scalac does not find sbt dependencies

I tried running my Scala code in VSCode editor. I am able to run my script via spark-submit command. But when I am trying with scalac to compile, I am getting: .\src\main\scala\sample.scala:1: error: object apache is not a member of package…
0
votes
1 answer

Is there scala compiler option that makes ` Option[T](t).map(x => null)` return None instead of Some(null)

I've enterprise polyglot codebase which is made of java and scala. We have lot of places where we do map function on Option[T] and the mapping function is legacy code which returns null. Option(2).map(x => null) returns Some(null). when another…
user51
  • 8,843
  • 21
  • 79
  • 158
0
votes
0 answers

Scala fatal warnings but excluding deprecations flag not work

According to https://alexn.org/blog/2020/05/26/scala-fatal-warnings.html "-Wconf:cat=deprecation:ws,any:e" Will turn warnings into errors, except for deprecations. But it gives this: [error] bad option: '-Wconf:cat=deprecation:ws,any:e' [error]…
samthebest
  • 30,803
  • 25
  • 102
  • 142
0
votes
0 answers

How do I use scalac to compile a class with dependencies?

I am trying to compile the class "Example.scala" which has a dependency on the class "ProtocolLang.scala". I would like to do this without using sbt so I tried to use scalac directly on the command line. I tried making a jar from the…
0
votes
1 answer

When using a scala macro, why the compilation error stacktrace looks so incoherent?

I'd like to experiment scala on some unreliable macro. So I mimic a simple error in shapeless invocation: import shapeless.Witness val v = Witness(Random.nextInt()) Then I compile it with gradle build --info --stacktrace, expecting to find an…
tribbloid
  • 4,026
  • 14
  • 64
  • 103
0
votes
1 answer

Is it possible to turn of only a specific kind of warning in scalac?

Call me stubborn, but they can get my /: and :\ out of my cold, dead fingers. I can't wait for scala 2.14 when they are supposed to go away so that I can implement my own and get rid of the deprecation warning completely, but is there anything I can…
Turin
  • 2,208
  • 15
  • 23
0
votes
1 answer

missing or invalid dependency detected while loading class file 'SQLTestUtilsBase.class'

I am trying to write unit tests for spark scala code and I found this post: How to write unit tests in Spark 2.0+? However, when I add those dependencies I get this error when compiling: Error:scalac: missing or invalid dependency detected while…
Jared DuPont
  • 165
  • 2
  • 14
0
votes
2 answers

Does the Scala compiler try to reduce object creation between several sequential maps and flatmaps

This is a question about the Scala compiler. Let's say I have a List, and that I transform that list through several maps and flatMaps. val myList = List(1,2,3,4,5) val transformed = myList.map(_+1).map(_*2).flatmap(x=>List(x-1,x,x+1)) Let's say I…
Allen Han
  • 1,163
  • 7
  • 16
0
votes
0 answers

Fastest sorting for Vectors with small, limited number of elements

I have a immutable Vector of a class called Vector3, with max 8 elements, no matter what. I can calculate a vector3.length, which will yield a Double. My question is how to sort this Vector[Vector3] the fastest way possible. What I used until…
Markus Appel
  • 3,138
  • 1
  • 17
  • 46
0
votes
1 answer

In scala compilation, how to enable "no tail recursion option"

According to this document: https://www.scala-lang.org/old/sites/default/files/linuxsoft_archives/docu/files/tools/scalac.html I'm supposed to use "-g:notc", so I add it into my scala-maven-plugin configuration:
tribbloid
  • 4,026
  • 14
  • 64
  • 103
0
votes
1 answer

Disable value classes unwrapping

Is it possible in scala compiler to disable unwrapping of value classes? disclaimer why I need this - because of mockito failures when mocking some specific class hierarchy (Mocking case classes with primitive types)
mnowak
  • 165
  • 2
  • 11