Community
Participate
Working Groups
Build Identifier: M20090917-0800 When a superclass (e.g. 'Bar') has protected abstract methods and an unresolved import (that doesn't otherwise cause any compiler errors), the overridden methods in the sub-class get a compiler error "Cannot reduce the visibility of the inherited method from Bar", which is quite misleading. It seems that in this situation, all abstract methods in the superclass get compiled as 'public' regardless of their actual declared visibility. This can be observed by running code similar to the following: System.out.println(Modifier.isPublic(Bar.class.getDeclaredMethods()[0].getModifiers())); Reproducible: Always Steps to Reproduce: 1. Create a superclass with a compilation error: package example; import invalid.type.Name; // only error public abstract class Bar { protected abstract boolean isBaz(); } 2. Create a subclass: package example; public class Foo extends Bar { protected boolean isBaz() { return false; } } 3. Build project and observe unexpected compiler error on Foo.isBaz().
Olivier, I happened to look at this bug and I think the issue is with the following code: org.eclipse.jdt.internal.compiler.ClassFile#addAbstractMethod(AbstractMethodDeclaration, MethodBinding) This is where we mark the method with errors as public and abstract. However, I am not quite sure why it has to be made public.
Yes, I believe this is the issue. Thanks for looking at it. I'll take care of it.
Created attachment 155431 [details] Proposed fix
Released for 3.6M5. I'll add a regression test for it.
Added regression test: org.eclipse.jdt.core.tests.compiler.regression.ProblemTypeAndMethodTest#test104
Verified for 3.6M5 using build I20100122-0800.
Verified.