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

Misleading javac error message

    XMLWordPrintable

Details

    • Bug
    • Resolution: Not an Issue
    • P4
    • 8
    • None
    • tools
    • None
    • TL build of
      langtool changeset: 0e70eb71fec0
      JDK changeset: b54a5b7d2e65.

    • 8

    Description

      Compile intersection type type case without enable it, javac will cause error as expected. However, the error message is misleading.

      Noted the message refer to -source 1.8 and -source 8, this mislead developer to think 1.8 and 8 are different versions. It would be better to use consistent representation of source level.

      $ javac IntersectionTypeLambda.java

      IntersectionTypeLambda.java:5: error: intersection types in cast are not supported in -source 1.8
              Runnable r = (Runnable & Serializable) () -> System.out.println("Hello World!");
                                     ^
        (use -source 8 or higher to enable default methods)
      1 error

      Attachments

        Activity

          People

            vromero Vicente Arturo Romero Zaldivar
            henryjen Henry Jen
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: