Bug 203581 - [compiler] Unnecessary code warning : default init value for class fields
Summary: [compiler] Unnecessary code warning : default init value for class fields
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.4   Edit
Hardware: PC Windows XP
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-09-17 07:41 EDT by NoName CLA
Modified: 2008-06-19 07:55 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description NoName CLA 2007-09-17 07:41:21 EDT
could you add a warning when class fields are initialized with default values, as defined in the JLS:

http://books.huihoo.org/the-java-language-specification/first-edition/4.doc.html#10931

for example:

public class Test {
  String s = null; // "= null" is useless code
}

I think a java developper should know the default values used by the compiler/the JVM and he/she should not write unnecessary code.
Comment 1 Dani Megert CLA 2008-06-19 07:55:25 EDT
>"= null" is useless code
I disagree. Sure, every developer know this but if I see this in the code I know that the developer actually really wanted 'null' as initial value. If nothing is set there's a chance that he simply forgot to set it.

==> if this check is added it should be off by default.