Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 318678

Summary: Enhancement request: If I declare a field and only use that field inside one method, I would like a warning that this could be a local variable instead
Product: [Eclipse Project] JDT Reporter: Lars Svensson <oxvalley>
Component: CoreAssignee: JDT-Core-Inbox <jdt-core-inbox>
Status: NEW --- QA Contact:
Severity: enhancement    
Priority: P3 CC: remy.suen, stephan.herrmann
Version: 3.7   
Target Milestone: ---   
Hardware: PC   
OS: Windows Server 2003   
Whiteboard:

Description Lars Svensson CLA 2010-07-02 04:58:33 EDT
Build Identifier: 

This could be an optional setting under Compiler-> Errors/Warnings

Reproducible: Always
Comment 1 Stephan Herrmann CLA 2010-07-04 18:30:27 EDT
This warning would only be valid if the first access to the field
within the method is a write access. If state is preserved across 
method invocations it must stay as a field.

To me this sounds like a bit too much special-case analysis for the compiler.
My 2c.