Is anybody face such problem?
Some fields marked with warning "The field is never read locally":
but when I suppress warning, it Eclipse starts claim that this is unnecessary:
As result, I can't get rid of warnings.
Eclipse SDK 3.6.2
EDITED:
The BlockBase class intended to be abstract. But adding abstract
keyword to class and changing constructor visibility to protected
doesn't change anything. I guess the real reason for this behavior that class market as private and thus compiler assumes that fields should be accessed from inside the class visibility area. It doesn't take into account, that these fields may be accessed from children, which have another visibility (public class DataBlock extends BlockBase
).
I changed BlockBase
visibility to protected
and it solved the problem. I don't like to change it to public, because it will cause that BlockBase
will be visible from outside the parent class, but changing visibility to protected
doesn't change anything, because I parent class don't have inherited classes.
But anyway, this compiler behavior is incorrect.
EDIT 2
-or-
HOW TO REPRODUCE THE PROBLEM
1. First file:
public class testClass {
private abstract class x
{
public int theProblem;
}
public class y extends x
{
}
}
2. Second file:
public class anotherClass {
public void accessToTheProblem()
{
testClass.y a = (new testClass()).new y();
a.theProblem = 5;
Log.i("TEST", "See, I can read theProblem: " + a.theProblem);
}
}
Under Eclipse SDK 3.6.2 you will see that theProblem
declaration market with Warning:
The field is never read locally