unreachable code

Discussion in 'Java' started by bob smith, Jul 19, 2012.

  1. bob smith

    bob smith Guest

    Is there an easy way to tell Java not to bug me about unreachable code?
     
    bob smith, Jul 19, 2012
    #1
    1. Advertising

  2. bob smith

    Arne Vajhøj Guest

    On 7/19/2012 5:50 PM, bob smith wrote:
    > Is there an easy way to tell Java not to bug me about unreachable code?


    Why not simply outcomment the unreachable code?

    Arne
     
    Arne Vajhøj, Jul 19, 2012
    #2
    1. Advertising

  3. bob smith <> wrote:
    > Is there an easy way to tell Java not to bug me about unreachable code?


    How unreachable is it?

    As I understand it, the compiler is supposed to understand

    if(false) { code }

    and even

    public static final boolean debug=false;

    if(debug) code;

    without complaint.

    (That is, the Java replacement for C's

    #if 0

    #endif
    )

    -- glen
     
    glen herrmannsfeldt, Jul 19, 2012
    #3
  4. bob smith

    Daniel Pitts Guest

    On 7/19/12 2:50 PM, bob smith wrote:
    > Is there an easy way to tell Java not to bug me about unreachable code?
    >

    Yes, you have several easy ways:

    1. Make the code reachable.
    2. Delete the unreachable code.
    3. Surround the code which *causes* the unreachability with if(true){}
    4. Comment out the unreachable code.

    All of those will tell Java not to bug you about an obvious bug in your
    code.
     
    Daniel Pitts, Jul 19, 2012
    #4
  5. bob smith

    Eric Sosman Guest

    On 7/19/2012 5:50 PM, bob smith wrote:
    > Is there an easy way to tell Java not to bug me about unreachable code?


    "Delete it" comes to mind ...

    Could you describe your situation in more detail? The
    unreachable code will never be executed; why do you wish to
    keep it around? I assume you've got some better reason than
    "I admire the sheer beauty of useless clutter;" what is it?

    --
    Eric Sosman
    d
     
    Eric Sosman, Jul 19, 2012
    #5
  6. bob smith

    Roedy Green Guest

    On Thu, 19 Jul 2012 14:50:58 -0700 (PDT), bob smith
    <> wrote, quoted or indirectly quoted someone
    who said :

    >Is there an easy way to tell Java not to bug me about unreachable code?


    Most IDES have a way to with a keystroke comment the code out. That
    way it is easy to revive it later, but has no effect on the class
    file.
    --
    Roedy Green Canadian Mind Products
    http://mindprod.com
    The greatest shortcoming of the human race is our inability to understand the exponential function.
    ~ Dr. Albert A. Bartlett (born: 1923-03-21 age: 89)
    http://www.youtube.com/watch?v=F-QA2rkpBSY
     
    Roedy Green, Jul 20, 2012
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jacob

    Re: unreachable statements

    Jacob, Aug 16, 2004, in forum: Java
    Replies:
    2
    Views:
    404
    Joona I Palaste
    Aug 16, 2004
  2. Unreachable

    , Sep 6, 2003, in forum: Python
    Replies:
    1
    Views:
    412
    Bertel Lund Hansen
    Sep 6, 2003
  3. Unreachable

    , Sep 6, 2003, in forum: Python
    Replies:
    0
    Views:
    359
  4. Gernot Frisch

    unreachable code?

    Gernot Frisch, Apr 27, 2006, in forum: C++
    Replies:
    4
    Views:
    349
    pillbug
    Apr 27, 2006
  5. Jack Bates
    Replies:
    2
    Views:
    251
    Gregory Ewing
    Apr 28, 2011
Loading...

Share This Page