Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 488532

Summary: Compilation unit exists when its parent doesn't
Product: [Eclipse Project] JDT Reporter: Vladimir Piskarev <pisv>
Component: CoreAssignee: JDT-Core-Inbox <jdt-core-inbox>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: stephan.herrmann
Version: 4.5.1   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard: stalebug
Attachments:
Description Flags
Test projects none

Description Vladimir Piskarev CLA 2016-02-26 03:11:50 EST
Created attachment 259950 [details]
Test projects

It can be demonstrated that a compilation unit (not a working copy) can answer true from #exists() when its parent package fragment doesn't exist in the Java model. Probably not a big deal but might be worth reporting.

Steps to reproduce:

1. Import the two projects from the attached test.zip (don't import the nested 'TestProject')

2. Run the 'test' project as JUnit Plug-in Test

3. Observe the failing test

Perhaps it would be a bit more consistent if Openable#exists() explicitly checked for parent existence? Something like this:

public boolean exists() {
    if (JavaModelManager.getJavaModelManager().getInfo(this) != null)
        return true;
    IJavaElement parent = getParent();
    if (parent != null && !parent.exists())
        return false;
    ...
}
Comment 1 Eclipse Genie CLA 2019-11-23 13:51:39 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.