0

I know it's supposed to work, but it doesn't. I have a class inheritance defined as follows:

public class VisitManagementForm extends FormWithTitle implements Property.ValueChangeListener {

Now it only allows to override the methods from extends, it doesn't make and indeed doesn't even allow me to implement/override methods from Property.ValueChangeListener. Why is that? I switched places of implements with extends, then only the implements worked and the extends didn't seem visible.

I recently turned the project to Maven, is it possible Maven is causing this madness? Maybe I need to specify something to allow this with it? Or am I just missing something in here?

Property.ValueChangeListener is supposed to force implement this method like this:

    @Override
public void valueChange(ValueChangeEvent event) {
    // TODO Auto-generated method stub

}

However now I get the error for it that it needs to override or implement a supertype method...

Edit: I'm using Java 1.6 for the project.

Edit: also if I try to implement something else (while leaving the extends there), it suggests me to implement the methods, but if I implement ValueChangeListener it doesn't suggest me to implement anything, but if you then remove the extends and leave just implements ValueChangeListener, it then suggest to implement it's methods again. But as long as I keep the extends, I seem to get the error mentioned above.

Arturas M
  • 4,120
  • 18
  • 50
  • 80

3 Answers3

3

Note that you cannot add the @Override annotation to a method implementing an interface in Java 5 - it generates an error. It is allowed in Java 6

Source

Community
  • 1
  • 1
Karthik T
  • 31,456
  • 5
  • 68
  • 87
2

What you are doing is illegal multiple inheritance. Check this example from of Java Language specification

Santosh
  • 17,667
  • 4
  • 54
  • 79
  • This seems like the likely answer. Assuming that FormWithTitle is a Vaadin Form subclass, it already implements Property.ValueChangeListener - simply remove "implements Property.ValueChangeListener" – GreyBeardedGeek Jan 10 '13 at 04:47
  • I don't see how this is related - the section you referenced is about inheritance from generic classes and changing their types. A hunch tells me that Karthik's answer is the correct one. – RonK Jan 10 '13 at 04:49
  • I doubt this, because when I remove implements Property.ValueChangeListener it still says the same. So I assume FormWithTitle doesn't implement Property.ValueChangeListener – Arturas M Jan 10 '13 at 05:26
  • You are right, I checked the documenation for Vaadin Form, it did implement the Property.ValueChangeListener, but I still had to clear the imports for it to work properly. – Arturas M Jan 10 '13 at 05:56
0

If this is code that worked before you switched to maven, the reason could be that the maven compiler plugin by default sets the source version to 1.5, which means, as already mentioned in another answer, you cannot use @Override for interface methods.

Henry
  • 42,982
  • 7
  • 68
  • 84
  • Uhm, well when I converted it to Maven I had problems because of that, so I had to specify it's 1.6. So it's been specified and I added the implements Property.ValueChangeListener a little later, but I was thinking maybe this could be still related. It might not be though. – Arturas M Jan 10 '13 at 05:29