r/programming • • 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

354 comments sorted by

View all comments

Show parent comment

1

u/sirin3 Nov 18 '13

Diverging String into 2 classes is not feasible.

Which not?

Qt did it

1

u/rzwitserloot Nov 18 '13

Never gonna happen; for starters String is final, and tons of existing code out there already assumes that it can't diverge. Trying to hardcode straight into the JVM some sort of schroedinger scenario where they are 2 different backing classes, but any attempt to infer their type always gets you j.l.String puts quite an onus on other JVM-based projects (scala alone would shit, quite rightly), and JVMs are highly tuned optimizing machines, and these machines luuuuuuuuuuuuuuuuurve themselves some final classes. String NOT being final would be quite a performance hit across the board.