In a previous question, Accessing scala.None from Java, it seems that people had used javap
to figure out how to access scala.None
from Java.
I'm not competing with the other answer, but since people seem often not to notice this, you can do this in the repl.
scala> :paste
// Entering paste mode (ctrl-D to finish)
object OptionTest extends App {
val x = scala.None
val y = scala.Some("asdf")
}
// Exiting paste mode, now interpreting.
defined module OptionTest
scala> :javap -v OptionTest$
Compiled from ""
public final class OptionTest$ extends java.lang.Object implements scala.App,scala.ScalaObject
SourceFile: ""
Scala: length = 0x
[lots of output etc]
public scala.None$ x();
Code:
Stack=1, Locals=1, Args_size=1
0: aload_0
1: getfield #65; //Field x:Lscala/None$;
4: areturn