This is the mail archive of the java-prs@sources.redhat.com mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

gcj/322: Overloaded method resolution should not cross contexts



>Number:         322
>Category:       gcj
>Synopsis:       Overloaded method resolution should not cross contexts
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    apbianco
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Aug 16 19:30:00 PDT 2000
>Closed-Date:
>Last-Modified:
>Originator:     Bryce McKinlay
>Release:        current
>Organization:
>Environment:

>Description:
gcj goes to some lengths to try and resolve calls to 
overloaded methods where methods in an outer context share
the same name (see find_most_specific_methods_list etc). 
However this is unneccessary (and wrong), as demonstrated 
by the following example.

class Overload
{
  void p(String s) {}

  class A
  {
    void p(int i) {}
    
    void a()
    {
      p("One");
    }
  }
}

Here gcj will patch the call through to p(String) in the
outer context. But both jikes and javac reject this code
because overload resolution should stop at the first context
in which an appropriatly named method is discovered.
Jikes's error message is particularly intelligent here:

$ jikes Overload.java 

Found 1 semantic error compiling "Overload.java":

    11.       p("One");
              <------>
*** Error: The method "void p(java.lang.String s);" contained in the enclosing type "Overload" is a perfect match for this method call. However, it is not visible in this nested class because a method with the same name in an intervening class is hiding it.
>How-To-Repeat:

>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]