Bug 36499 - exists() returns true for a source file inside a classfolder
Summary: exists() returns true for a source file inside a classfolder
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.1   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 3.0 M1   Edit
Assignee: Jerome Lanneluc CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-04-15 09:41 EDT by Olivier Thomann CLA
Modified: 2003-06-06 06:03 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Olivier Thomann CLA 2003-04-15 09:41:55 EDT
Using 2.1, exists() on a compilation unit handle returns true if the source file
is located inside a classfolder. It should return false.

Steps to reproduce:
1) Start a fresh workspace
2) Create a java project P
3) Unzip the attached file in the parent folder of the folder P
4) Refresh P
5) You might have to create a source folder src and the output folder bin.
6) Open the class folder, click on MyLinkedClass.class. You will get a source
for it even if there is no source attachement for this class folder. The problem
is that the outliner doesn't synchronize.

The bug is located in the NameLookup.findCompilationUnit(...). This method
should returns null for a compilation unit located in a classfolder. We might
have the same issue for a .class file located in a source folder.

See bug 36337 for the original problem.
Comment 1 Philipe Mulet CLA 2003-04-16 03:45:38 EDT
Agreed. Reciprocally a classfile in source folder shouldn't exist either.
Comment 2 Philipe Mulet CLA 2003-04-16 08:26:11 EDT
Should also deal with exclusion if source kind.

Q: can we still open such elements ? i.e. would exist() fix be enough ?
Comment 3 Jerome Lanneluc CLA 2003-04-17 09:31:22 EDT
Overrode exists() and openwhenClosed() on CompilationUnit and ClassFile so that 
they check if the cu or class file is of the right kind (and not excluded for a 
cu).

Added regression tests on ExsistenceTests: testClassFileInSource1, 
testClassFileInSource2, testCompilationUnitInLibrary1 and 
testCompilationUnitInLibrary2.
Comment 4 David Audel CLA 2003-06-06 06:03:49 EDT
Verified.