One of the things that forced Strings to be immutable was security. You have a file open method. You pass a String to it. And then it's doing all kind of authentication checks before it gets around to doing the OS call. If you manage to do something that effectively mutated the String, after the security check and before the OS call, then boom, you're in. But Strings are immutable, so that kind of attack doesn't work. That precise example is what really demanded that Strings be immutable.
—Bill Venners. James Gosling on Java, May 2001, A Conversation with Java's Creator, James Gosling. JavaWorld, June 2001.
URL:http://www.artima.com/intv/gosling313.html. Accessed: 2011-07-07. (Archived by WebCite® at http://www.webcitation.org/5zzmtnS6b)
7 de julio de 2011
¿Por qué String es final en Java?
A veces, surge esa pregunta. Yo creo que el creador de Java, James Gosling, tiene la respuesta "final":
Suscribirse a:
Comentarios de la entrada (Atom)
No hay comentarios.:
Publicar un comentario