Illustration einer tropischen Insel mit Palmen und einem hohen Berg

Java Blog für Programmierer

So etwas bei RowSetMetaDataImpl in den Sun-Quellen zu sehen tut weh

· Christian Ullenboom

Neue String-Objekte als Kopie von existierende Strings aufzubauen ist ganz schön übel. Aus javax.sql.rowset.RowSetMetaDataImpl:

public void setColumnLabel(int columnIndex, String label) throws SQLException{ checkColRange(columnIndex); if (label != null) {  colInfo[columnIndex].columnLabel = new String(label); } else {  colInfo[columnIndex].columnLabel = new String(""); }}

Wie die API-Doku zum Konsturktor so schön schreibt:

Unless an explicit copy of {@code original} is needed, use of this constructor is unnecessary since Strings are immutable.

Kategorien: Allgemein

← Alle Beiträge