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

Compiler improperly reports ambiguous method

    XMLWordPrintable

Details

    • Bug
    • Resolution: Not an Issue
    • P3
    • None
    • 1.1, 1.2.0
    • tools
    • generic, x86
    • solaris_2.5.1, windows_nt

    Description



      Name: mc57594 Date: 03/12/97


      class A
      {
         public void method1( int x )
         { System.out.println( "A.method1 (int) : " + x );
         }

         public static void main( String[] xArgs )
         { ASub a1 = new ASub();
            a1.method1( 3 );
         }
      }

      --------------

      class ASub extends A
      {
         public void method1( long x )
         { System.out.println( "ASub.method1 (long) : " + x );
         }
      }

      --------------

      Compiler produces error "Reference to method1 is ambiguous" when
      compiling class A. According to section 15.11.2.2 of the
      Language Specification the "most specific" method should be
      chosen. Since, by method invocation conversion, an "int"
      argument can be converted to a "long" but a "long" cannot be
      converted to an "int", the method (in class A) with the "int"
      argument should be "more specific" and method1 should not be
      ambiguous.


      company - Cyberian Foundations , email - ###@###.###
      ======================================================================

      Attachments

        Issue Links

          Activity

            People

              tturnidgsunw Todd Turnidge (Inactive)
              mchamnessunw Mark Chamness (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: