-
Enhancement
-
Resolution: Won't Fix
-
P4
-
None
-
5.0, 6
-
generic, x86
-
generic, windows_xp
Feedback
from mustang forum:
--------
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 <String, ArrayList<AddressRange>> my_map = new HashMap<String, ArrayList<AddressRange>>(4000);
when before the line was
private HashMap <String, ArrayList> my_map = new HashMap<String, ArrayList>(4000);
and was being called like
ArrayList <AddressRange> 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
<String, ArrayList<AddressRange>>"
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.
At the same time adding a warning for types like
List<String>[] could be useful.
from mustang forum:
--------
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 <String, ArrayList<AddressRange>> my_map = new HashMap<String, ArrayList<AddressRange>>(4000);
when before the line was
private HashMap <String, ArrayList> my_map = new HashMap<String, ArrayList>(4000);
and was being called like
ArrayList <AddressRange> 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
<String, ArrayList<AddressRange>>"
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.
At the same time adding a warning for types like
List<String>[] could be useful.
- duplicates
-
JDK-6355406 Additional lint option when generics not specified
-
- Closed
-