Community
Participate
Working Groups
When the preference : Window -> Preferences -> Java -> Compiler -> Advanced -> Local variable declaration hides another field or variable is set to warning, it highlights the parameter 'bar' of the abstract method 'foobar' in the following code : ----- BEGIN ----- 1: public abstract class Foo { 2: 3: private int bar; 4: 5: protected abstract void foobar(int bar); 6: 7: } ----- END ----- I believe that since the instance variable 'bar' will never be seen in the concretization of 'foobar' (in a subclass), the engine responsible should not issue a 'Local variable declaration hides another field or variable' warning.
I suppose we could implement the fact that methods without no body would not be flagged (abstract or native).
Something like the following?? Index: Argument.java =================================================================== RCS file: /home/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/comp iler/ast/Argument.java,v retrieving revision 1.38 diff -u -r1.38 Argument.java --- Argument.java 6 Jul 2004 11:15:03 -0000 1.38 +++ Argument.java 11 Jul 2004 22:33:23 -0000 @@ -37,6 +37,9 @@ // record the resolved type into the type reference int modifierFlag = this.modifiers; + if ((scope.getDeclarationModifiers() & (AccAbstract | AccNative)) != 0) + return; + Binding existingVariable = scope.getBinding(name, BindingIds.VARIABLE, this, false /*do not resolve hidden field*/); if (existingVariable != null && existingVariable.isValidBinding ()){ if (existingVariable instanceof LocalVariableBinding && this.hiddenVariableDepth == 0) {
or maybe, we could consider only flagging used variable declarations only.
Deferring post 3.1
As of now 'LATER' and 'REMIND' resolutions are no longer supported. Please reopen this bug if it is still valid for you.