Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Recompile with -Xlint:unchecked for details

Tags:

java

while compiling java program we are getting "Recompile with -Xlint:unchecked for details". Why we are getting this error?

like image 686
krishna bhargavi Avatar asked Jun 21 '11 08:06

krishna bhargavi


1 Answers

Probably because you're not using generics properly. Perhaps you're mixing legacy code with generic code.

Here's a quote fro the official trail on type erasure:

Note: WarningDemo.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

This can happen when using an older API that operates on raw types, as shown in the following WarningDemo program:

public class WarningDemo {
    public static void main(String[] args) {
        Box<Integer> bi;
        bi = createBox();
    }

    static Box createBox() {
        return new Box();
    }
}

I suggest you follow the advice, and add the -Xlint:unchecked option when compiling. This should reveal the which parts of the code that are problematic.

like image 157
aioobe Avatar answered Sep 22 '22 10:09

aioobe