Community
Participate
Working Groups
Build Identifier: M20110909-1335 When a private member of a class is not used, eclipse Java editor would express it by underlining those members in yellow. Even when the private members are used by an inner class. Reproducible: Always Steps to Reproduce: "The value of the field not used" warning given for PersonListPresenter.assignedPerson PersonListPresenter.normalPerson PersonListPresenter.systemPerson But, they are indeed being used by a nested non-static class. [code] @Presenter( view = PersonListViewImpl.class ) public class PersonListPresenter extends LazyPresenter<PersonListView, AdminModuleEventBus> { static private List<Person> systemPerson; static private List<Person> normalPerson; private List<Person> assignedPerson; public enum WhichList { System, Normal, Assigned; } public class PersonListCallBack implements MethodCallback<Person> { public PersonListCallBack(WhichList whichlist) { this.whichlist = whichlist; } @Override public void onFailure(Method method, Throwable exception) { String msg = exception.getMessage(); } @Override public void onSuccess(Method method, List<Person> personList) { switch(this.whichlist) { case System: systemPerson = personList; case Normal: normalPerson = personList; case Assigned: PersonListPresenter.this.assignedPerson = personList; } } WhichList whichlist; } } [/code]
(In reply to comment #0) > Build Identifier: M20110909-1335 > > When a private member of a class is not used, eclipse Java editor would express > it by underlining those members in yellow. Even when the private members are > used by an inner class. > > Reproducible: Always > > Steps to Reproduce: > "The value of the field not used" warning given for > > PersonListPresenter.assignedPerson > PersonListPresenter.normalPerson > PersonListPresenter.systemPerson > > But, they are indeed being used by a nested non-static class. Please re-read the warning: it doesn't say that the field is not used but that the value stored in the field is never used. This seems to be true for your example, thus I intend to close as invalid unless I'm missing a relevant detail.
Warning given: The value of the local variable sortList is not used. But sortlist is used: "return sortList.get(0).isAscending()" I am interpreting that the purpose of the warning is "to help me determine that I can remove the field without causing errors". But if I follow the warning, and remove the field, certainly errors would be caused. If the purpose in life for this yellow warning is not "to help me determine that I can remove the field without causing errors", then the warning feature is useless to me and cannot be relied upon because it will be difficult for me to find all the unused entrails I might have left behind, during project clean-up. That is, I would not know if eclipse is calling wolf or a real wolf is present. [code] AsyncDataProvider<Person> dataProvider = new AsyncDataProvider<Person>() { @Override protected void onRangeChanged(HasData<Person> display) { final Range range = display.getVisibleRange(); // sortlist is underlined in yellow final ColumnSortList sortList = PersonnelTable.this.getColumnSortList(); int start = range.getStart(); int end = start + range.getLength(); Collections.sort(PersonnelTable.this.PersonnelList, new Comparator<Person>() { @Override public int compare(Person o1, Person o2) { if (o1 == o2) return 0; int diff = -1; if (o1 != null) diff = (o2 != null) ? o1.name.compareTo(o2.name) : 1; return sortList.get(0).isAscending() ? diff : -diff; } }); List<Person> dataInRange = PersonnelTable.this.PersonnelList.subList(start, end); // Push the data back into the list. PersonnelTable.this.setRowData(start, dataInRange); } }; [/code]
(In reply to comment #2) > Warning given: The value of the local variable sortList is not used. > > But sortlist is used: > "return sortList.get(0).isAscending()" This would be a bug. Using your example (and adding lots of stubs for required classes / methods) I can *only* reproduce when I set the compiler compliance to 1.5. However, in 1.5 the @Override annotation is an error (super method is from an interface). This error causes that the compiler skips analyzing the body of compare(..) so the use of sortList is not seen. As a rule of thumb: while your code contains actual errors, all warnings may be imprecise. Please fix the errors first, then the warning will go. Unless you are seeing this in code without compile errors, this is working as expected, and yes: if the warning remains after errors have been fixed, its purpose is to signal that you could safely delete the variable (as long as you keep side effects from assignments).
Two independent defects were reported (comment 0 and comment 2). Each has been explained to work as expected (comment 1 and comment 3). -> closing as INVALID.
Verified for 3.8 M5 using build id: I20120122-2000