Java一些输入文件使用未经检查或不安全的操作

时间:2019-03-13 16:45:59

标签: java hashmap unchecked

以下是引发此警告的代码:

IntMap.class:

package masthead.util;

import java.util.HashMap;

// slow
public class IntMap extends HashMap {

    public Object get(int key) {
        return get(""+key);
    }

    public Object put(int key, Object value) {
        return put(""+key, value);
    }    

    public Object remove(int key) {
        return remove(""+key);
    }        

    public boolean containsKey(int key) {
        return containsKey(""+key);
    }

}

它抛出以下警告,需要修复:

[WARNING] /trident-payment-swtich/src/main/masthead/util/IntMap.java: Some input files use unchecked or unsafe operations.
[WARNING] /trident-payment-swtich/src/main/masthead/util/IntMap.java: Recompile with -Xlint:unchecked for details.

一旦完成javac -Xlint:unchecked /Users/plamsal/workspace/trident-payment-swtich/src/main/masthead/util/IntMap.java,它就会为我提供以下详细信息,但仍无法修复::

warning: [unchecked] unchecked call to put(K,V) as a member of the raw type HashMap
        return put(""+key, value);
                  ^
  where K,V are type-variables:
    K extends Object declared in class HashMap
    V extends Object declared in class HashMap
1 warning

我们将为您提供帮助

0 个答案:

没有答案