Community
Participate
Working Groups
When the Java compiler's "null reference" error is turned on in the preferences, an error is flagged in the following class when it is in an AspectJ project. When it is in a Java project, no error is reported. The error reported is: "The variable date can only be null; it was either set to null or checked for null when last used" Here is the class: package test; import java.text.DateFormat; import java.text.ParsePosition; import java.text.SimpleDateFormat; import java.util.Date; public class Test { private static final DateFormat[] FORMATS = { new SimpleDateFormat("yyyy:MM:dd HH:mm:ss") }; public Date parse(String s) throws Exception { if (s != null) { ParsePosition pos = new ParsePosition(0); for (int i = 0; i < FORMATS.length; i++) { Date date = FORMATS[i].parse(s, pos); if (date != null) // <-- Error reported here return date; } } throw new Exception(s); } }
passing over to compiler
"null reference" appears to be a 3.2 compiler option and AspectJ is a 3.1 compiler derivative. Marking this to resolve when we move to the new compiler.
I don't know precisely which compiler option you mean - on a quick look I found 'null pointer access' and 'potential null pointer access' in eclipse 3.3. I turned both on and there is no error with AJDT1.5.2 (which has aspectj1.6.0m1 inside) - assuming fixed. please reopen if you find it is not fixed.