IntelliJ says "Warning: java: foo/bar/Baz.java uses unchecked or unsafe operations", but it doesn't say in which line it is referring to

StackOverflow https://stackoverflow.com/questions/14238578

سؤال

I am getting this warning:

ScreenShot

When I click on the image, it just opens the associated Editor, but it doesn't say the line number where the warning is raised. I don't want to add @SuppressWarning("unchecked") on the whole class...

Any workaround/fix?

هل كانت مفيدة؟

المحلول 3

I'm not sure why your IDE does not show you generic warnings, but you can try to compile with

-Xlint:unchecked

to get more details.

نصائح أخرى

To compile with -Xlint:unchecked in IntelliJ IDEA:

  • Go to Settings dialog (Ctrl+Alt+S or +, )
  • Select Compiler > Java Compiler
  • Add following into the field Additional command line parameters:

    -Xlint:unchecked

  • Run your compile again

IntelliJ IDEA 15

A faster solution:

  • Press Ctrl + Shift + A
  • Type "Additional com" and press Enter:

    Additional command line parameters

  • Type -Xlint:unchecked > OK

    Xlint unchecked

  • Press Ctrl + Shift + F9 to recompile (or go to Build > Compile ... )

    • you can select a class / module from the project tree to specify what you want to be recompiled
  • You will see the line and the column where the problem appeared

    E.g.: Warning:(5,27) java: unchecked ...

I don't yet have the reputation to comment, but to add to @ROMANIA_engineer's answer - if you're on a Mac, the shortcut is Shift-Command-A.

The menu entry is Help/Find Action.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top