I need a sort method for JML I tried bubblesort but I don't know what requires and ensures or maintaingins I need. I'm new with this language.
public class BubbleSortExample {
//@ references
static void bubbleSort(int[] arr)
{
int n = arr.length;
int temp = 0;
for(int i=0; i < n; i++)
{
for(int j=1; j < (n-i); j++)
{
if(arr[j-1] > arr[j])
{
temp = arr[j-1];
arr[j-1] = arr[j];
arr[j] = temp;
}
}
}
}
There is an example of BubbleSort from the KeY Project. You can further information on JML in the second version of the KeY Book or the JML Reference.
Note syntax and semantic of JML can be interpreted by tools differently.
Note this example seems a little bit older, as it does not rely on the theory of sequence and permutation.