Bug 23597 - cannot resolve a call to a protected superclass method
Summary: cannot resolve a call to a protected superclass method
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 2.1 M2   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-09-16 09:43 EDT by Adam Kiezun CLA
Modified: 2002-10-17 10:18 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Adam Kiezun CLA 2002-09-16 09:43:31 EDT
class A{
  void f(){
     A a= new A();
     a.clone();  //resolving the name fails - returns null
  }
}
Comment 1 Adam Kiezun CLA 2002-09-16 09:48:00 EDT
happens also if you do add
throws CloneNotSupportedException 
to the declaration of f
Comment 2 Olivier Thomann CLA 2002-09-16 09:51:45 EDT
I will investigate.
Comment 3 Olivier Thomann CLA 2002-09-16 10:13:17 EDT
Do you mean resolving "a" or "clone"? I tried "a" and I have no problem with 
this source:
  void f() throws CloneNotSupportedException {
     A a= new A();
     a.clone();
  }
Comment 4 Adam Kiezun CLA 2002-09-16 10:23:24 EDT
sorry, 
i meant resolving clone (that's the 'call to a protected superclass method' 
from the summary)
Comment 5 Olivier Thomann CLA 2002-09-16 10:31:48 EDT
I have no problem to resolve "clone" as well. I will try without the throws 
clause.
Comment 6 Olivier Thomann CLA 2002-09-16 10:39:16 EDT
Both cases work fine. Could you please give me your code?
Comment 7 Olivier Thomann CLA 2002-09-16 12:05:51 EDT
Could not reproduce so far. Please provide additional steps.

I tried to resolve:

class A{
  void f(){
     A a= new A();
     a.clone();  //resolving the name fails - returns null
  }
}

And I got a binding for the name "clone" in a.clone();
Comment 8 Adam Kiezun CLA 2002-09-16 12:12:19 EDT
sorry, my bad
here's the original cu (it does have a compile error):
so, lower priority because of that error.
however, F3 resolves it correctly

----------A.java -------
package p;
class A{
	public void foo(){};
}
class Test{
	void test() throws CloneNotSupportedException{
		A a= new A();
		a.clone();
	}
}
----------A.java -------
Comment 9 Olivier Thomann CLA 2002-09-16 12:51:06 EDT
It is not possible to get this binding, because the method is not visible. So in
fact I have a problem binding from the compiler's world. null is returned
because before returning the new binding I check first if it is a valid binding.
In this case, it is not a valid binding.
I really don't see how I could create a valid binding in this very specific case.
Comment 10 Adam Kiezun CLA 2002-09-16 12:54:39 EDT
how come F3 works?
Comment 11 Olivier Thomann CLA 2002-09-16 13:01:21 EDT
I don't know. Which binding would you expect?
The methodbinding that correspond to the method clone() in java.lang.Object? I
can try to hack the resolution to return this binding.
Comment 12 Adam Kiezun CLA 2002-09-16 13:22:29 EDT
Object::clone() is the one - the method is just not accessible from there. but 
the compiler knows which one it is.

anyway - like i said, this PR is of lower priority for me because there is a 
compilation error. 
so, if you see difficulties - feel free to close. (i might reopen at some 
point, though - who knows :-) )
Comment 13 Olivier Thomann CLA 2002-09-16 13:53:54 EDT
I can return the Object::clone(). I simply need to check the problemId(). It is 
only when the problem id is NotVisible that I can retrieve the method binding 
by getting the binding through the declaring class. This code needs more 
testing, but it should be released quite soon.
Comment 14 Olivier Thomann CLA 2002-09-16 14:19:17 EDT
Object::clone() is returned in this example. More generally, the binding is
retrieved from the problem binding when the problemReason is NotVisible and in
this case only, otherwise null is returned.
Fixed and released in 2.1 stream.
Comment 15 Philipe Mulet CLA 2002-09-19 06:34:00 EDT
I confirm, this is the trick we play in code-select. We also provide a fuzzy 
match in case a method isn't applicable (best match found if any), but I am not 
convinced this should work.

Anyhow, providing a binding in presence of an error is ok, but as long as the 
error isn't ignored. Ok, Adam ?
Comment 16 Adam Kiezun CLA 2002-09-19 06:41:32 EDT
any API easy way to find out that the method is not visible ?
(i mean, without doing all the checks myself)
Comment 17 Olivier Thomann CLA 2002-09-19 10:51:23 EDT
I don't see the need of an API if we report the error in the compilation unit
problems' list and we give your the proper binding. This should be a workable
solution.
Comment 18 David Audel CLA 2002-10-17 10:18:19 EDT
Verified.