In a servlet, you need to get a DAO instance that is wrapped in an AtomicReference , but when casting, the compiler is worried and writes:
Unchecked cast: 'java.lang.Object' to 'java.util.concurrent.atomic.AtomicReference<ru.javavision.dao.UserDAO>' less... (⌘F1) Signals places where an unchecked warning is issued by the compiler, for example: void f(HashMap map) { map.put("key", "value"); } Hint: Pass -Xlint:unchecked to javac to get more details. The code itself looks like this:
AtomicReference<UserDAO> dao = (AtomicReference<UserDAO>) req.getServletContext().getAttribute("dao"); Tell me how you can calm the compiler, given that the instance of does not work with generics, or if it works then how to write it?
Thank.