🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #415

Re: dealing with compiler warning

#415
From: Jeroen Wenting
Date: Mon, 08 Aug 2005 12:16
41 lines
2200 bytes
"Alan Shiers" <ashiers@hfx.eastlink.ca> wrote:
>Hi there,
>
>I got the following warning message:
>
>TestProcessor.java:153: warning: [unchecked] unchecked method invocation:
><T>sor
>t(java.util.List<T>) in java.util.Collections is applied to
>(java.util.ArrayList
><mvcs.TestProcessor.Answer>)
>         Collections.sort(list);
>                         ^
>1 warning
>
>What is it I need to do further to prevent this warning message from popping
>up all the time? Am I supposed to ignore it or is there something I'm
>expected to do to prevent this warning message?
>
>Please advise,
>
>Alan
>
>

Add the annotation @suppresswarnings("unchecked") to the method (or class if you want it to be global for that class) declaration.
E.g. turn
-------------------
public void aMethod(List list) {
  Collections.sort(list);
}
-------------------
into
-------------------
@suppresswarnings("unchecked")
public void aMethod(List list) {
  Collections.sort(list);
}
-------------------

I'm not fond of annotations, but this is one case they could come in handy (though of course it's like shooting a moquito with an elephant gun as you're potentially hiding warnings you do want to soo).
Technical Details
Message-ID: <42f74d1c$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!feeder2.on.meganewsservers.com!meganewsservers.com!textfeed1.on.meganewsservers.com!38.119.100.83.MISMATCH!news-out.nntp.be!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail
References: <42f27c48$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: f74b3,c7b486fd2f985b01
X-Google-Attributes: gidf74b3,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Jeroen Wenting" <jwenting@hotmail.com>
Sender: "Jeroen Wenting" <jwenting@hotmail.com>
Reply-To: "Jeroen Wenting" <jwenting@hotmail.com>
Subject: Re: dealing with compiler warning
Newsgroups: borland.public.jbuilder.java.language
X-User-Info: 212.19.218.2     
X-Forwarded-For: 192.168.1.144
References:  <42f27c48$1@newsgroups.borland.com>
NNTP-Posting-Host: 207.105.83.66
Message-ID: <42f74d1c$1@newsgroups.borland.com>
Date: 8 Aug 2005 05:16:28 -0700
X-Trace: newsgroups.borland.com 1123503388 207.105.83.66 (8 Aug 2005 05:16:28 -0700)
Lines: 41
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!feeder2.on.meganewsservers.com!meganewsservers.com!textfeed1.on.meganewsservers.com!38.119.100.83.MISMATCH!news-out.nntp.be!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail