Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8354227

Imprecise error message in javac

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • None
    • None
    • tools

      When I try to compile the attached Hello.java file with javac It prints the following message:

      ```
      Hello.java:22: error: incompatible types: INT#1 cannot be converted to int
              return (x == y) ?
                              ^
        where INT#1,INT#2 are intersection types:
          INT#1 extends Object,Serializable,Comparable<? extends INT#2>,Constable
          INT#2 extends Object,Serializable,Comparable<?>,Constable
      1 error
      ```

      The return expression in the test case contains an error, it tries to cast an integer to a boolean automatically, however the message that javac prints doesn't hint on that problem IMO and the "^" is not pointing to the correct place in the expression where the error is.

            Unassigned Unassigned
            cslucas Cesar Soares
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: