Bug 27241 - Missing code generation for the qualifier of a static method invocation
Summary: Missing code generation for the qualifier of a static method invocation
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 M5   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-11-27 10:08 EST by Olivier Thomann CLA
Modified: 2003-02-07 09:21 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:08:10 EST
Using 1119, we don't generate the qualifier of a static message call. This is a
bug if this qualifier can send an exception.
public class A {
	static A a = null;
	A a1 = null;
	
	public static void foo(int i) {
			System.out.print(i);
	}
	public static void main(String[] args) {
		try {
			a.a1.foo(0);
		} catch (NullPointerException e) {
			System.out.print("OK");
		}
	}
}

Compiling this code, we return:
0
instead of:
OK

because a.a1 should have thrown an NPE. Changing foo to a non static method
fixes it.
The JLS
http://java.sun.com/docs/books/jls/second_edition/html/expressions.doc.html#38359
states that if the invocation mode is static, then there is no target reference.
The expression Primary is evaluated, but the result is then discarded.
javac and jikes are compiling this code and get the right result.
Comment 1 Philipe Mulet CLA 2002-11-28 06:12:06 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 Philipe Mulet CLA 2002-11-28 06:12:19 EST
Fixed
Comment 3 Philipe Mulet CLA 2002-11-28 06:13:34 EST
Oops modified wrong bug, these comments were for bug 27247
Comment 4 Philipe Mulet CLA 2002-12-17 06:29:53 EST
Deferred to M5. Changes are quite big and too close to M4.
Need more testing.
Comment 5 Philipe Mulet CLA 2002-12-20 05:18:18 EST
Changed both field ref and qualified name ref. Added InitializationTests for 
these.

Fixed
Comment 6 David Audel CLA 2003-02-07 09:21:01 EST
Verified.