Community
Participate
Working Groups
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.
Agreed. Reciprocally a classfile in source folder shouldn't exist either.
Should also deal with exclusion if source kind. Q: can we still open such elements ? i.e. would exist() fix be enough ?
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.
Verified.