How intelligent are the compilers?
I've got some lines of code like this:public Connection getConnection()throws SQLException
{
if ((iv_connection ==null) || (iv_connection.isClosed()))// !!!!!!!!
{
iv_connection = connect(iv_DBUser, iv_DBPasswort, iv_DBName);
iv_connection.setAutoCommit(false);
}
return iv_connection;
}
The problem is the if-clause. If the property iv_connection is null the rest of the clause does not have to be tested. But if it would be tested I would get a NullPointerException. The Webgain (Visual Cafe) compiler does a good job and the second part of the if-clause is not tested. But do all the other compilers do this too? I would like to be sure if the code is ok.
koem

