Question

I want to work with assertions in a Scala program. The assertions should be turned off for the final version of the program for increasing the performance.

There seem to be two Scala compiler flags enabling this (the first one requires an additional priority):

-Xelide-below
-Xdisable-assertions

However, activating those in the Scala Compiler Properties of my Scala project in Eclipse has no effect: the assertions are still executed.

The small program I used for testing:

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

I made sure the code is recompiled; I tested different (very high) priorities for -Xelide-below.

I use Eclipse Juno (4.2.0) and the Scala Plugi-In 2.1.0.nightly-2_09-201209040315-cc63a95 together with Scala 2.9.1-1 on a Windows 7 machine.

Was it helpful?

Solution

To disable assertions you should use Scala Compiler > Advanced > Xdisable-assertions.

Another way to disable them is to pass the option -Xdisable-assertions to Scala Compiler > Additional command line parameters

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top