Quando leio o código-fonte do java.io.BufferedInputStream.getInIfOpen(), fico confuso sobre por que ele escreveu um código como este:
/**
* 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;
}
Por que está usando o alias em vez de usar a variável de campo indiretamente como abaixo:
/**
* 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;
}
Alguém pode dar uma explicação razoável?
ifdeclaração?
Eclipse, você não pode pausar um depurador em umaifinstrução. Pode ser um motivo para essa variável de alias. Só queria jogar isso lá fora. Eu especulo, é claro.