Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to setup IntelliJ IDEA to compile code with a parameter -Xlint:unchecked?

I read about the -Xlint:unchecked in the Oracle Java tutorial link. And I would like to setup my IDE to inform me about unsafe code. But I faced some troubles trying to accomplish so. But I managed to get a warning message in my Terminal using command:

javac GenericsMain.java Box.java -Xlint:unchecked

I got such message

GenericsMain.java:19: warning: [unchecked] unchecked call to addItem(T)
as a member of the raw type Box
rawBox.addItem(8);
^
where T is a type-variable:
T extends Object declared in class Box
GenericsMain.java:23: warning:
[unchecked] unchecked call to addItem(T) as a member of the raw type Box
rawBox.addItem(8);
^
where T is a type-variable:
T extends Object declared in class Box
2 warnings

How can I provide this in my IDE? Thank you.

like image 940
Alexander Belenov Avatar asked Oct 28 '25 03:10

Alexander Belenov


1 Answers

Settings (Ctrl+Alt+S / ,) > Build, Execution, Deployment > Compiler > Java Compiler > "Additional command line parameters"

This is a per project setting.

screen shot of IntelliJ > Settings/Preferences > Build, Execution, Deployment > Compiler > Java Compiler panel

To set for new future projects, set the same under File > Other Settings > Default Settings

screen shot of IntelliJ > File > Other Settings > Default Settings > Build, Execution, Deployment > Compiler > Java Compiler >

More details at: https://www.jetbrains.com/help/idea/java-compiler.html

like image 195
Javaru Avatar answered Oct 30 '25 17:10

Javaru



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!