How to avoid Eclipse warnings when using legacy code without generics?
        Posted  
        
            by Paul Crowley
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Paul Crowley
        
        
        
        Published on 2010-04-15T15:21:38Z
        Indexed on 
            2010/04/15
            15:23 UTC
        
        
        Read the original article
        Hit count: 315
        
I'm using JSON.simple to generate JSON output from Java. But every time I call jsonobj.put("this", "that"), I see a warning in Eclipse:
Type safety: The method put(Object, Object) belongs to the raw type HashMap. References to generic type HashMap should be parameterized
The clean fix would be if JSONObject were genericized, but since it isn't, I can't add any generic type parameters to fix this. I'd like to switch off as few warnings as possible, so adding "@SuppressWarnings("unchecked")" to lots of methods is unappealing, but do I have any other option besides putting up with the warnings?
© Stack Overflow or respective owner