jeudi 30 juillet 2015

Is there any guarantee that the algorithm behind java.util.Collections.shuffle() remains unchanged in future Java releases?

Is the following programm guaranteed to produce a list with the same contents and ordering in future java releases?

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Random;

public class Test {
  public static void main(String[] args) {
    List<String> list = new ArrayList<>(Arrays.asList("A", "B", "C", "D"));
    Collections.shuffle(list, new Random(42));
  }
}

The javadoc of the java.util.Random class guarantees that it will always return the same random numbers if intialized with the same seed in all future java releases.

But are there any guarantees regarding the algorithm behind the java.util.Collections.shuffle() utility function? The Javadoc for this utility function does not say anything about this.

I need this guarantee, because I want to be sure that persisted data will not be useless with any future java release.




Aucun commentaire:

Enregistrer un commentaire