Bug 334306 - [1.7][compiler] name clash reported in javac 1.7 and not in javac 1.6
Summary: [1.7][compiler] name clash reported in javac 1.7 and not in javac 1.6
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.7   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: 3.7.1   Edit
Assignee: Srikanth Sankaran CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 322740 342819 345625 (view as bug list)
Depends on:
Blocks:
 
Reported: 2011-01-13 14:26 EST by Olivier Thomann CLA
Modified: 2011-08-05 02:54 EDT (History)
3 users (show)

See Also:


Attachments
Proposed fix (1.62 KB, patch)
2011-01-13 15:16 EST, Olivier Thomann CLA
no flags Details | Diff
All compiler test failures in compliance 1.7. (1.32 MB, text/plain)
2011-01-13 15:17 EST, Olivier Thomann CLA
no flags Details
Proposed fix + tests (17.91 KB, patch)
2011-05-16 10:33 EDT, Srikanth Sankaran CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Olivier Thomann CLA 2011-01-13 14:26:41 EST
For following code used to compile with javac 1.6, but no longer compile using javac 1.7.
This would mean that we need to use the compliance if we want to mimic the javac 1.6 behavior.

class A<T> {}
interface I {
	void foo(A<Number> p);
}
interface J extends I {
	void foo(A<Integer> p);
}

It looks like in org.eclipse.jdt.internal.compiler.lookup.MethodVerifier15.checkForNameClash(MethodBinding, MethodBinding) that the name clash check is not done for interfaces.

Such interface could only be implemented using a raw type for the parameter type.
The JLS needs to be checked regarding to this issue, but the current JDK7 build (b124) is already implementing the change.

Same thing applies to static methods:

class A<T> {}
class Super {
	void foo(A<Number> p) {}
}
class Sub extends Super {
	void foo(A<Integer> p) {}
}

This code compiles using javac 1.6, but doesn't compile anymore using javac 1.7.
Comment 1 Olivier Thomann CLA 2011-01-13 14:26:55 EST
Srikanth, please investigate.
Comment 2 Olivier Thomann CLA 2011-01-13 15:16:35 EST
Created attachment 186774 [details]
Proposed fix

This seems to do the trick. Of course some existing tests are now failing in compliance 1.7. I'll attach all the test failures in compliance 1.7.
Comment 3 Olivier Thomann CLA 2011-01-13 15:17:16 EST
Created attachment 186775 [details]
All compiler test failures in compliance 1.7.
Comment 4 Srikanth Sankaran CLA 2011-05-16 02:42:20 EDT
*** Bug 345625 has been marked as a duplicate of this bug. ***
Comment 5 Srikanth Sankaran CLA 2011-05-16 05:37:43 EDT
With the current patch, the following triggers an error while
javac7 compiles it fine:

interface I<E> {
	I<String> b();
}
interface J<E> extends I<E> {
	<U> J<String> b();
}

Needs to be investigated.

Also see https://bugs.eclipse.org/bugs/show_bug.cgi?id=322740.
Comment 6 Srikanth Sankaran CLA 2011-05-16 06:06:09 EDT
Slightly simpler case:

interface I {
	I b();
}
interface J extends I {
	J b();
}

compiles alright, while 

interface I {
	I b();
}
interface J extends I {
	<U> J b();
}

reports a name clash, javac7 compiles both alright.
Comment 7 Srikanth Sankaran CLA 2011-05-16 06:26:54 EDT
*** Bug 322740 has been marked as a duplicate of this bug. ***
Comment 8 Srikanth Sankaran CLA 2011-05-16 06:48:56 EDT
This issue has many intertwined nuances to it. In order to
preserve my sanity I'll split the issues into different bugs.
I'll keep the current one for the interface name clash case
and raise a separate one for the static method case and yet
another for the cases reported in comment# 6
Comment 9 Srikanth Sankaran CLA 2011-05-16 09:49:05 EDT
(In reply to comment #6)

The Equivalent class case (abstract and concrete both) fail too.
Raised bug 345947 to track this issue as it is unrelated to the
current problem.

>(In reply to comment #0)

> Same thing applies to static methods:

[...]

> This code compiles using javac 1.6, but doesn't compile anymore using javac
> 1.7.

Raised bug 345949 to track this case.
Comment 10 Srikanth Sankaran CLA 2011-05-16 10:33:36 EDT
Created attachment 195734 [details]
Proposed fix + tests

This fixes the interface method name clash case.
Also includes a junit test case for bug 322740.
Comment 11 Srikanth Sankaran CLA 2011-05-16 10:35:11 EDT
Fix applies for all compliance levels. But the fix is released only
in BETA_JAVA7 branch and will be seen by users only via a JDK7 compatible
release from Eclipse.
Comment 12 Srikanth Sankaran CLA 2011-05-16 10:57:39 EDT
*** Bug 342819 has been marked as a duplicate of this bug. ***
Comment 13 Satyam Kandula CLA 2011-07-01 03:17:58 EDT
Verified using Eclipse Java 7 Support(Beta) feature patch v20110623-0900.