Minimized code
Welcome to Scala 3.1.1 (18, Java OpenJDK 64-Bit Server VM).
Type in expressions for evaluation. Or try :help.
scala> object sun { val x = 42 }
// defined object sun
scala> import sun.x
-- [E008] Not Found Error: ---------------------------------------------------------------------------------------------
1 |import sun.x
| ^
| value x is not a member of sun
1 error found
scala> import jdk.CollectionConverters.*
-- [E008] Not Found Error: ---------------------------------------------------------------------------------------------
1 |import jdk.CollectionConverters.*
| ^^^^^^^^^^^^^^^^^^^^^^^^
| value CollectionConverters is not a member of jdk
1 error found
scala> import _root_.
<empty> dotty javax org sun
<special-ops> images jdk repl toolbarButtonGraphics
com java netscape scala xsbti
or without REPL
import scala.jdk.CollectionConverters._
// not in Scala 2/3
//import jdk.CollectionConverters._
// in Scala 2
//scalac -Yimports:java,scala,scala.Predef,scala.jdk hh.scala
//import CollectionConverters._
object HelloWorld {
def main(args: Array[String]) = {
val ss = java.util.List.of("Hello", "world")
println(ss.asScala.mkString("", ", ", "!"))
}
}
Output
Random "root" symbols on the class path (see completions above) shadow things I actually care about.
Scala 2 is divided, in that REPL at least sees the sun and not its shadow:
Welcome to Scala 2.13.8 (OpenJDK 64-Bit Server VM, Java 17.0.2).
Type in expressions for evaluation. Or try :help.
scala> object sun { val x = 42 }
object sun
scala> import sun.x
import sun.x
scala> import jdk.CollectionConverters._
^
error: object CollectionConverters is not a member of package jdk
Expectation
My expectation was that I had graduated from studying Chapter 2 of the spec.
I needed CollectionConverters for a quickie test and couldn't remember how to spell it.
_root_.jdk should be lowest-priority binding of jdk, below the root context scala that makes scala.jdk available.
Minimized code
or without REPL
Output
Random "root" symbols on the class path (see completions above) shadow things I actually care about.
Scala 2 is divided, in that REPL at least sees the
sunand not its shadow:Expectation
My expectation was that I had graduated from studying Chapter 2 of the spec.
I needed
CollectionConvertersfor a quickie test and couldn't remember how to spell it._root_.jdkshould be lowest-priority binding ofjdk, below the root contextscalathat makesscala.jdkavailable.