Warum kopiert BufferedInputStream ein Feld in eine lokale Variable, anstatt das Feld direkt zu verwenden

Wenn ich den Quellcode von @ gelesen hajava.io.BufferedInputStream.getInIfOpen(), Ich bin verwirrt darüber, warum es Code wie diesen geschrieben hat:

/**
 * Check to make sure that underlying input stream has not been
 * nulled out due to close; if not return it;
 */
private InputStream getInIfOpen() throws IOException {
    InputStream input = in;
    if (input == null)
        throw new IOException("Stream closed");
    return input;
}

Warum verwendet es den Alias anstelle der Feldvariablenin direkt wie unten:

/**
 * Check to make sure that underlying input stream has not been
 * nulled out due to close; if not return it;
 */
private InputStream getInIfOpen() throws IOException {
    if (in == null)
        throw new IOException("Stream closed");
    return in;
}

Kann jemand eine vernünftige Erklärung geben?

Antworten auf die Frage(8)

Ihre Antwort auf die Frage