Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

warning: [unchecked] unchecked call to put(K,V) as a member of the raw type java.util.Hashtable localParams.put(name, values);

Tags:

java

generics

I have got 2 warning: -- The First is :

HELPDESKGESTION2\src\java\glpi\filter\LoginFilter.java:289: warning: [unchecked] unchecked call to put(K,V) as a member of the raw type java.util.Hashtable
                    localParams.put(key, value);
                                   ^

--The Second is :

HELPDESKGESTION2\src\java\glpi\filter\LoginFilter.java:292: warning: [unchecked] unchecked call to put(K,V) as a member of the raw type java.util.Hashtable
            localParams.put(name, values);
                           ^

The Code ho generate this warnings is :

public void setParameter(String name, String []values) {
    if (debug) System.out.println("LoginFilter::setParameter(" + name + "=" + values + ")" + " localParams = "+ localParams);

    if (localParams == null) {
    localParams = new Hashtable();
    // Copy the parameters from the underlying request.
    Map wrappedParams = getRequest().getParameterMap();
    Set keySet = wrappedParams.keySet();
    for (Iterator it = keySet.iterator(); it.hasNext(); ) {
        Object key = it.next();
        Object value = wrappedParams.get(key);
        localParams.put(key, value);
    }
    }
    localParams.put(name, values);
}
like image 954
majda88 Avatar asked Sep 28 '11 17:09

majda88


1 Answers

Replace:

localParams = new Hashtable();

With:

localParams = new Hashtable<String,String>();

I assume you have a global variable like the following:

private Hashtable localParams;

Replace that with:

private Hashtable<String,String> localParams;

If you make the changes I suggested the warnings will go away but you will also have to replace all of your Object with String;

like image 119
Robert Louis Murphy Avatar answered Sep 18 '22 13:09

Robert Louis Murphy