r/programming • u/Eirenarch • Nov 18 '13
TIL Oracle changed the internal String representation in Java 7 Update 6 increasing the running time of the substring method from constant to N
http://java-performance.info/changes-to-string-java-1-7-0_06/
1.4k
Upvotes
View all comments
Show parent comment
2
u/Eirenarch Nov 19 '13
While it is true that one behavior is not better than the other in every case one case is tested, the other is a breaking change. The fact that the documentation is incomplete is not an excuse. Now there are good excuses like "in practice this would affect almost no one while many people would benefit" but certainly you can't blame people who assumed that the behavior would stay. In fact they did not even think of it they just tested and found out that their program works as opposed to not working. If it was documented that the method runs in O(N) then I would agree that it is not a breaking change to change the implementation but it was not.
Keep in mind that I am not arguing if Oracle's decision was correct (I am perfectly sure it was) I am arguing if increasing the complexity of a method is a breaking change in general and if it should always be present in the documentation. For me this is like omitting to list the exceptions a method throws in the docs and then adding a new exception that is thrown on previously working inputs and stating that the docs did not say anything about exceptions.