Bug 207935 - [1.5][compiler] inconsistency with javac 1.5&1.6 involving parameterized invocation of non-generic method
Summary: [1.5][compiler] inconsistency with javac 1.5&1.6 involving parameterized invo...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.4   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.5 M7   Edit
Assignee: Kent Johnson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 150655 (view as bug list)
Depends on:
Blocks:
 
Reported: 2007-10-30 06:58 EDT by Maxime Daniel CLA
Modified: 2009-04-28 09:19 EDT (History)
4 users (show)

See Also:


Attachments
Proposed patch and testcase (12.87 KB, patch)
2009-03-25 13:43 EDT, Kent Johnson CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Maxime Daniel CLA 2007-10-30 06:58:00 EDT
I20071029-0010

Fup on bug 168230.

Checked that we still bark at the following at 5.0 and 6.0 compliance levels,
whereas javac does not:
public class X extends Y {
  public String foobar(String one, String two) {
    return this.<String>foobar(one, two);
  }
}
class Y {
  public <T> String foobar(String one, String two) {
    return null;
  }
}

Modified GenericTypeTest#1203 accordingly.
Comment 1 Maxime Daniel CLA 2007-10-30 07:04:44 EDT
*** Bug 150655 has been marked as a duplicate of this bug. ***
Comment 2 Philipe Mulet CLA 2007-11-09 04:30:41 EST
Strange... I was thinking it would pick the super method due to presence of generic super method, but no. When running the following, it prints "X#foobar"

There seems to be some tolerance for the fact where a super method is generic.

public class X extends Y {
	public static void main(String[] args) {
		new X().<String> foobar("1","2");
	}

	public void foobar(String one, String two) {
		System.out.println("X#foobar");
	}
}

class Y {
	public <T> void foobar(String one, String two) {
		System.out.println("Y#foobar");
	}
}
Comment 3 Philipe Mulet CLA 2007-11-09 04:32:46 EST
Indeed, the presence of a super generic method is sufficient in java5 or java6 mode to allow for unused type arguments:

i.e. the following is rejected:
public class X extends Y {
	public static void main(String[] args) {
		new X().<String> foobar("1","2");
	}

	public void foobar(String one, String two) {
		System.out.println("X#foobar");
	}
}

class Y {
	public void foobar(String one, String two) {
		System.out.println("Y#foobar");
	}
}

(only tolerated in java7)
Comment 4 Philipe Mulet CLA 2007-11-09 04:35:54 EST
Kent - maybe now is the time to introduce a link from a method to its super method.
Comment 5 Kent Johnson CLA 2009-02-03 15:00:50 EST
Actually the super method is not needed at all. With this case:

class X {
	void foobar(String one, String two) {}
	void test(X x) {
		x.<String>foobar("1", "2");
	}
}

Only javac 7 compiles without an error or warning. 1.5 & 6 complain.

Philippe - I think we should just remove our error to be compatible with 7
Comment 6 Kent Johnson CLA 2009-03-25 13:43:32 EDT
Created attachment 129870 [details]
Proposed patch and testcase
Comment 7 Kent Johnson CLA 2009-03-25 16:17:37 EDT
Fix and test released for 3.5M7
Comment 8 Jay Arthanareeswaran CLA 2009-04-28 03:00:26 EDT
Verified for 3.5M7 using build I20090426-2000