Simple covariant return type

Mathieu Malaterre mathieu.malaterre at gmail.com
Wed Jun 24 13:49:01 UTC 2009


Hi there,

  I must be doing something wrong, but I do not see what is wrong with
the following piece of code (*). Is there a restriction when using ecj
as the java compiler ? This seems to be the default when upload a
package with Build-Depends: default-jdk-builddep

(*)
$ /usr/bin/javac Image.java ImageToImageFilter.java Pixmap.java
PixmapToPixmapFilter.java
----------
1. ERROR in ImageToImageFilter.java (at line 4)
	public Image GetOutput() {
	       ^^^^^
The return type is incompatible with PixmapToPixmapFilter.GetOutput()
----------
1 problem (1 error)%

With:
$ cat Image.java ImageToImageFilter.java Pixmap.java PixmapToPixmapFilter.java
public class Image extends Pixmap {
}

public class ImageToImageFilter extends PixmapToPixmapFilter {
  public Image GetOutput() {
    return new Image();
  }
}

public class Pixmap {
}

public class PixmapToPixmapFilter {
  public Pixmap GetOutput() {
    return new Pixmap();
  }
}


Thanks !
-- 
Mathieu



More information about the pkg-java-maintainers mailing list