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

javac doesn't detect circular subclass dependencies via qualified names

    Details

    • Subcomponent:
    • Resolved In Build:
      b114
    • CPU:
      x86
    • OS:
      linux
    • Verification:
      Verified

      Description

      FULL PRODUCT VERSION :
      java version "1.6.0_13"
      Java(TM) SE Runtime Environment (build 1.6.0_13-b03)
      Java HotSpot(TM) 64-Bit Server VM (build 11.3-b02, mixed mode)

      javac 1.6.0_13

      ADDITIONAL OS VERSION INFORMATION :
      2.6.28-13-generic #45-Ubuntu SMP Tue Jun 30 22:12:12 UTC 2009 x86_64 GNU/Linux

      A DESCRIPTION OF THE PROBLEM :
      The example code below (four variations) describes a conceptually valid class hierarchy, but in each case is prohibited by the JLS (8.1.4, 9.1.3: "A class C directly depends on a type T if T is mentioned in the extends or implements clause of C either as a superclass or superinterface, or AS A QUALIFIER of a superclass or superinterface name" ... "It is a compile-time error if a class depends on itself." -- emphasis mine.) Javac will compile two of the examples without error, and reports misleading errors in the other two cases.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Compile the following programs (cleaning up after any successful compiles to prevent javac from relying on previously-compiled class files):

      *** Example 1

      class a { static interface b {} }
      class c extends a implements z.y {}

      class x { static interface y {} }
      class z extends x implements c.b {}

      *** Example 2 (added another superinterface of c)

      class a { static interface b { static interface d {} } }
      class c extends a implements z.y, z.d {}

      class x { static interface y {} }
      class z extends x implements c.b {}

      *** Example 3 (changed declaration order)

      class x { static interface y {} }
      class z extends x implements c.b {}

      class a { static interface b { static interface d {} } }
      class c extends a implements z.y, z.d {}

      *** Example 4 (added another superinterface of z)

      class a { static interface b { static interface d {} } }
      class c extends a implements z.y, z.d {}

      class x { static interface y { static interface w {} } }
      class z extends x implements c.b, c.w {}


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      In each case, report a cyclical dependency in the declaration of the hierarchy. (Eclipse does this successfully.)
      ACTUAL -
      *** Example 1: [javac reports no error.]

      *** Example 2: [javac reports no error.]

      *** Example 3:
      circular.java:5: cannot find symbol
      symbol : class d
      location: class z
      class c extends a implements z.y, z.d {}
                                         ^
      1 error

      *** Example 4:
      circular.java:6: cannot find symbol
      symbol : class w
      location: class c
      class z extends x implements c.b, c.w {}
                                         ^
      1 error



      REPRODUCIBILITY :
      This bug can be reproduced always.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                mcimadamore Maurizio Cimadamore
                Reporter:
                ndcosta Nelson Dcosta (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: