Using Scala character character results in NoSuchMethod
I recently started using Scala. I wrote a DSL in it that can be used to describe the processing pipeline in medici . In my DSL, I used symbols to denote an anchor that can be used to place a fork (or tee, if you like) into the pipeline. Here's a small sample program that works correctly:
object Test extends PipelineBuilder {
connector("TCP") / Map("tcpProtocol" -> new DirectProtocol())
"tcp://localhost:4858" --> "ByteToStringProcessor" --> Symbol("hello")
"stdio://in?promptMessage=enter name:%20" --> Symbol("hello")
Symbol("hello") --> "SayHello" / Map("prefix" -> "\n\t") --> "stdio://out"
}
For some reason, when I use a character literal in my program, I get a NoSuchMethod exception at runtime:
java.lang.NoSuchMethodError: scala.Symbol.intern()Lscala/Symbol;
at gov.pnnl.mif.scaladsl.Test$.<init>(Test.scala:7)
at gov.pnnl.mif.scaladsl.Test$.<clinit>(Test.scala)
at gov.pnnl.mif.scaladsl.Test.main(Test.scala)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at scala.tools.nsc.ObjectRunner$$anonfun$run$1.apply(ObjectRunner.scala:75)
at scala.tools.nsc.ObjectRunner$.withContextClassLoader(ObjectRunner.scala:49)
at scala.tools.nsc.ObjectRunner$.run(ObjectRunner.scala:74)
at scala.tools.nsc.MainGenericRunner$.main(MainGenericRunner.scala:154)
at scala.tools.nsc.MainGenericRunner.main(MainGenericRunner.scala)
This happens regardless of how the symbol is used. In particular, I tried to use a symbol in a pipeline and in a simple statement println('foo)
.
The question is: what could lead to a literal simple existence symbol to cause a NoSuchMethodError? In my DSL, I use an implicit function that converts characters to instances of the Anchor class, for example:
implicit def makeAnchor(a: Symbol):Anchor = anchor(a)
Unfortunately my understanding of Scala is weak enough that I cannot think of why this might cause my NoSuchMethodError.
a source to share
The most likely explanation is that you are compiling with a different version of Scala than your classpath at runtime.
Scala runtime version check
Add to your main () method:
println(classOf[scala.Symbol].getProtectionDomain.getCodeSource)
This will tell you where you are loading the Scala library, for example:
(file: / Users / jason / usr / scala -2.8.0.RC2 / lib / scala -library.jar)
Scala time version check
to compile>I don't know how you are calling scalac. Assuming it is from the command line, run scalac -version
.
a source to share
Perhaps you have multiple versions of Scala installed, at least from 2.7.1 source (http://scala-tools.org/scaladocs/scala-library/2.7.1/Symbol.scala.html ) doesn't seem like Symbol has an intern method?
a source to share