Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jdt-core-dev] Ambiguous compilation

Hi Guys,

I wonder if I could get your opinion on this.  The following fails to
compile:

    class A {
        static void a(int i1, int i2) {}
    }

    class B extends A {
        static void a(double d1, double d2) {}
    }

    class C extends B {
        void c() {
            a(0, 0); //*** Fails here
	  }
    }

The error given is:

    The method a(double, double) is ambiguous for the type C

javac is able to compile this but fails with a similar error if the
definitions
of a in A and B are made non-static (Eclipse fails both ways).

The javac approach seems inconsistent but maybe there's something in the JLS
that
justifies it.  I had a quick look but couldn't find anything.

This came up when I tried to use Eclipse to compile a large existing code
base that
has been compiled with javac to date.  This occurs in a great many places in
the
code base and I don't really have a remit to change it.  Any suggestions
welcomed.

Dave Wathen
Canzonet Limited
Phone: +44 (0)20 8660 5171
Mobile: +44 (0)7968 167934
Fax: +44 (0)870 051 7664
http://www.canzonet.com
mailto:dave.wathen@xxxxxxxxxxxx



Back to the top