Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jdt-dev] Import issues with generics and inner interfaces


Hello

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:

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

Is there a way to get the jdt compiler to behave the same way as javac?

Thanks,

Martin

This e-mail is confidential and it is intended only for the addressees. Any review, dissemination, distribution, or copying of this message by persons or entities other than the intended recipient is prohibited. If you have received this e-mail in error, kindly notify us immediately by telephone or e-mail and delete the message from your system. The sender does not accept liability for any errors or omissions in the contents of this message which may arise as a result of the e-mail transmission.


Back to the top