Code line with warning messages ?


I use IntlliJ IDEA 9.0.3, when I compile one class, the compiler would give messages for example:

Error:(16, 9) cannot find symbol class Strin
Warning: Note: C:\Test\src\ uses unchecked or unsafe operations.

Could you please teach me what to do, in order to have the number of the line of code, which generates the Warning. The same as the Error message line above.
Thanh you very much.

Comment actions Permalink

> Error:(16, 9) cannot find symbol class Strin

why can't you just double click on this text and cursor will jump to error line?

> Warning: Note: C:\Test\src\ uses unchecked or unsafe operations.

Sun java compiler doesn't provide line number in this warning message. After double-click Idea will only open the file. Idea can't know where to jump.

Comment actions Permalink

Thank you for the reply.

More info: Because I read the book "Java Generics and Collections" by Maurice Naftalin, Philip Wadler, published by O'Reilly in October 2006.

I get jealous to read how they compile java classes with code line infomation in the warning messages as extracted below:

From Part I, Chapter 6, Section 6.2

source code:

class Promote {
  public static List<String> promote(List<Object> objs) {
    for (Object o : objs)
      if (!(o instanceof String))
        throw new ClassCastException();
    return (List<String>)(List<?>)objs; // unchecked cast
  public static void main(String[] args) {
    List<Object> objs1 = Arrays.<Object>asList("one","two");
    List<Object> objs2 = Arrays.<Object>asList(1,"two");
    List<String> strs1 = promote(objs1);
    assert (List<?>)strs1 == (List<?>)objs1;
    boolean caught = false;
    try {
      List<String> strs2 = promote(objs2);
    } catch (ClassCastException e) { caught = true; }
    assert caught;

compile result:

% javac -Xlint:unchecked warning: [unchecked] unchecked cast
found   : java.util.List
required: java.util.List<java.lang.String>
    return (List<String>)(List<?>)objs; // unchecked cast
1 warning

Maybe, you know anything about javac command line, and teach me. Highly appreciate.


Please sign in to leave a comment.