scalascala-reflect

Strange Scala Error when Using Scala Reflect


I added a dependency to the scala reflect library version 2.11.8 to one of my existing project such that I could use TypeTag's but strangely I face some error when running. Here is my error:

Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/bin/java (0x10a3ab4c0) and /Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/jre/lib/libinstrument.dylib (0x10b4ce4e0). One of the two will be used. Which one is undefined.
Exception in thread "main" java.lang.AbstractMethodError: Method com/my/csvparser/CSVParser$.scala$App$_setter_$executionStart_$eq(J)V is abstract
    at com.my.csvparser.CSVParser$.scala$App$_setter_$executionStart_$eq(CSVParser.scala)
    at scala.App$class.$init$(App.scala:44)
    at com.my.csvparser.CSVParser$.<init>(CSVParser.scala:13)
    at com.my.csvparser.CSVParser$.<clinit>(CSVParser.scala)
    at com.my.csvparser.CSVParser.main(CSVParser.scala)

Did anyone face a similar issue? My Scala version is 2.11.8


Solution

  • It worked for me by removing object class extending App and putting all piece of code into main method means doing

    object Test {
       def main(args: Array[String]): Unit = {
      }
    }
    

    Instead of

    object Test extends App {
           
        }
    

    I am still not sure why it just worked as I am also new to scala world.