Re: Unnecessary type casts
"Ludwig Magnusson" <[email protected]> Wed, 2 Feb 2011 18:53:02 +0100
| Newsgroups | gmane.comp.java.audit.checkstyle.user |
|---|---|
| Message-ID | <[email protected]> |
Never mind, I realized this could be done by changing the compiler settings. From: Ludwig Magnusson [mailto:[email protected]] Sent: den 2 februari 2011 16:11 To: '[email protected]' Subject: Unnecessary type casts Hello! Is it possible to use checkstyle to detect unnecessary type casts in java? Let me show two examples: Ex 1: String helloString = (String) getHelloString(); public String getHelloString() { return "hello"; } -- Ex 2: List aList = (List) getNewList(); public ArrayList getNewList() { return new ArrayList(); } As you can see the casts (String) and (List) are not necessary. I need this for a project going from java 1.4 to 1.5 where typecasts are no longer necessary as generics become available. /Ludwig ------------------------------------------------------------------------------ Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)! Finally, a world-class log management solution at an even better price-free! Download using promo code Free_Logger_4_Dev2Dev. Offer expires February 28th, so secure your free ArcSight Logger TODAY! http://p.sf.net/sfu/arcsight-sfd2d _______________________________________________ Checkstyle-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/checkstyle-user