Menu

#37 False Positive: DLS: Dead store to local variable

closed-wont-fix
None
5
2004-11-23
2004-10-14
Anonymous
No

This code gives a false positive for a DLS error.

import java.text.Format;
import java.text.MessageFormat;
import java.util.Date;

public final class X
{
public static void main(String[] args)
{
final String copyrightFmt = "Copyright (C)
{0,date,yyyy}, Avaya Inc.";
final Format copyrightFormatter = new
MessageFormat(copyrightFmt);

System.err.println(copyrightFormatter.format(new
Date()));
}
}

I get this error when I shouldn't get any.
EXP: DLS: Dead store to local variable in method X.main
(String[])
...
At X.java:[line 10]

Discussion

  • Nobody/Anonymous

    Logged In: NO

    This is with 0.8.5

     
  • Dave Brosius

    Dave Brosius - 2004-10-17

    Logged In: YES
    user_id=66596

    Thanks for the report. Yes this is a known problem with final
    variables. Unfortunately the byte code generated makes it
    difficult to detect live final variable stores, and the final
    attribute isn't a class file attribute. This is why the detector
    is disabled, by default.

    When i use it, i mentally ignore any reports on final variables.

     
  • David Hovemeyer

    David Hovemeyer - 2004-11-23
    • assigned_to: nobody --> daveho
    • status: open --> closed-wont-fix
     

Log in to post a comment.

MongoDB Logo MongoDB