Eclipse is giving me a warning of the following form:
Type safety: Unchecked cast from Object to HashMap
This is from a call to
If you are sure that the type returned by session.getAttribute() is HashMap then you can not typecast to that exact type, but rely on only checking the generic HashMap
HashMap,?> getItems(javax.servlet.http.HttpSession session) {
HashMap,?> theHash = (HashMap,?>)session.getAttribute("attributeKey");
return theHash;
}
Eclipse will then surprise warnings, but of course this can lead to runtime errors that can be hard to debug. I use this approach in not operation-critical contexts only.