Bug 169994

Summary: Wrong warning "The field class.field is never read locally" for finalizer guardian
Product: [Eclipse Project] JDT Reporter: Robert Wenner <robert.wenner>
Component: CoreAssignee: JDT-Core-Inbox <jdt-core-inbox>
Status: RESOLVED INVALID QA Contact:
Severity: normal    
Priority: P3    
Version: 3.3   
Target Milestone: 3.3 RC4   
Hardware: PC   
OS: All   
Whiteboard:

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.