Bug 216772 - IJavaModel#refreshExternalArchives fails to refresh ExternalJavaProject jar cache
Summary: IJavaModel#refreshExternalArchives fails to refresh ExternalJavaProject jar c...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.3.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.5 M1   Edit
Assignee: Jerome Lanneluc CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-01-28 09:56 EST by Fedronic valere CLA
Modified: 2008-08-06 13:54 EDT (History)
1 user (show)

See Also:


Attachments
The junit plugin test (6.84 KB, application/zip)
2008-01-28 09:56 EST, Fedronic valere CLA
no flags Details
Proposed fix and regression test (5.63 KB, patch)
2008-05-16 10:35 EDT, Jerome Lanneluc CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Fedronic valere CLA 2008-01-28 09:56:14 EST
Created attachment 88015 [details]
The junit plugin test

Build ID: I20071213-1700

Steps To Reproduce:
The attached file contains a JunitTest that highlights the bug.
Just run the test 'testRefresh'

This is the scenario :

1) create a project with a jar file 'ext.jar' that contains a single class Ext.java with 'public static void foo()' method.

2) create a CompilationUnit with no associated java project, this is done thanks to the API WorkingCopyOwner#newWorkingCopy(String name, IClasspathEntry[] classpath, IProgressMonitor monitor)

3) The created CompilationUnit has only the main() method that make a call to the Ext.java#foo() method.

4) We can assert that there is no compilation problems (cu.reconcile())

5) Change the ext.jar contents with a new Ext.java class with a method bar() (instead of foo).

6) Update the java model (cu.getJavaModel().refreshExternalArchives()

7) Reconcile again

Expected : An error should detected (the foo() method doesn't exist)

Actual : No error, the jar model is out of synch.




More information:

Reproducible with 3.3.1.1 and 3.4M4

The problem seems to be that the DeltaProcessor#createExternalArchiveDelta() returns false in this case. It doesn't try to refresh the java projects because it considers that there are no java projects. But in fact there is an ExternalJavaProject.


I found a work around, but it use some discouraged access, and doesn't scale well :

packageFragmentRoot.close();
JavaModelManager.getJavaModelManager().getDeltaProcessor().projectCachesToReset.add(cu.getJavaProject());
JavaModelManager.getJavaModelManager().getDeltaProcessor().resetProjectCaches();
Comment 1 Jerome Lanneluc CLA 2008-05-16 10:35:42 EDT
Created attachment 100646 [details]
Proposed fix and regression test
Comment 2 Jerome Lanneluc CLA 2008-06-23 07:46:31 EDT
Fix and test released for 3.5M1
Comment 3 Olivier Thomann CLA 2008-08-06 13:54:51 EDT
Verified for 3.5M1 using I20080805-1307