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

Missing compile error in Java 8 mode for Interface.super.field access

    XMLWordPrintable

Details

    • b42
    • x86_64
    • windows_7
    • Verified

    Backports

      Description

        FULL PRODUCT VERSION :
        java version "1.8.0_20-ea"
        Java(TM) SE Runtime Environment (build 1.8.0_20-ea-b20)
        Java HotSpot(TM) 64-Bit Server VM (build 25.20-b20, mixed mode)

        ADDITIONAL OS VERSION INFORMATION :
        Windows.
        All

        A DESCRIPTION OF THE PROBLEM :
        interface T2 { int f = 0; }
        interface T extends T2 { int f = 0; }
        class X implements T {
        int i = T.super.f;
        }

        The compiler compiles the code without any issues.

        JLS 15.11.2. Accessing Superclass Members using super
        "The form T.super.Identifier refers to the field named Identifier of the lexically enclosing instance corresponding to T, but with that instance viewed as an instance of the superclass of T."
        The statement does not mention anything about Interfaces.

        In my opinion the compiler should throw for T.super.f.

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        interface T2 { int f = 0; }
        interface T extends T2 { int f = 0; }
        class X implements T {
        int i = T.super.f;
        }

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        The compiler should throw for T.super.f.
        ACTUAL -
        The code compiles fine without any issues.

        REPRODUCIBILITY :
        This bug can be reproduced always.

        ---------- BEGIN SOURCE ----------
        interface T2 { int f = 0; }
        interface T extends T2 { int f = 0; }
        class X implements T {
        int i = T.super.f;
        }
        ---------- END SOURCE ----------

        Attachments

          Issue Links

            Activity

              People

                vromero Vicente Arturo Romero Zaldivar
                webbuggrp Webbug Group
                Votes:
                0 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: