Bug 218566 - restricted field access not flagged as problem
Summary: restricted field access not flagged as problem
Status: ASSIGNED
Alias: None
Product: PDE
Classification: Eclipse Project
Component: API Tools (show other bugs)
Version: 3.4   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: PDE API Tools Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords: investigate
Depends on:
Blocks:
 
Reported: 2008-02-11 16:46 EST by Michael Rennie CLA
Modified: 2023-08-09 13:01 EDT (History)
2 users (show)

See Also:


Attachments
patch (1.79 KB, patch)
2008-05-12 16:45 EDT, Darin Wright CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Rennie CLA 2008-02-11 16:46:55 EST
If you make a reference to a restricted field of a parent class from a different component it does not get flagged as an error.

For example:

1. you have two projects P1 and P2
2. you have a class C1 in P1 with a field F1 which has a noreference tag on it
3. you have a class C2 in P2 which extends P1
4. you have method in C2 that assigns a local variable the value of F1 ->

   public void noRef() {
      this.F2 = F1;
   }

Expected:
the ref to F1 would be flagged as an error

Happens:
nothing, likely we are not resolving field lookups like we do for virtual method sends. 

The given example does flag it properly if you qualify the access to F1 like -> super.F1
Comment 1 Michael Rennie CLA 2008-02-11 16:51:19 EST
it also does not get flagged if F1 is qualified by 'this' or if F1 is accessed from an instance of the subclass ->

main(..) {
  C2 c = new C2();
  c.F1 = null; //does not get flagged
}
Comment 2 Michael Rennie CLA 2008-03-27 14:42:47 EDT
I think the missing key here is that we need to do some additional processing with fields that are initialized when they are defined. It seems that field references in the <init> are not inspected properly. Currently we only check them to see if their type is an illegal ref not what we are assigning to them.

Also when we find the super.F1 reference, it is reported as static access to the field F1...investigating.
Comment 3 Darin Wright CLA 2008-05-12 15:49:36 EDT
I found two problems here:

(1) We were not collecting GET FIELD/GET STATIC FIELD references... only puts
(2) When a field reference is made we don't resolve it (so if its "this.field", we don't resolve what class actually defines the field).
Comment 4 Darin Wright CLA 2008-05-12 16:45:50 EDT
Created attachment 99813 [details]
patch

This is a patch for (1) - creating the right kinds of references.
Comment 5 Darin Wright CLA 2008-05-14 14:24:48 EDT
Filed bug 232139 to fix problem (1)
Comment 6 Michael Rennie CLA 2008-05-21 13:00:48 EDT
patch for part (1) has been applied.

Still need to address (2) in a way that does not affect performance (too much).
Comment 7 Darin Wright CLA 2008-05-22 11:34:38 EDT
Not planned for 3.4
Comment 8 Darin Wright CLA 2008-07-08 10:27:35 EDT
Moving to 3.5 - not blocking anyone.
Comment 9 Michael Rennie CLA 2009-05-05 15:12:39 EDT
moving to 3.6
Comment 10 Eclipse Genie CLA 2019-08-27 18:15:58 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 11 Eclipse Genie CLA 2021-08-18 05:56:02 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 12 Eclipse Genie CLA 2023-08-09 13:01:45 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.