Bug 294057 - [1.5][compiler] Imports not resolved correctly with generics and inner interfaces
Summary: [1.5][compiler] Imports not resolved correctly with generics and inner interf...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.5   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.6 M6   Edit
Assignee: Srikanth Sankaran CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 322177 (view as bug list)
Depends on:
Blocks:
 
Reported: 2009-11-03 08:45 EST by Martin Nilsson CLA
Modified: 2010-08-09 22:43 EDT (History)
5 users (show)

See Also:
jarthana: review+


Attachments
Possible patch (12.24 KB, patch)
2010-02-01 07:03 EST, Srikanth Sankaran CLA
no flags Details | Diff
Proposed patch (12.25 KB, patch)
2010-02-01 08:42 EST, 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 Martin Nilsson CLA 2009-11-03 08:45:51 EST
I'm running into a problem with an API that I'm developing that deals with generics and inner interfaces. A very simple example of the problem is the following:

SuperInterface.java:

package com.test.superint;

public interface SuperInterface<G extends SuperInterface.SuperInterfaceGetter, S extends SuperInterface.SuperInterfaceSetter> {
    public interface SuperInterfaceGetter {}

    public interface SuperInterfaceSetter {}
}

SubInterface.java:

package com.test.subint;

import com.test.superint.SuperInterface;

public interface SubInterface extends SuperInterface<SubInterface.SubInterfaceGetter, SubInterface.SubInterfaceSetter> {
    public interface SubInterfaceGetter extends SuperInterfaceGetter {}

    public interface SubInterfaceSetter extends SuperInterfaceSetter {}
}

These two classes compiles without a problem in eclipse jdt, but fails when compiling using javac or maven with the following error (using the complience level 1.5 in both environments):

test\subint\SubInterface.java:6: cannot find symbol
symbol  : class SuperInterfaceGetter
location: interface test.subint.SubInterface
    public interface SubInterfaceGetter extends SuperInterfaceGetter {}
                                                ^
test\subint\SubInterface.java:8: cannot find symbol
symbol  : class SuperInterfaceSetter
location: interface test.subint.SubInterface
    public interface SubInterfaceSetter extends SuperInterfaceSetter {}
                                                ^
test\subint\SubInterface.java:5: type parameter test.subint.SubInterface.SubInterfaceGetter is not within its bound
public interface SubInterface extends SuperInterface<SubInterface.SubInterfaceGetter, SubInterface.SubInterfaceSetter> {
                                                                 ^
test\subint\SubInterface.java:5: type parameter test.subint.SubInterface.SubInterfaceSetter is not within its bound
public interface SubInterface extends SuperInterface<SubInterface.SubInterfaceGetter, SubInterface.SubInterfaceSetter> {
                                                                                                  ^
4 errors

To make it compile outside of eclipse, I have to add two imports to the interface SubInterface.java:

import com.test.superint.SuperInterface.SuperInterfaceGetter;
import com.test.superint.SuperInterface.SuperInterfaceSetter;

But as soon as I do it, eclipse says these two imports are never used and remove them if the "Remove unused imports" is enabled

The only way to make the code compile in eclipse as well as javac/maven is by referring to the inner interfaces through the outer interface class:

package com.test.subint;

import com.test.superint.SuperInterface;

public interface SubInterface extends com.test.superint.SuperInterface<SubInterface.SubInterfaceGetter, SubInterface.SubInterfaceSetter> {
    public interface SubInterfaceGetter extends SuperInterface.SuperInterfaceGetter {}

    public interface SubInterfaceSetter extends SuperInterface.SuperInterfaceSetter {}
}

Additional information:
I'm using Java SDK 1.6.0_11
Comment 1 Olivier Thomann CLA 2009-11-03 09:08:41 EST
What is your build id ?
Comment 2 Martin Nilsson CLA 2009-11-04 02:24:56 EST
Build id: I20090611-1540
Comment 3 Olivier Thomann CLA 2009-12-07 11:11:30 EST
Moving to M5.
Comment 4 Olivier Thomann CLA 2010-01-19 20:30:17 EST
Srikanth,

Any update on this?
Comment 5 Srikanth Sankaran CLA 2010-01-20 05:17:33 EST
(In reply to comment #4)
> Srikanth,
> 
> Any update on this?

Sorry, prior to leaving on vacation I had found out that this was
a regression in behavior introduced by the fix to bug# 205235.
After my return I didn't get a chance so far. I need to fix this
without reintroducing bug# 205235. I'll get on this task now.
Comment 6 Srikanth Sankaran CLA 2010-01-24 22:42:44 EST
Retargetting for M6.
Comment 7 Srikanth Sankaran CLA 2010-02-01 07:03:06 EST
Created attachment 157765 [details]
Possible patch

This patch undoes the fix for bug#205235 and refixes it
in a way that doesn't cause the current problem. This
fixes both the problems and is under test.
Comment 8 Srikanth Sankaran CLA 2010-02-01 08:42:23 EST
Created attachment 157776 [details]
Proposed patch

I like this patch better.
Comment 9 Srikanth Sankaran CLA 2010-02-01 08:43:57 EST
Jay, can you please review ? Thanks.
Comment 10 Jay Arthanareeswaran CLA 2010-02-02 04:58:13 EST
The patch looks really good.(In reply to comment #8)
> Created an attachment (id=157776) [details]
> Proposed patch
> 
> I like this patch better.

The patch looks really good to me.
Comment 11 Srikanth Sankaran CLA 2010-02-03 01:34:27 EST
Released in HEAD for 3.6M6
Comment 12 Ayushman Jain CLA 2010-03-08 04:19:11 EST
verified for 3.6M6 using build I20100305-1011.
Comment 13 Jay Arthanareeswaran CLA 2010-03-08 04:55:08 EST
Verified.
Comment 14 Srikanth Sankaran CLA 2010-08-09 22:43:41 EDT
*** Bug 322177 has been marked as a duplicate of this bug. ***