This is the mail archive of the
java-prs@sources.redhat.com
mailing list for the Java project.
gcj/322: Overloaded method resolution should not cross contexts
- To: java-gnats at sourceware dot cygnus dot com
- Subject: gcj/322: Overloaded method resolution should not cross contexts
- From: bryce at albatross dot co dot nz
- Date: 17 Aug 2000 02:23:20 -0000
- Reply-To: bryce at albatross dot co dot nz
- Resent-Cc: java-prs at sourceware dot cygnus dot com, green at cygnus dot com
- Resent-Reply-To: java-gnats@sourceware.cygnus.com, bryce@albatross.co.nz
>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: