Skip to main content

Cool new lint option: redundant casts and feedback

3 replies [Last post]
amitkulz
Offline
Joined: 2005-09-22

I just d/l b55 and got rid of around 5 unnecessary casts. I now compile using -Xlint.

Feedback
--------
I managed to get rid of all the unchecked call/conversion in the generics part of my code. There was one thing which got me stumped for a while. I now have to do this in my class, which is kinda weird since I have not used C++ templates since 1997 (and that too was just a cursory reading).

private HashMap > my_map = new HashMap>(4000);

when before the line was

private HashMap my_map = new HashMap(4000);

and was being called like
ArrayList ranges = my_map.get(streetName);

On hindsight, I think it would have really helped if instead of pointing to the exact line of warning i.e add(E) unchecked conversion , javac should also suggest solution in the warning "constructor or initialization of my_map should be >"

Is this too much to ask? javac knows what the problem is at this point. It maybe (may not be?) just a cosmetic improvement, but it would help to go directly to the offending line number and clean it up. Without Angelika Langer's FAQ I would have taken a bit longer to understand what was wrong.

Thanks

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
ingridy
Offline
Joined: 2004-11-17

a new RFE 6334465 has been filed and you may bug
watch its latest status.

amitkulz
Offline
Joined: 2005-09-22

Thank you for the filing..

peterahe
Offline
Joined: 2004-11-22

Yes, that is a good idea and one of the things
we would like to do.