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

Method compatibility not checked during cast conversion

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3
    • Resolution: Duplicate
    • Affects Version/s: 1.1.3
    • Fix Version/s: None
    • Component/s: tools
    • Labels:
      None
    • Subcomponent:
    • CPU:
      x86
    • OS:
      windows_95

      Description



      Name: tb29552 Date: 08/15/97


      The following illustrates that javac's implementation of cast
      conversion is incorrect. The cast should be a compile-time error because I and
      J contain methods with the same signature but different return types; the
      reference comparison should be wrong for the same reason (since ==/!= must check
      for cast convertibility first).

      interface I {
          void f ();
      }

      interface J {
          int f ();
      }

      public class C {
          {
              I i = null;
              J j = (J)i; // should be an error according to 5.5

              if (i == j) // should be an error according to 15.20.3
                  System.out.println("It is allowed after all.");
          }
      }
      ======================================================================

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                tturnidgsunw Todd Turnidge (Inactive)
                Reporter:
                tbell Tim Bell
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: