Bug 10996 - createCompilationUnit doesn't behave as described in the documentation
Summary: createCompilationUnit doesn't behave as described in the documentation
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 2.0 M4   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-03-07 16:17 EST by Olivier Thomann CLA
Modified: 2002-03-13 13:06 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Olivier Thomann CLA 2002-03-07 16:17:53 EST
From EC:
"When I create a compilation unit using:
IPackageFragment.createCompilationUnit("test.java", "", true, null);
and "test.java" already exists, it does not overwrite it and instead
throws a CoreException. My understanding of the force flag was that if it
was set to true, it would automatically overwrite any compilation units of
the same name, if they existed. However, when I set the flag to either
false or true, it complains about "test.java" already existing."

This is still true in latest. If the flag force is true, the existing 
compilation unit should be overriden. If false, the actual behavior is correct.
Comment 1 Olivier Thomann CLA 2002-03-07 16:26:55 EST
The operation used is a CreateCompilationUnit operation. The documentation says 
that this operation will fail if the compilation unit already exists. The flag 
force is passed to the IFile.create method where the meaning is the way the 
plaform should handle files which are not synchronized with the local file 
system. So I guess there is a confusion in the meaning of the flag force between 
the JDT/Core API and the Platform/Core API.
CreateCompilationUnitOperation should not fail if the compilation unit already 
exists and the flag is true. It should simply override the contents of the 
existing compilation unit.
Comment 2 Philipe Mulet CLA 2002-03-11 05:53:07 EST
Agreed.
Comment 3 Olivier Thomann CLA 2002-03-13 12:21:11 EST
Fixed and released in HEAD. Model tests updated.
Comment 4 Victor Ng CLA 2002-03-13 12:40:53 EST
>> Fixed and released in HEAD. Model tests updated.
What do you mean by this? What should I download to get this fix?
Comment 5 Olivier Thomann CLA 2002-03-13 12:44:00 EST
It means that the fix is ready for the next integration build or night build. 
So wait for the next integration build and you will get the fix. Is this ok for 
you?
Comment 6 Victor Ng CLA 2002-03-13 13:06:41 EST
I'm currently using IBM WebSphere Application Developer, which is built on the 
Eclipse platform. Thus, I don't think I can just download the newest build, 
right? Is there a way I can just replace the newest eclipse jar (for that 
class) on top of the one I currently have?