Community
Participate
Working Groups
Steps: 1) Open an existing Java project in Eclipse and enable automatic building. 2) Using a native shell, create a new directory 'foo' in the project's top directory. Create 'bug' as a subdirectory of 'foo'. 3) Using a native editor, save text "package bug;class Bug{}" as foo/bug/Bug.java. 4) Open foo/bug/Bug.java in Eclipse. 5) In PackageExplorer add 'foo' as a Source Folder. See that the package statement in foo/bug/Bug.java is falsely flagged as an error saying "The declared package does not match the expected package". Adding whitespace and saving doesn't eliminate the false error. Closing Bug.java and reopening it is needed to remove the false error.
Brian, how did you open the editor in step 4. Did you do a refresh in Eclipse before to see Bug.java ?
I never did a project refresh. I saw the 'foo' directory spontaneously appear in the Package Explorer tree. So for step 4, I expanded the 'foo' tree node, then expanded the 'bug' subnode, and then doubleclicked on the Bug.java subnode. That opens Bug.java in the source text editor.
Then I guess you have "Refresh automatically" under Preferences->General->Workspace checked. There is no need to create this externally. Here are steps to reproduce this internally. - create project P - create package foo - create package foo.bug - create CU Bug in foo.bug, but chage package declaration statement to bug - save file. observe: you correctly get a compile error - select package foo - execute Build Path->Use as source folder - answer all questions with Yes. observe: a compile is triggered and the problem is removed from the problem view and the package explorer. However, the problem in the editor stays.
*** This bug has been marked as a duplicate of 65267 ***