Possible Bug in handling of generics

I have two classes

public interface IObservable<T>
{
     public void notifyObservers();
     public <X extends T> void notifyObservers(X arg);

}
and



public class ObservableInstance implements IObservable<String>
{
     public void notifyObservers()
    {
        if (true) throw new UnsupportedOperationException("Fix This");

    }

    public <X extends String> void notifyObservers(X arg)
    {
        if (true) throw new UnsupportedOperationException("Fix This");

    }
}


The methods in ObservableInstance  are generated by asking to implement the methods of IObservable in ObservableInstance - then
in the second notifyObservers replaging <X extends T> with <X extends String>
The line public class ObservableInstance implements IObservable<String>
is marked in red for mot implementing public <X extends T> void notifyObservers(X arg);

Is this a bug ot am I doing something wrong?????
3 comments
Comment actions Permalink

On 2/25/2010 1:09 AM, Steve Lewis wrote:

I have two classes
public interface IObservable<T>
{
      public void notifyObservers();
      public<X extends T>  void notifyObservers(X arg);

>

}
and

>

public class ObservableInstance implements IObservable<String>
{
      public void notifyObservers()
     {
         if (true) throw new UnsupportedOperationException("Fix This");

>

     }

>

     public<X extends String>  void notifyObservers(X arg)
     {
         if (true) throw new UnsupportedOperationException("Fix This");

>

     }
}

>

The methods in ObservableInstance  are generated by asking to implement the methods of IObservable in ObservableInstance - then
in the second notifyObservers replaging<X extends T>  with<X extends String>
The line public class ObservableInstance implements IObservable<String>
is marked in red for mot implementing public<X extends T>  void notifyObservers(X arg);

>

Is this a bug ot am I doing something wrong?????


Does it compile using the sun javac? If not, then you are most likely
doing something wrong. If it does compile, you may have found one of the
bugs in IDEAs generics handling.  I've seen a couple, but they are
usually not show stoppers.

Also, Java 6 and Java 5 handle strange generic situations slightly
differently, so you might try both compilers to make sure your code works.

0
Comment actions Permalink

Well the code compiles and runs correctly in  Idea 9.01 - it merely marks the class as having an error in the editor and the project -
try it - it would not take a lot of code.
I presume if your compiler can deal with the classes suns can as well

0
Comment actions Permalink

On 2/25/2010 10:07 AM, Steve Lewis wrote:

Well the code compiles and runs correctly in  Idea 9.01 - it merely marks the class as having an error in the editor and the project -
try it - it would not take a lot of code.
I presume if your compiler can deal with the classes suns can as well

I would try it, if I had 9.01 installed.

I was only trying to provide a discriminator of whether this was a bug
or not.

0

Please sign in to leave a comment.