ava 1.5 - generics "unchecked cast" suppression

Discussion in 'Java' started by Steven Buroff, Sep 26, 2004.

  1. Is there a way to suppress the "unchecked cast" message for a particular
    statement rather than an entire file? There are times when you can't really
    avoid the cast. In my case, I'm reading back in a previously serialized
    object. I need to cast it. Thanks in advance.

    Steve
     
    Steven Buroff, Sep 26, 2004
    #1
    1. Advertising

  2. Steven Buroff

    Paul Lutus Guest

    Steven Buroff wrote:

    > Is there a way to suppress ...


    Multiposting? No, apparently not. But stop it anyway.

    --
    Paul Lutus
    http://www.arachnoid.com
     
    Paul Lutus, Sep 26, 2004
    #2
    1. Advertising

  3. Steven Buroff

    Alan Moore Guest

    On Sun, 26 Sep 2004 14:35:43 GMT, "Steven Buroff"
    <> wrote:

    >Is there a way to suppress the "unchecked cast" message for a particular
    >statement rather than an entire file? There are times when you can't really
    >avoid the cast. In my case, I'm reading back in a previously serialized
    >object. I need to cast it. Thanks in advance.



    Try adding this annotation to the method:

    @SuppressWarnings("unchecked")
     
    Alan Moore, Sep 27, 2004
    #3
  4. Steven Buroff

    Alan Moore Guest

    On Mon, 27 Sep 2004 04:27:28 GMT, Alan Moore
    <> wrote:

    >
    >Try adding this annotation to the method:
    >
    > @SuppressWarnings("unchecked")



    Never mind: @SuppressWarnings is not implemented in JDK 5.0. Bummer.
     
    Alan Moore, Sep 27, 2004
    #4
  5. "Alan Moore" <> wrote in message
    news:...
    > On Mon, 27 Sep 2004 04:27:28 GMT, Alan Moore
    > <> wrote:
    >
    > >
    > >Try adding this annotation to the method:
    > >
    > > @SuppressWarnings("unchecked")

    >
    >
    > Never mind: @SuppressWarnings is not implemented in JDK 5.0. Bummer.


    Right. Looks like exactly what I was looking for. Thanks for trying.

    Steve
     
    Steven Buroff, Sep 27, 2004
    #5
  6. Steven Buroff

    Alan Moore Guest

    On Mon, 27 Sep 2004 13:03:09 GMT, "Steven Buroff"
    <> wrote:

    >> Never mind: @SuppressWarnings is not implemented in JDK 5.0. Bummer.

    >
    >Right. Looks like exactly what I was looking for. Thanks for trying.


    I just wrote a method that's a perfect candidate for this annotation:
    the casts are perfectly safe, but the compiler can't know that due to
    erasure. I guess I'll go ahead and add the annotation anyway, in the
    interest of self-documentation. And maybe someday I'll remember to
    quit compiling with the -nowarn option and get a pleasant surprise.
     
    Alan Moore, Sep 28, 2004
    #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. Andrew Lee
    Replies:
    2
    Views:
    3,142
    Andrew Lee
    Nov 18, 2004
  2. Ian Pilcher

    Avoid unchecked cast warning

    Ian Pilcher, Aug 20, 2005, in forum: Java
    Replies:
    0
    Views:
    3,560
    Ian Pilcher
    Aug 20, 2005
  3. Replies:
    3
    Views:
    8,929
  4. Knute Johnson

    Unchecked cast warning?

    Knute Johnson, Nov 1, 2006, in forum: Java
    Replies:
    4
    Views:
    1,036
    Knute Johnson
    Nov 1, 2006
  5. Peter
    Replies:
    5
    Views:
    486
    =?ISO-8859-15?Q?Arne_Vajh=F8j?=
    Sep 23, 2007
Loading...

Share This Page