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

Interface with defaults invalid compiler warning for Serializable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 8, 9.0.1, 10
    • Fix Version/s: 10
    • Component/s: tools
    • Subcomponent:
    • Resolved In Build:
      b39
    • CPU:
      x86_64
    • OS:
      linux_ubuntu

      Backports

        Description

        FULL PRODUCT VERSION :


        A DESCRIPTION OF THE PROBLEM :
        As I mentioned in this link: https://stackoverflow.com/questions/47390432/functional-interface-with-default-behavior-with-serializable

        I think the behavior of compiler is wrong.

        When an Interface with no default method extends Serializable everythings works fine. But When a default method for that interface comes in picture we have a warning that says:

        MyInterface.java: serializable class MyInterface has no definition of serialVersionUID
        It got intersting when I change that interface to a abstract class. The error disappears.

        To sum up the warning happening table is as below:

        |----------------------------|------------------|
        | Type | WARNING |
        |----------------------------|------------------|
        | interface with no defaults | NO |
        |----------------------------|------------------|
        | interface with defaults | YES |
        |----------------------------|------------------|
        | abstract class | NO |
        |----------------------------|------------------|
        Is there any reason for that or it's just a bug?




        REPRODUCIBILITY :
        This bug can be reproduced always.

          Issue Links

            Activity

            Hide
            fmatte Fairoz Matte added a comment -
            This issue is reproducible in 8 9 and 10. Slightly different results compared to bug report. Getting warning even for abstract class as well.
            == Running with -Xlint==
            interface with no defaults - No warning
            interface with defaults - Warning (warning: [serial] serializable class Main has no definition of serialVersionUID)
            abstract class - Warning (warning: [serial] serializable class Main has no definition of serialVersionUID)
            Show
            fmatte Fairoz Matte added a comment - This issue is reproducible in 8 9 and 10. Slightly different results compared to bug report. Getting warning even for abstract class as well. == Running with -Xlint== interface with no defaults - No warning interface with defaults - Warning (warning: [serial] serializable class Main has no definition of serialVersionUID) abstract class - Warning (warning: [serial] serializable class Main has no definition of serialVersionUID)
            Hide
            darcy Joe Darcy added a comment -
            It seems reasonable that the serial warning would not be applied the same way to interfaces. At the very least, the warning message should not use the term "class" to refer to an interface.
            Show
            darcy Joe Darcy added a comment - It seems reasonable that the serial warning would not be applied the same way to interfaces. At the very least, the warning message should not use the term "class" to refer to an interface.
            Hide
            mtrudeau Michel Trudeau added a comment -
            Please reassign and triage accordingly.
            Show
            mtrudeau Michel Trudeau added a comment - Please reassign and triage accordingly.
            Hide
            hgupdate HG Updates added a comment -
            URL: http://hg.openjdk.java.net/jdk/jdk10/rev/e2b8009bf42c
            User: jjg
            Date: 2018-01-06 00:56:08 +0000
            Show
            hgupdate HG Updates added a comment - URL: http://hg.openjdk.java.net/jdk/jdk10/rev/e2b8009bf42c User: jjg Date: 2018-01-06 00:56:08 +0000

              People

              • Assignee:
                jjg Jonathan Gibbons
                Reporter:
                webbuggrp Webbug Group
              • Votes:
                0 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: