Search code examples
scalaintellij-ideaassert

JVM -ea parameter ignored in Intellij


I'm working on a Scala project in IntelliJ. I'm trying to use Predef.assert.

Given the following code :

test("TEST"){
    try{
        Predef.assert(0 == 1,"test")
    }
    catch{
        case e :AssertionError => println("Catch")
    }
    println("End")
}

I create a configuration in IntelliJ with the VM option : -ea

I expect to have Catchand Endwritten in the console, but it outputs only End

The assertion is ignored, even if I enable it in the VM options of the current configuration of IntelliJ. Is there anyone who has experienced this ?

I can even see in the IntelliJ console that the parameter has been added :

"C:\Program Files\Java\jdk1.8.0_144\bin\java.exe" -ea "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2018.1.5\lib ...

How do I enable the assertions properly ?


Solution

  • Okay, after being confronted to the fact that it works with a new project (only myself to blame here, always start from scratch, as per MCVE) I started digging, and the fact is, a parameter was still laying in the file .idea/scala_compiler

    I had to remove

    <parameter value="-Xdisable-assertions" />
    

    Which obviously overtook the VM parameters.