Bug 256375

Summary: [1.5][compiler] Import Static Error
Product: [Eclipse Project] JDT Reporter: Mahmood Ali <msaeed999>
Component: CoreAssignee: Philipe Mulet <philippe_mulet>
Status: VERIFIED INVALID QA Contact:
Severity: normal    
Priority: P3 CC: jerome_lanneluc, philippe_mulet
Version: 3.5   
Target Milestone: 3.5 M4   
Hardware: All   
OS: All   
Whiteboard:

Description Mahmood Ali CLA 2008-11-25 00:16:10 EST
Build ID: I20080617-2000

Steps To Reproduce:
1. Create a new Java file, named test/Outer.java with the following content:

package test;

import static test.Outer.Inner.*;

public class Outer {

    int i = VALUE;
    int i2 = Inner.VALUE;

    static class Inner {
        private static final int VALUE = 0;
    }
}

2. Notice that the code compiles cleanly.
3. Change the static import statement to:

import static test.Outer.Inner.VALUE;

4. Notice that we get two errors:
Description	Resource	Path	Location	Type

The field Outer.Inner.test.Outer.Inner.VALUE is not visible	Outer.java	Test/src/test	line 3	Java Problem
Description	Resource	Path	Location	Type

VALUE cannot be resolved	Outer.java	Test/src/test	line 7	Java Problem


More information:
Comment 1 Philipe Mulet CLA 2008-11-25 05:17:16 EST
This feels the right behavior to me, since a private member is not visible inside entire compilation unit, but rather in toplevel type declaration it occurs into.

So essentially, the single type static import is doomed, as VALUE is not accessible outside Outer. But the on demand static import is working fine, since VALUE is only referenced from a valid context.

Interestingly, javac seems to also reject the on demand static import case, which I suspect is wrong.
Comment 2 Philipe Mulet CLA 2008-11-25 05:21:44 EST
Added StaticImportTest#test073-074.

Marking as Invalid, since this is working as specified.
Comment 3 Jerome Lanneluc CLA 2008-12-09 05:39:11 EST
Verified for 3.5M4