Bug 82671 - [compiler][1.5]Protected field not visible to subclass in different package when having a class parameter
Summary: [compiler][1.5]Protected field not visible to subclass in different package w...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: Other Linux
: P3 normal (vote)
Target Milestone: 3.1 M5   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-01-12 10:28 EST by Jan Schäfer CLA
Modified: 2005-02-15 06:28 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Schäfer CLA 2005-01-12 10:28:58 EST
Trying to access a protected field of a superclass within a subclass that 
resides in another package gives the error: field is not visible. 
This bug only happens if the subclass is in another package and has a class 
parameters. Accessing the field of the this object also works. 
 
Example: 
 
package test; 
class Foo { 
   protected String s; 
} 
 
package test2; 
import test.Foo; 
 
class FooBar<R> extends Foo { 
   void fail() { 
      FooBar f = new FooBar(); 
      f.s = "foo"; // Error: field f.s is not visible 
      this.b = false // Works 
   } 
}
Comment 1 Jan Schäfer CLA 2005-01-12 10:56:52 EST
Sorry, it must be: 
 
      this.s = "foo"; // Works  
 
instead of 
 
      this.b = false // Works  
 
Comment 2 Kent Johnson CLA 2005-01-12 16:09:25 EST
Philippe, what do you want to do with this?

In the call to FieldBinding canBeSeenBy(TypeBinding receiverType, 
InvocationSite invocationSite, Scope scope) the receiverType is FooBar#RAW so 
the comparison to the declaringClass fails.
Comment 3 Philipe Mulet CLA 2005-01-24 10:47:34 EST
Used erasure to compare identical.
Added GenericTypeTest#test467-468.
Fixed
Comment 4 Jan Schäfer CLA 2005-01-25 03:34:34 EST
Is there a chance to get a patch against M4? 
Comment 5 Jan Schäfer CLA 2005-01-27 03:37:16 EST
OK. The previous example works now, but the bug is still there in a slightly 
modified example. This time the superclass is generic, too: 
 
package test; 
public class Foo<R> { 
    protected R s;   
} 
 
package test2; 
import test.Foo;  
public class FooBar<R> extends Foo<R> { 
    void fail() {   
	FooBar<String> f = new FooBar<String>();  
	f.s = "foo"; // Error: field f.s not visible 
    }   
} 
 
 
 
Comment 6 Philipe Mulet CLA 2005-01-27 08:52:48 EST
Thanks for noticing it. Added GenericTypeTest#test471-472.
Fixed.

You can grab the next nightly build output, copy the org.eclipse.jdt.core plugin
from it and paste it into a M4 install.
Comment 7 Philipe Mulet CLA 2005-01-27 08:53:02 EST
Fixed
Comment 8 Jan Schäfer CLA 2005-01-27 09:18:07 EST
I have downloaded the HEAD from CVS and it works now! Thank you! 
Comment 9 Jerome Lanneluc CLA 2005-02-15 06:28:00 EST
Verified in I20050214