0

I have a protected method in superclass.

package com.pts.filter
public class a {
  ...

  protected Filter callFilter(Object aInParam) {
     return Filter.LowPass;
  }
}

I am extending the class a.

package com.pts.filter.image    
public class b extends a {
  ...
  @Override
  protected Filter callFilter(Object aInParam) {
     ...
     return Filter.LowPass;
  }
}

I get a compiler error saying "The method callFilter of type b must override or implement a supertype method". I am extending class a so I don't understand why it does not see the supertype method. Is it because the method I am trying to override is protected? From my understanding protected method is visible in subclasses.

Luiggi Mendoza
  • 85,076
  • 16
  • 154
  • 332
as3rdaccount
  • 3,711
  • 12
  • 42
  • 62
  • 10
    Are you sure you are showing everything? This should compile... Unless you override _another_ class named `a` which does not have this method – fge Jul 03 '13 at 16:41
  • 2
    It looks like you have forgotten some `import` statements. Both classes are in different packages. – Uwe Plonus Jul 03 '13 at 16:43
  • As implied in other comments/answers, you're overriding a different class `a` than you think you are. Check out all your class `a`'s, and/or try overriding some other methods and see what happens. – RalphChapin Jul 03 '13 at 17:30

1 Answers1

5

My only guess why it may not be working, is wrong imports. You may be using different 'Filter' class imports in both the classes. Otherwise it is perfectly legal to override protected methods the way you have mentioned in your code.

Juned Ahsan
  • 67,789
  • 12
  • 98
  • 136
  • Used a Filter class from different type (did not know java has some built in filter class for swing UI stuff). Thats what happens when you trust the suggestion tool too much. – as3rdaccount Jul 03 '13 at 21:41