Bug 169994 - Wrong warning "The field class.field is never read locally" for finalizer guardian
Summary: Wrong warning "The field class.field is never read locally" for finalizer gua...
Status: RESOLVED INVALID
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.3   Edit
Hardware: PC All
: P3 normal (vote)
Target Milestone: 3.3 RC4   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-01-09 13:27 EST by Robert Wenner CLA
Modified: 2007-06-22 08:51 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Robert Wenner CLA 2007-01-09 13:27:25 EST
Build ID: 3.2.1

Steps To Reproduce:
public class Foo {
    public void cleanup() {
       // ...
    }

    private final Object finalizerGuardian = new Object() {
        protected void finalize() {
            cleanup();
        }
    };
}


More information:
This is a finalizer guardian as described in Bloch's Effective Java (item 6).

There should not be a warning for this, and one cannot remove the field without any side effect as the quick fix states.
Comment 1 Jerome Lanneluc CLA 2007-06-22 08:51:24 EDT
Indeed in this code sample, field 'finalizerGuardian' is written, but it is never read. The warning looks correct to me.