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

Method compatibility not checked during cast conversion

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • P3
    • None
    • 1.1.3
    • tools
    • None
    • x86
    • 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

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

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: