java - JML can't catch a violated precondition -


in class test i've array of 5 int named a, , method addone(int index) add 1 selected cell. wrote in jml simple precondition control index passed method. try violate precondition calling method negative index , jml can't catch error. what's wrong?

this test class:

public class test {   public int[] a;   public test(){     = new int[]{1,1,1,1,1};  }   //@ requires index>=0 && index<5;  public void addone(int index){     a[index]+=1;  } }  

and main:

public static void main(string[] args) {     test t = new test();     t.addone(-2); } 

that throw exception: java.lang.arrayindexoutofboundsexception: -2.

with jml message.


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -