Bug 27247 - Missing generation for the qualifier in 1.4 mode
Summary: Missing generation for the qualifier in 1.4 mode
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.1   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 2.1 M4   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-11-27 10:57 EST by Olivier Thomann CLA
Modified: 2002-12-17 11:52 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Olivier Thomann CLA 2002-11-27 10:57:04 EST
Using 1119, we have a case where we should throw a NPE earlier. We do it, but
too late (inside the member constructor).

class A {
	class B {
		B(int i) {
		}
	}
	public static void main(String[] args) {
		int i = 1;
		try {
			A t = null;
			t.new B(i++);
		} catch (NullPointerException e) {
			System.out.println(i);
		}
		try {
			((A) null).new B(i++);
		} catch (NullPointerException e) {
			System.out.println(i);
		}
	}
}

We generate a getClass() inside the member constructor, but it should be done
before the constructor call if we don't want the side effect on 'i' (i++). Javac
1.4.1 adds the getClass() call before the constructor call in the outer class A.
I can give the bytecodes if needed.

In this case, the expected output is:
1
1
But we have:
2
3

In 1.3 mode, we don't throw any exception at all. Javac 1.3 has the same issue.
Comment 1 Philipe Mulet CLA 2002-11-28 06:14:08 EST
Solved. Null check in 1.4 mode got moved from constructor to allocation, so it 
gets performed prior to evaluating allocation arguments (JLS 15.9.4).

Fixed. In 1.3 mode, we don't want to complain for backward compatibility (see 
bug 25174).

Comment 2 David Audel CLA 2002-12-17 11:52:29 EST
Verified.