Fix a null exception on Java 6, and improve warning message