Bug 97524

Summary: [prefs] Importing preferences with user library doesn't recreate jar entries
Product: [Eclipse Project] JDT Reporter: Jerome Lanneluc <jerome_lanneluc>
Component: CoreAssignee: Frederic Fusier <frederic_fusier>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: Brian_Young, martinae, qdang
Version: 3.1   
Target Milestone: 3.1 RC2   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Proposed fix
none
Proposed fix (put back method comment) none

Description Jerome Lanneluc CLA 2005-05-31 11:20:28 EDT
3.1 RC1

1. Add a user library 'TEST' with 1 jar
2. Export all preferences
3. New workspace
4. Import the saved preferences
Observe: the user library 'TEST' is recreated but it has no jar
Comment 1 Frederic Fusier CLA 2005-05-31 12:21:27 EDT
While fixing bug 88719, martin said that Import/Export for User Libraries do not
use JDT/Core code...
=> Move to JDT/UI
Comment 2 Dirk Baeumer CLA 2005-05-31 13:20:42 EDT
Martin, can you please comment. I thought user libraries use JDT/Core code ?
Comment 3 Martin Aeschlimann CLA 2005-06-01 03:40:51 EDT
There are two different import/exports:
- On the user library page you can import/export one or a selection of
libraries. This is all jdt.ui and uses a own xml file format

- On File -> Export -> Preferences you can export all preferences. In 3.0 this
included all user libararies as (jdt.core) persists them in the preference
store, similar to the classpath variables. The code that listens to the
preference change and updates the internal user library store is all in jdt.core.

Jerome, I assume you referred to the second import/export.
Comment 4 Frederic Fusier CLA 2005-06-01 04:25:10 EDT
Looking at comment 0, it seems correct that it's the second import/export which
is used => so I agree it's for me...
Comment 5 Frederic Fusier CLA 2005-06-01 04:29:22 EDT
I can reproduce it only if Java perspective has not been opened.
As soon as, Java perspective is opened, if I redo the import, then user library
has its jar correctly set...
I guess this is normal behavior as Java model is not initialized until JDT/Core
plugin has not been started and so listeners are not activated...
OK to close?
Comment 6 Martin Aeschlimann CLA 2005-06-01 04:37:04 EDT
But when the Java model finally initializes, wouldn't it read the preferences
and get the new library and its JAR?
Comment 7 Frederic Fusier CLA 2005-06-01 05:30:58 EDT
This is already the case...
You do not need to perform import again after having opened Java perspective.
Following scenario prove that listener is well activated when Java model starts:
1) Open new workspace (Do not open Java perspective!)
2) In Resources perspective, import preferences with user Library 'TEST'
3) Look at User Library in Java>Build path>User Libraries preferences page
   => TEST has no jar defined
4) Open Java perspective
5) Look at User Library in Java>Build path>User Libraries preferences page
   => TEST has 1 jar defined
Comment 8 Martin Aeschlimann CLA 2005-06-01 05:38:01 EDT
That still looks like a bug: In step 3, the User library page uses jdt.core
functionality (JavaCore.getUserLibraryNames()) to get all the library names.
This should activate the jdt.core plugin and return correct result.

I suggest to reopen.
Comment 9 Frederic Fusier CLA 2005-06-01 05:49:14 EDT
ok to reopen. I'll have a look later to see what exactly happen there...
Comment 10 Frederic Fusier CLA 2005-06-01 05:49:39 EDT
...but post 3.1
Comment 11 Martin Aeschlimann CLA 2005-06-01 06:01:09 EDT
My feeling is that this points to a deeper problem with container
initialization. The first call seems to return no child entries even if it should.
Comment 12 Frederic Fusier CLA 2005-06-09 12:30:17 EDT
I have a fix for this bug...
Comment 13 Frederic Fusier CLA 2005-06-09 12:34:56 EDT
Created attachment 22712 [details]
Proposed fix
Comment 14 Philipe Mulet CLA 2005-06-09 12:42:17 EDT
+1 for RC2
Comment 15 Frederic Fusier CLA 2005-06-09 12:43:55 EDT
Created attachment 22719 [details]
Proposed fix (put back method comment)
Comment 16 Frederic Fusier CLA 2005-06-09 13:16:01 EDT
Fixed and released in HEAD.

Note that implemented patch is only a hack as JavaModelManager does not expect
to receive JavaProject which does not have a Java nature.
We need to figure out how JDT can handle User Libraries informations more
properly than using a dummy project.
I'll open bugs to follow-up future work in this area...

[jdt-core internal]
Change done in JavaModelManager.initializeAllContainers(...)

No test case currently added, but all existing ones pass (of course)
Comment 17 Frederic Fusier CLA 2005-06-09 13:44:16 EDT
I've opened 2 bugs for work about dummy project removal:
bug 99208: JDT/Core work to provide API methods to get/store user librairies info
bug 99210: JDT/UI work to remove dummy project usage when 99208 will be fixed
Comment 18 Olivier Thomann CLA 2005-06-09 18:28:25 EDT
Verified in I20050609-1605.
Comment 19 Frederic Fusier CLA 2005-06-10 04:27:37 EDT
*** Bug 73099 has been marked as a duplicate of this bug. ***
Comment 20 Jerome Lanneluc CLA 2005-06-10 09:28:03 EDT
Verified with I20050610-0010