This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 84603
Collapse All | Expand All

(-)src/org/netbeans/modules/javacore/classpath/MergedClassPathImplementation.java (-18 / +40 lines)
Lines 269-306 Link Here
269
            this.addClassPath (cp);
269
            this.addClassPath (cp);
270
        }
270
        }
271
    }
271
    }
272
    
273
    private int updateEntriesCounter;
272
274
273
    private void updateEntries (ClassPath cp) {
275
    private void updateEntries (ClassPath cp) {
274
        
276
        
275
        boolean fire = false;
277
        boolean fire = false;
276
        List oldResources;
278
        List oldResources;
279
        int id;
277
        synchronized (this) {
280
        synchronized (this) {
278
            oldResources = (List) this.resourceMap.remove (cp);
281
            id = ++updateEntriesCounter;
282
            oldResources = (List) this.resourceMap.get (cp);
279
            assert oldResources != null : "Change in unknown classpath"; // NOI18N
283
            assert oldResources != null : "Change in unknown classpath"; // NOI18N
280
        }
284
        }
281
        List newResources = addClassPathResources (cp);
285
        List newResources = addClassPathResources (cp);
282
        synchronized (this) {
286
        synchronized (this) {
283
            Collection toRemove = new HashSet (oldResources);
287
            if (id==updateEntriesCounter) {
284
            toRemove.removeAll (newResources);
288
                Collection toRemove = new HashSet (oldResources);
285
            newResources.removeAll (oldResources);  //To Add
289
                toRemove.removeAll (newResources);
286
            for (Iterator it = toRemove.iterator(); it.hasNext();) {
290
                newResources.removeAll (oldResources);  //To Add
287
                PathResourceImplementation resource = (PathResourceImplementation) it.next();
291
                for (Iterator it = toRemove.iterator(); it.hasNext();) {
288
                oldResources.remove(resource);
292
                    PathResourceImplementation resource = (PathResourceImplementation) it.next();
289
                if (!this.cachedResources.remove(resource)) {
293
                    oldResources.remove(resource);
290
                    if (!this.unresolvedRoots.remove (resource)) {
294
                    if (!this.cachedResources.remove(resource)) {
291
                        missingRoots.remove(resource.getRoots()[0]);
295
                        if (!this.unresolvedRoots.remove (resource)) {
296
                            missingRoots.remove(resource.getRoots()[0]);
297
                        }
298
                    }
299
                    else {
300
                        fire = true;
292
                    }
301
                    }
293
                }
302
                }
294
                else {
303
                for (Iterator it = newResources.iterator(); it.hasNext();) {
295
                    fire = true;
304
                    PathResourceImplementation resource = (PathResourceImplementation) it.next();
305
                    oldResources.add (resource);
296
                }
306
                }
307
                this.resourceMap.put (cp,oldResources);
308
                this.unresolvedRoots.addAll(newResources);
297
            }
309
            }
298
            for (Iterator it = newResources.iterator(); it.hasNext();) {
299
                PathResourceImplementation resource = (PathResourceImplementation) it.next();
300
                oldResources.add (resource);
301
            }
302
            this.resourceMap.put (cp,oldResources);
303
            this.unresolvedRoots.addAll(newResources);
304
        }
310
        }
305
        if (fire) {
311
        if (fire) {
306
            this.firePropertyChange(PROP_RESOURCES);
312
            this.firePropertyChange(PROP_RESOURCES);
Lines 454-459 Link Here
454
                    Object wpk = pair.getKey();
460
                    Object wpk = pair.getKey();
455
                    if (key.equals(wpk)) {
461
                    if (key.equals(wpk)) {
456
                        it.remove();
462
                        it.remove();
463
                        return pair.getValue();
464
                    }
465
                }
466
            }
467
            return null;
468
        }
469
        
470
        public Object get (Object key) {
471
            if (key == null) {
472
                return null;
473
            }
474
            synchronized (MergedClassPathImplementation.this) {
475
                for (Iterator it = this.data.iterator(); it.hasNext();) {
476
                    WeakPair pair = (WeakPair) it.next ();
477
                    Object wpk = pair.getKey();
478
                    if (key.equals(wpk)) {
457
                        return pair.getValue();
479
                        return pair.getValue();
458
                    }
480
                    }
459
                }
481
                }

Return to bug 84603