Warning: [unchecked] unchecked call put (k, V) as a member of the original type Java util. Hashtable localParams. put(name,values);

I have two warnings:

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);
                                   ^

– second:

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 generation warning 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);
}

Solution

Replacement:

localParams = new Hashtable();

Attached:

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

I assume you have a global variable, as follows:

private Hashtable localParams;

Replace with:

private Hashtable<String,String> localParams;

If you make changes, I suggest that the warning will disappear, but you must also replace all objects with string;

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>