Bug 145203 - [comp-upgrade] Invalid null reference reported
Summary: [comp-upgrade] Invalid null reference reported
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 1.6.0 M1   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-06-03 13:16 EDT by John Pitman CLA
Modified: 2008-01-22 12:32 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description John Pitman CLA 2006-06-03 13:16:19 EDT
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);
	}
}
Comment 1 Matt Chapman CLA 2006-06-03 15:02:07 EDT
passing over to compiler
Comment 2 Andrew Clement CLA 2006-06-05 04:02:30 EDT
"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.
Comment 3 Andrew Clement CLA 2008-01-22 12:32:03 EST
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.