Bug 149004 - static fields from package classes wrong quick-fix'ed
Summary: static fields from package classes wrong quick-fix'ed
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 minor (vote)
Target Milestone: 3.3 M4   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-06-28 10:22 EDT by Roman Kalukiewicz CLA
Modified: 2006-12-12 11:06 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Roman Kalukiewicz CLA 2006-06-28 10:22:16 EDT
example:
package foo;
class BaseFoo {
 public static final int VAL = 0;
}

package foo;
public class NextFoo extends BaseFoo {
}

package bar;
public class Bar {
 int v = NextFoo.VAL;  // this line!
}

Eclipse displays warning on "this line" that "The static field NextFoo.VAL should be accessed directly", and Quick-Fixes this by changing "this line" to:

int v = BaseFoo.VAL; // this line!

witch is wrong, because BaseFoo is not public class, and Bar is in diferent package than BaseFoo. It causes compilation error.
Comment 1 Jerome Lanneluc CLA 2006-06-28 11:04:12 EDT
Moving to JDT UI
Comment 2 Martin Aeschlimann CLA 2006-06-29 10:37:02 EDT
Quick fixes don't promise to not break anything, they are more thought of helping the user as a step in its coding routine.

So here, the next step would be to make the base class visible.

The question is, should the compiler really mark this as a warning? The variable can't be accessed directly, so maybe it's better to not complain.

Moving to jdt.core to discuss this.
Comment 3 Philipe Mulet CLA 2006-10-11 04:01:09 EDT
Good point. The warning should only surface if the declaring class is actually visible, need an extra check before emitting the warning.
Comment 4 Olivier Thomann CLA 2006-11-07 22:58:12 EST
Released for 3.3M4.
Added regression tests in org.eclipse.jdt.core.tests.compiler.regression.FieldAccessTest#test001/004
Comment 5 Frederic Fusier CLA 2006-12-12 11:06:45 EST
Verified for 3.3 M4 using build I20061212-0010.