Bug 256375 - [1.5][compiler] Import Static Error
Summary: [1.5][compiler] Import Static Error
Status: VERIFIED INVALID
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.5   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 3.5 M4   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-11-25 00:16 EST by Mahmood Ali CLA
Modified: 2009-05-07 03:33 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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