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 76787
Collapse All | Expand All

(-)nbproject/project.properties (-1 / +3 lines)
Lines 10-15 Link Here
10
# Microsystems, Inc. All Rights Reserved.
10
# Microsystems, Inc. All Rights Reserved.
11
11
12
is.autoload=true
12
is.autoload=true
13
javac.compilerargs=-Xlint:unchecked
14
javac.source=1.5
13
javadoc.apichanges=${basedir}/doc/changes/apichanges.xml
15
javadoc.apichanges=${basedir}/doc/changes/apichanges.xml
14
javadoc.arch=${basedir}/arch.xml
16
javadoc.arch=${basedir}/arch.xml
15
javadoc.title=Java Support APIs
17
javadoc.title=Java Support APIs
Lines 21-24 Link Here
21
    ${core.dir}/lib/boot.jar:\
23
    ${core.dir}/lib/boot.jar:\
22
    ${core.dir}/core/core.jar:\
24
    ${core.dir}/core/core.jar:\
23
    ${openide/util.dir}/lib/org-openide-util.jar:\
25
    ${openide/util.dir}/lib/org-openide-util.jar:\
24
    ${openide/modules.dir}/lib/org-openide-modules.jar
26
    ${openide/modules.dir}/lib/org-openide-modules.jar
(-)src/org/netbeans/api/java/classpath/ClassPath.java (-31 / +27 lines)
Lines 168-181 Link Here
168
    
168
    
169
    private static final ErrorManager ERR = ErrorManager.getDefault().getInstance(ClassPath.class.getName());
169
    private static final ErrorManager ERR = ErrorManager.getDefault().getInstance(ClassPath.class.getName());
170
    
170
    
171
    private static final Lookup.Result/*<ClassPathProvider>*/ implementations =
171
    private static final Lookup.Result<? extends ClassPathProvider> implementations =
172
        Lookup.getDefault().lookup(new Lookup.Template(ClassPathProvider.class));
172
        Lookup.getDefault().lookupResult(ClassPathProvider.class);
173
173
174
    private ClassPathImplementation impl;
174
    private ClassPathImplementation impl;
175
    private FileObject[] rootsCache;
175
    private FileObject[] rootsCache;
176
    private PropertyChangeListener pListener;
176
    private PropertyChangeListener pListener;
177
    private RootsListener rootsListener;
177
    private RootsListener rootsListener;
178
    private List entriesCache;
178
    private List<ClassPath.Entry> entriesCache;
179
179
180
    /**
180
    /**
181
     * Retrieves valid roots of ClassPath, in the proper order.
181
     * Retrieves valid roots of ClassPath, in the proper order.
Lines 187-196 Link Here
187
     */
187
     */
188
    public synchronized FileObject[]  getRoots() {
188
    public synchronized FileObject[]  getRoots() {
189
        if (rootsCache == null || rootsListener == null) {
189
        if (rootsCache == null || rootsListener == null) {
190
            List entries = this.entries();
190
            List<ClassPath.Entry> entries = this.entries();
191
            List l = new ArrayList ();
191
            List<FileObject> l = new ArrayList<FileObject> ();
192
            for (Iterator it = entries.iterator(); it.hasNext();) {
192
            for (Entry entry : entries) {
193
                Entry entry = (Entry) it.next();
194
                RootsListener rootsListener = this.getRootsListener();
193
                RootsListener rootsListener = this.getRootsListener();
195
                if (rootsListener != null) {
194
                if (rootsListener != null) {
196
                    rootsListener.addRoot (entry.getURL());
195
                    rootsListener.addRoot (entry.getURL());
Lines 199-205 Link Here
199
                if (fo != null)
198
                if (fo != null)
200
                    l.add (fo);
199
                    l.add (fo);
201
            }
200
            }
202
            this.rootsCache = (FileObject[]) l.toArray (new FileObject[l.size()]);
201
            this.rootsCache = l.toArray (new FileObject[l.size()]);
203
        }
202
        }
204
        return this.rootsCache;        
203
        return this.rootsCache;        
205
    }
204
    }
Lines 211-234 Link Here
211
     * instance. Clients must assume that the returned value is immutable.
210
     * instance. Clients must assume that the returned value is immutable.
212
     * @return list of definition entries (Entry instances)
211
     * @return list of definition entries (Entry instances)
213
     */
212
     */
214
    public  List entries() {
213
    public  List<ClassPath.Entry> entries() {
215
        synchronized (this) {
214
        synchronized (this) {
216
            if (this.entriesCache != null) {
215
            if (this.entriesCache != null) {
217
                return this.entriesCache;
216
                return this.entriesCache;
218
            }
217
            }
219
        }
218
        }
220
        List resources = impl.getResources();
219
        List<? extends PathResourceImplementation> resources = impl.getResources();
221
        synchronized (this) {
220
        synchronized (this) {
222
            if (this.entriesCache == null) {
221
            if (this.entriesCache == null) {
223
                //The ClassPathImplementation.getResources () should never return
222
                //The ClassPathImplementation.getResources () should never return
224
                // null but it was not explicitly stated in the javadoc
223
                // null but it was not explicitly stated in the javadoc
225
                if (resources == null) {
224
                if (resources == null) {
226
                    this.entriesCache = Collections.EMPTY_LIST;
225
                    this.entriesCache = Collections.<ClassPath.Entry>emptyList();
227
                }
226
                }
228
                else {
227
                else {
229
                    List cache = new ArrayList ();
228
                    List<ClassPath.Entry> cache = new ArrayList<ClassPath.Entry> ();
230
                    for (Iterator it = resources.iterator(); it.hasNext();) {
229
                    for (PathResourceImplementation pr : resources) {
231
                        PathResourceImplementation pr = (PathResourceImplementation)it.next();
232
                        URL[] roots = pr.getRoots();
230
                        URL[] roots = pr.getRoots();
233
                        for (int i=0; i <roots.length; i++) {
231
                        for (int i=0; i <roots.length; i++) {
234
                            Entry e = new Entry (roots[i]);
232
                            Entry e = new Entry (roots[i]);
Lines 277-285 Link Here
277
     * @param resourceName resource name
275
     * @param resourceName resource name
278
     * @return list of resources identified by the given name.
276
     * @return list of resources identified by the given name.
279
     */
277
     */
280
    public final List findAllResources(String resourceName) {
278
    public final List<? extends FileObject> findAllResources(String resourceName) {
281
	FileObject[] roots = getRoots();
279
	FileObject[] roots = getRoots();
282
        List l = new ArrayList(roots.length);
280
        List<FileObject> l = new ArrayList<FileObject>(roots.length);
283
        int[] idx = new int[] { 0 };
281
        int[] idx = new int[] { 0 };
284
        String[] namec = parseResourceName(resourceName);
282
        String[] namec = parseResourceName(resourceName);
285
        while (idx[0] < roots.length) {
283
        while (idx[0] < roots.length) {
Lines 347-353 Link Here
347
     */
345
     */
348
    public final FileObject findOwnerRoot(FileObject resource) {
346
    public final FileObject findOwnerRoot(FileObject resource) {
349
	FileObject[] roots = getRoots();
347
	FileObject[] roots = getRoots();
350
        Set/*<FileObject>*/ rootsSet = new HashSet(Arrays.asList(roots));
348
        Set<FileObject> rootsSet = new HashSet<FileObject>(Arrays.asList(roots));
351
        for (FileObject f = resource; f != null; f = f.getParent()) {
349
        for (FileObject f = resource; f != null; f = f.getParent()) {
352
            if (rootsSet.contains(f)) {
350
            if (rootsSet.contains(f)) {
353
                return f;
351
                return f;
Lines 439-447 Link Here
439
        }
437
        }
440
        boolean log = ERR.isLoggable(ErrorManager.INFORMATIONAL);
438
        boolean log = ERR.isLoggable(ErrorManager.INFORMATIONAL);
441
        if (log) ERR.log("CP.getClassPath: " + f + " of type " + id);
439
        if (log) ERR.log("CP.getClassPath: " + f + " of type " + id);
442
        Iterator it = implementations.allInstances().iterator();
440
        for (ClassPathProvider impl  : implementations.allInstances()) {
443
        while (it.hasNext()) {
444
            ClassPathProvider impl = (ClassPathProvider)it.next();
445
            ClassPath cp = impl.findClassPath(f, id);
441
            ClassPath cp = impl.findClassPath(f, id);
446
            if (cp != null) {
442
            if (cp != null) {
447
                if (log) ERR.log("  got result " + cp + " from " + impl);
443
                if (log) ERR.log("  got result " + cp + " from " + impl);
Lines 566-572 Link Here
566
     * name, the next one is either the extension or null.
562
     * name, the next one is either the extension or null.
567
     */
563
     */
568
    private static String[] parseResourceName(String name) {
564
    private static String[] parseResourceName(String name) {
569
        Collection parsed = new ArrayList(name.length() / 4);
565
        Collection<String> parsed = new ArrayList<String>(name.length() / 4);
570
        char[] chars = name.toCharArray();
566
        char[] chars = name.toCharArray();
571
        char ch;
567
        char ch;
572
        int pos = 0;
568
        int pos = 0;
Lines 609-615 Link Here
609
            System.err.println("parsed size is not even!!");
605
            System.err.println("parsed size is not even!!");
610
            System.err.println("input = " + name);
606
            System.err.println("input = " + name);
611
        }
607
        }
612
        return (String[])parsed.toArray(new String[parsed.size()]);
608
        return parsed.toArray(new String[parsed.size()]);
613
    }
609
    }
614
610
615
    /**
611
    /**
Lines 641-649 Link Here
641
        return f;
637
        return f;
642
    }
638
    }
643
639
644
    private static final Reference EMPTY_REF = new SoftReference(null);
640
    private static final Reference<ClassLoader> EMPTY_REF = new SoftReference<ClassLoader>(null);
645
641
646
    private Reference refClassLoader = EMPTY_REF;
642
    private Reference<ClassLoader> refClassLoader = EMPTY_REF;
647
643
648
    /* package private */synchronized void resetClassLoader(ClassLoader cl) {
644
    /* package private */synchronized void resetClassLoader(ClassLoader cl) {
649
        if (refClassLoader.get() == cl)
645
        if (refClassLoader.get() == cl)
Lines 663-674 Link Here
663
     */
659
     */
664
    public final synchronized ClassLoader getClassLoader(boolean cache) {
660
    public final synchronized ClassLoader getClassLoader(boolean cache) {
665
        // XXX consider adding ClassLoader and/or InputOutput and/or PermissionCollection params
661
        // XXX consider adding ClassLoader and/or InputOutput and/or PermissionCollection params
666
        Object o = refClassLoader.get();
662
        ClassLoader o = refClassLoader.get();
667
        if (!cache || o == null) {
663
        if (!cache || o == null) {
668
            o = ClassLoaderSupport.create(this);
664
            o = ClassLoaderSupport.create(this);
669
            refClassLoader = new SoftReference(o);
665
            refClassLoader = new SoftReference<ClassLoader>(o);
670
        }
666
        }
671
        return (ClassLoader)o;
667
        return o;
672
    }
668
    }
673
669
674
670
Lines 695-708 Link Here
695
    }
691
    }
696
692
697
693
698
    private static class RootsListener extends WeakReference implements FileChangeListener, Runnable {
694
    private static class RootsListener extends WeakReference<ClassPath> implements FileChangeListener, Runnable {
699
695
700
        private boolean initialized;
696
        private boolean initialized;
701
        private Set roots;
697
        private Set<String> roots;
702
698
703
        private RootsListener (ClassPath owner) {
699
        private RootsListener (ClassPath owner) {
704
            super (owner, Utilities.activeReferenceQueue());
700
            super (owner, Utilities.activeReferenceQueue());
705
            roots = new HashSet ();
701
            roots = new HashSet<String> ();
706
        }
702
        }
707
703
708
        public void addRoot (URL url) {
704
        public void addRoot (URL url) {
Lines 867-873 Link Here
867
                return fileSystems;
863
                return fileSystems;
868
            }
864
            }
869
            File[] roots = File.listRoots();
865
            File[] roots = File.listRoots();
870
            Set allRoots = new LinkedHashSet();
866
            Set<FileSystem> allRoots = new LinkedHashSet<FileSystem>();
871
            assert roots != null && roots.length > 0 : "Could not list file roots"; // NOI18N
867
            assert roots != null && roots.length > 0 : "Could not list file roots"; // NOI18N
872
            
868
            
873
            for (int i = 0; i < roots.length; i++) {
869
            for (int i = 0; i < roots.length; i++) {
(-)src/org/netbeans/api/java/classpath/GlobalPathRegistry.java (-37 / +27 lines)
Lines 17-26 Link Here
17
import java.beans.PropertyChangeListener;
17
import java.beans.PropertyChangeListener;
18
import java.util.ArrayList;
18
import java.util.ArrayList;
19
import java.util.Arrays;
19
import java.util.Arrays;
20
import java.util.Collection;
21
import java.util.Collections;
20
import java.util.Collections;
22
import java.util.EventListener;
23
import java.util.EventObject;
24
import java.util.HashMap;
21
import java.util.HashMap;
25
import java.util.HashSet;
22
import java.util.HashSet;
26
import java.util.Iterator;
23
import java.util.Iterator;
Lines 91-100 Link Here
91
    }
88
    }
92
    
89
    
93
    private int resetCount;
90
    private int resetCount;
94
    private final Map/*<String,List<ClassPath>>*/ paths = new HashMap();
91
    private final Map<String,List<ClassPath>> paths = new HashMap<String,List<ClassPath>>();
95
    private final List/*<PathRegistryListener>*/ listeners = new ArrayList();
92
    private final List<GlobalPathRegistryListener> listeners = new ArrayList<GlobalPathRegistryListener>();
96
    private Set/*<FileObject>*/ sourceRoots = null;
93
    private Set<FileObject> sourceRoots = null;
97
    private Set/*ChangeListener*/ results = new HashSet ();
94
    private Set<SourceForBinaryQuery.Result> results = new HashSet<SourceForBinaryQuery.Result>();
98
    
95
    
99
    
96
    
100
    private final ChangeListener resultListener = new SFBQListener ();
97
    private final ChangeListener resultListener = new SFBQListener ();
Lines 121-135 Link Here
121
     * @param id a classpath type, e.g. {@link ClassPath#SOURCE}
118
     * @param id a classpath type, e.g. {@link ClassPath#SOURCE}
122
     * @return an immutable set of all registered {@link ClassPath}s of that type (may be empty but not null)
119
     * @return an immutable set of all registered {@link ClassPath}s of that type (may be empty but not null)
123
     */
120
     */
124
    public synchronized Set/*<ClassPath>*/ getPaths(String id) {
121
    public synchronized Set<ClassPath> getPaths(String id) {
125
        if (id == null) {
122
        if (id == null) {
126
            throw new NullPointerException();
123
            throw new NullPointerException();
127
        }
124
        }
128
        List l = (List)paths.get(id);
125
        List<ClassPath> l = paths.get(id);
129
        if (l != null && !l.isEmpty()) {
126
        if (l != null && !l.isEmpty()) {
130
            return Collections.unmodifiableSet(new HashSet(l));
127
            return Collections.unmodifiableSet(new HashSet<ClassPath>(l));
131
        } else {
128
        } else {
132
            return Collections.EMPTY_SET;
129
            return Collections.<ClassPath>emptySet();
133
        }
130
        }
134
    }
131
    }
135
    
132
    
Lines 145-156 Link Here
145
        GlobalPathRegistryEvent evt = null;
142
        GlobalPathRegistryEvent evt = null;
146
        GlobalPathRegistryListener[] _listeners = null;
143
        GlobalPathRegistryListener[] _listeners = null;
147
        synchronized (this) {
144
        synchronized (this) {
148
            List l = (List)this.paths.get(id);
145
            List<ClassPath> l = this.paths.get(id);
149
            if (l == null) {
146
            if (l == null) {
150
                l = new ArrayList();
147
                l = new ArrayList<ClassPath>();
151
                this.paths.put(id, l);
148
                this.paths.put(id, l);
152
            }
149
            }
153
            Set/*<ClassPath>*/ added = listeners.isEmpty() ? null : new HashSet();
150
            Set<ClassPath> added = listeners.isEmpty() ? null : new HashSet<ClassPath>();
154
            for (int i = 0; i < paths.length; i++) {
151
            for (int i = 0; i < paths.length; i++) {
155
                if (paths[i] == null) {
152
                if (paths[i] == null) {
156
                    throw new NullPointerException("Null path encountered in " + Arrays.asList(paths) + " of type " + id); // NOI18N
153
                    throw new NullPointerException("Null path encountered in " + Arrays.asList(paths) + " of type " + id); // NOI18N
Lines 164-170 Link Here
164
                l.add(paths[i]);
161
                l.add(paths[i]);
165
            }
162
            }
166
            if (added != null && !added.isEmpty()) {
163
            if (added != null && !added.isEmpty()) {
167
                _listeners = (GlobalPathRegistryListener[])listeners.toArray(new GlobalPathRegistryListener[listeners.size()]);
164
                _listeners = listeners.toArray(new GlobalPathRegistryListener[listeners.size()]);
168
                evt = new GlobalPathRegistryEvent(this, id, Collections.unmodifiableSet(added));
165
                evt = new GlobalPathRegistryEvent(this, id, Collections.unmodifiableSet(added));
169
            }
166
            }
170
            // Invalidate cache for getSourceRoots and findResource:
167
            // Invalidate cache for getSourceRoots and findResource:
Lines 191-202 Link Here
191
        GlobalPathRegistryEvent evt = null;
188
        GlobalPathRegistryEvent evt = null;
192
        GlobalPathRegistryListener[] _listeners = null;
189
        GlobalPathRegistryListener[] _listeners = null;
193
        synchronized (this) {
190
        synchronized (this) {
194
            List l = (List)this.paths.get(id);
191
            List<ClassPath> l = this.paths.get(id);
195
            if (l == null) {
192
            if (l == null) {
196
                l = new ArrayList();
193
                l = new ArrayList<ClassPath>();
197
            }
194
            }
198
            List l2 = new ArrayList(l); // in case IAE thrown below
195
            List<ClassPath> l2 = new ArrayList<ClassPath>(l); // in case IAE thrown below
199
            Set/*<ClassPath>*/ removed = listeners.isEmpty() ? null : new HashSet();
196
            Set<ClassPath> removed = listeners.isEmpty() ? null : new HashSet<ClassPath>();
200
            for (int i = 0; i < paths.length; i++) {
197
            for (int i = 0; i < paths.length; i++) {
201
                if (paths[i] == null) {
198
                if (paths[i] == null) {
202
                    throw new NullPointerException();
199
                    throw new NullPointerException();
Lines 213-219 Link Here
213
            }
210
            }
214
            this.paths.put(id, l2);
211
            this.paths.put(id, l2);
215
            if (removed != null && !removed.isEmpty()) {
212
            if (removed != null && !removed.isEmpty()) {
216
                _listeners = (GlobalPathRegistryListener[])listeners.toArray(new GlobalPathRegistryListener[listeners.size()]);
213
                _listeners = listeners.toArray(new GlobalPathRegistryListener[listeners.size()]);
217
                evt = new GlobalPathRegistryEvent(this, id, Collections.unmodifiableSet(removed));
214
                evt = new GlobalPathRegistryEvent(this, id, Collections.unmodifiableSet(removed));
218
            }
215
            }
219
            resetSourceRootsCache ();
216
            resetSourceRootsCache ();
Lines 267-300 Link Here
267
     * </p>
264
     * </p>
268
     * @return an immutable set of <code>FileObject</code> source roots
265
     * @return an immutable set of <code>FileObject</code> source roots
269
     */
266
     */
270
    public Set/*<FileObject>*/ getSourceRoots() {        
267
    public Set<? extends FileObject> getSourceRoots() {        
271
        int currentResetCount;
268
        int currentResetCount;
272
        Set/*<ClassPath>*/ sourcePaths, compileAndBootPaths;
269
        Set<ClassPath> sourcePaths, compileAndBootPaths;
273
        synchronized (this) {
270
        synchronized (this) {
274
            if (this.sourceRoots != null) {
271
            if (this.sourceRoots != null) {
275
                return this.sourceRoots;
272
                return this.sourceRoots;
276
            }            
273
            }            
277
            currentResetCount = this.resetCount;
274
            currentResetCount = this.resetCount;
278
            sourcePaths = getPaths(ClassPath.SOURCE);
275
            sourcePaths = getPaths(ClassPath.SOURCE);
279
            compileAndBootPaths = new LinkedHashSet(getPaths(ClassPath.COMPILE));
276
            compileAndBootPaths = new LinkedHashSet<ClassPath>(getPaths(ClassPath.COMPILE));
280
            compileAndBootPaths.addAll(getPaths(ClassPath.BOOT));
277
            compileAndBootPaths.addAll(getPaths(ClassPath.BOOT));
281
        }
278
        }
282
        
279
        
283
        Set newSourceRoots = new LinkedHashSet();                    
280
        Set<FileObject> newSourceRoots = new LinkedHashSet<FileObject>();
284
        Iterator it = sourcePaths.iterator();
281
        for (ClassPath sp : sourcePaths) {
285
        while (it.hasNext()) {
286
            ClassPath sp = (ClassPath)it.next();
287
            newSourceRoots.addAll(Arrays.asList(sp.getRoots()));
282
            newSourceRoots.addAll(Arrays.asList(sp.getRoots()));
288
        }
283
        }
289
        
284
        
290
        final List newResults = new LinkedList ();
285
        final List<SourceForBinaryQuery.Result> newResults = new LinkedList<SourceForBinaryQuery.Result> ();
291
        final ChangeListener tmpResultListener = new SFBQListener ();
286
        final ChangeListener tmpResultListener = new SFBQListener ();
292
        it = compileAndBootPaths.iterator();
287
        for (ClassPath cp : compileAndBootPaths) {
293
        while (it.hasNext()) {
288
            for (ClassPath.Entry entry : cp.entries()) {
294
            ClassPath cp = (ClassPath)it.next();
295
            Iterator it2 = cp.entries().iterator();
296
            while (it2.hasNext()) {
297
                ClassPath.Entry entry = (ClassPath.Entry)it2.next();
298
                SourceForBinaryQuery.Result result = SourceForBinaryQuery.findSourceRoots(entry.getURL());
289
                SourceForBinaryQuery.Result result = SourceForBinaryQuery.findSourceRoots(entry.getURL());
299
                result.addChangeListener(tmpResultListener);
290
                result.addChangeListener(tmpResultListener);
300
                newResults.add (result);
291
                newResults.add (result);
Lines 318-326 Link Here
318
    }
309
    }
319
    
310
    
320
    
311
    
321
    private void removeTmpSFBQListeners (List/*<SourceForBinaryQuery.Result>*/ results, ChangeListener listener, boolean addListener) {
312
    private void removeTmpSFBQListeners (List<? extends SourceForBinaryQuery.Result> results, ChangeListener listener, boolean addListener) {
322
        for (Iterator/*<SourceForBinaryQuery.Result>*/ it = results.iterator(); it.hasNext(); ) {
313
        for (SourceForBinaryQuery.Result res : results) {
323
            SourceForBinaryQuery.Result res = (SourceForBinaryQuery.Result) it.next();
324
            if (addListener) {
314
            if (addListener) {
325
                res.addChangeListener (this.resultListener);
315
                res.addChangeListener (this.resultListener);
326
            }
316
            }
(-)src/org/netbeans/api/java/classpath/GlobalPathRegistryEvent.java (-3 / +3 lines)
Lines 21-29 Link Here
21
public final class GlobalPathRegistryEvent extends EventObject {
21
public final class GlobalPathRegistryEvent extends EventObject {
22
22
23
    private final String id;
23
    private final String id;
24
    private final Set/*<ClassPath>*/ changed;
24
    private final Set<ClassPath> changed;
25
25
26
    GlobalPathRegistryEvent(GlobalPathRegistry r, String id, Set/*<ClassPath>*/ changed) {
26
    GlobalPathRegistryEvent(GlobalPathRegistry r, String id, Set<ClassPath> changed) {
27
        super(r);
27
        super(r);
28
        assert id != null;
28
        assert id != null;
29
        assert changed != null && !changed.isEmpty();
29
        assert changed != null && !changed.isEmpty();
Lines 51-57 Link Here
51
     * Get a set of classpaths that were added or removed.
51
     * Get a set of classpaths that were added or removed.
52
     * @return an immutable and nonempty set of {@link ClassPath}s of the given type
52
     * @return an immutable and nonempty set of {@link ClassPath}s of the given type
53
     */
53
     */
54
    public Set/*<ClassPath>*/ getChangedPaths() {
54
    public Set<ClassPath> getChangedPaths() {
55
        return changed;
55
        return changed;
56
    }
56
    }
57
57
(-)src/org/netbeans/api/java/queries/AccessibilityQuery.java (-6 / +3 lines)
Lines 12-18 Link Here
12
 */
12
 */
13
package org.netbeans.api.java.queries;
13
package org.netbeans.api.java.queries;
14
14
15
import java.util.Iterator;
16
import org.netbeans.spi.java.queries.AccessibilityQueryImplementation;
15
import org.netbeans.spi.java.queries.AccessibilityQueryImplementation;
17
import org.openide.util.Lookup;
16
import org.openide.util.Lookup;
18
import org.openide.filesystems.FileObject;
17
import org.openide.filesystems.FileObject;
Lines 39-46 Link Here
39
 */
38
 */
40
public class AccessibilityQuery {
39
public class AccessibilityQuery {
41
    
40
    
42
    private static final Lookup.Result/*<AccessibilityQueryImplementation>*/ implementations =
41
    private static final Lookup.Result<? extends AccessibilityQueryImplementation> implementations =
43
        Lookup.getDefault().lookup(new Lookup.Template(AccessibilityQueryImplementation.class));
42
        Lookup.getDefault().lookupResult(AccessibilityQueryImplementation.class);
44
43
45
    private AccessibilityQuery() {}
44
    private AccessibilityQuery() {}
46
45
Lines 60-68 Link Here
60
        if (!pkg.isFolder()) {
59
        if (!pkg.isFolder()) {
61
            throw new IllegalArgumentException("Not a folder: " + pkg); // NOI18N
60
            throw new IllegalArgumentException("Not a folder: " + pkg); // NOI18N
62
        }
61
        }
63
        Iterator it = implementations.allInstances().iterator();
62
        for ( AccessibilityQueryImplementation aqi : implementations.allInstances()) {
64
        while (it.hasNext()) {
65
            AccessibilityQueryImplementation aqi = (AccessibilityQueryImplementation)it.next();
66
            Boolean b = aqi.isPubliclyAccessible(pkg);
63
            Boolean b = aqi.isPubliclyAccessible(pkg);
67
            if (b != null) {
64
            if (b != null) {
68
                return b;
65
                return b;
(-)src/org/netbeans/api/java/queries/JavadocForBinaryQuery.java (-6 / +3 lines)
Lines 15-21 Link Here
15
15
16
import java.net.URL;
16
import java.net.URL;
17
import java.util.Arrays;
17
import java.util.Arrays;
18
import java.util.Iterator;
19
import javax.swing.event.ChangeListener;
18
import javax.swing.event.ChangeListener;
20
import org.netbeans.spi.java.queries.JavadocForBinaryQueryImplementation;
19
import org.netbeans.spi.java.queries.JavadocForBinaryQueryImplementation;
21
import org.openide.ErrorManager;
20
import org.openide.ErrorManager;
Lines 31-38 Link Here
31
    
30
    
32
    private static final ErrorManager ERR = ErrorManager.getDefault().getInstance(JavadocForBinaryQuery.class.getName());
31
    private static final ErrorManager ERR = ErrorManager.getDefault().getInstance(JavadocForBinaryQuery.class.getName());
33
    
32
    
34
    private static final Lookup.Result/*<JavadocForBinaryQueryImplementation>*/ implementations =
33
    private static final Lookup.Result<? extends JavadocForBinaryQueryImplementation> implementations =
35
        Lookup.getDefault().lookup (new Lookup.Template (JavadocForBinaryQueryImplementation.class));
34
        Lookup.getDefault().lookupResult(JavadocForBinaryQueryImplementation.class);
36
35
37
    private JavadocForBinaryQuery () {
36
    private JavadocForBinaryQuery () {
38
    }
37
    }
Lines 54-62 Link Here
54
        }
53
        }
55
        boolean log = ERR.isLoggable(ErrorManager.INFORMATIONAL);
54
        boolean log = ERR.isLoggable(ErrorManager.INFORMATIONAL);
56
        if (log) ERR.log("JFBQ.findJavadoc: " + binary);
55
        if (log) ERR.log("JFBQ.findJavadoc: " + binary);
57
        Iterator it = implementations.allInstances().iterator();
56
        for  (JavadocForBinaryQueryImplementation impl : implementations.allInstances()) {
58
        while (it.hasNext()) {
59
            JavadocForBinaryQueryImplementation impl = (JavadocForBinaryQueryImplementation) it.next();
60
            Result r = impl.findJavadoc(binary);
57
            Result r = impl.findJavadoc(binary);
61
            if (r != null) {
58
            if (r != null) {
62
                if (log) ERR.log("  got result " + Arrays.asList(r.getRoots()) + " from " + impl);
59
                if (log) ERR.log("  got result " + Arrays.asList(r.getRoots()) + " from " + impl);
(-)src/org/netbeans/api/java/queries/SourceForBinaryQuery.java (-5 / +3 lines)
Lines 15-21 Link Here
15
15
16
import java.net.URL;
16
import java.net.URL;
17
import java.util.Arrays;
17
import java.util.Arrays;
18
import java.util.Iterator;
19
import javax.swing.event.ChangeListener;
18
import javax.swing.event.ChangeListener;
20
import org.netbeans.spi.java.queries.SourceForBinaryQueryImplementation;
19
import org.netbeans.spi.java.queries.SourceForBinaryQueryImplementation;
21
import org.openide.ErrorManager;
20
import org.openide.ErrorManager;
Lines 38-45 Link Here
38
    
37
    
39
    private static final ErrorManager ERR = ErrorManager.getDefault().getInstance(SourceForBinaryQuery.class.getName());
38
    private static final ErrorManager ERR = ErrorManager.getDefault().getInstance(SourceForBinaryQuery.class.getName());
40
    
39
    
41
    private static final Lookup.Result/*<SourceForBinaryQueryImplementation>*/ implementations =
40
    private static final Lookup.Result<? extends SourceForBinaryQueryImplementation> implementations =
42
        Lookup.getDefault().lookup (new Lookup.Template (SourceForBinaryQueryImplementation.class));
41
        Lookup.getDefault().lookupResult (SourceForBinaryQueryImplementation.class);
43
42
44
    private SourceForBinaryQuery () {
43
    private SourceForBinaryQuery () {
45
    }
44
    }
Lines 59-66 Link Here
59
        }
58
        }
60
        boolean log = ERR.isLoggable(ErrorManager.INFORMATIONAL);
59
        boolean log = ERR.isLoggable(ErrorManager.INFORMATIONAL);
61
        if (log) ERR.log("SFBQ.findSourceRoots: " + binaryRoot);
60
        if (log) ERR.log("SFBQ.findSourceRoots: " + binaryRoot);
62
        for (Iterator it = implementations.allInstances().iterator(); it.hasNext();) {
61
        for (SourceForBinaryQueryImplementation impl : implementations.allInstances()) {
63
            SourceForBinaryQueryImplementation impl = (SourceForBinaryQueryImplementation) it.next();
64
            Result result = impl.findSourceRoots(binaryRoot);
62
            Result result = impl.findSourceRoots(binaryRoot);
65
            if (result != null) {
63
            if (result != null) {
66
                if (log) ERR.log("  got result " + Arrays.asList(result.getRoots()) + " from " + impl);
64
                if (log) ERR.log("  got result " + Arrays.asList(result.getRoots()) + " from " + impl);
(-)src/org/netbeans/api/java/queries/SourceLevelQuery.java (-6 / +3 lines)
Lines 12-18 Link Here
12
 */
12
 */
13
package org.netbeans.api.java.queries;
13
package org.netbeans.api.java.queries;
14
14
15
import java.util.Iterator;
16
import org.netbeans.spi.java.queries.SourceLevelQueryImplementation;
15
import org.netbeans.spi.java.queries.SourceLevelQueryImplementation;
17
import org.openide.filesystems.FileObject;
16
import org.openide.filesystems.FileObject;
18
import org.openide.util.Lookup;
17
import org.openide.util.Lookup;
Lines 25-32 Link Here
25
 */
24
 */
26
public class SourceLevelQuery {
25
public class SourceLevelQuery {
27
    
26
    
28
    private static final Lookup.Result/*<SourceLevelQueryImplementation>*/ implementations =
27
    private static final Lookup.Result<? extends SourceLevelQueryImplementation> implementations =
29
        Lookup.getDefault().lookup(new Lookup.Template(SourceLevelQueryImplementation.class));
28
        Lookup.getDefault().lookupResult (SourceLevelQueryImplementation.class);
30
29
31
    private SourceLevelQuery() {
30
    private SourceLevelQuery() {
32
    }
31
    }
Lines 40-48 Link Here
40
     *     if it is not known
39
     *     if it is not known
41
     */
40
     */
42
    public static String getSourceLevel(FileObject javaFile) {
41
    public static String getSourceLevel(FileObject javaFile) {
43
        Iterator it = implementations.allInstances().iterator();
42
        for  (SourceLevelQueryImplementation sqi : implementations.allInstances()) {
44
        while (it.hasNext()) {
45
            SourceLevelQueryImplementation sqi = (SourceLevelQueryImplementation)it.next();
46
            String s = sqi.getSourceLevel(javaFile);
43
            String s = sqi.getSourceLevel(javaFile);
47
            if (s != null) {
44
            if (s != null) {
48
                return s;
45
                return s;
(-)src/org/netbeans/api/java/queries/UnitTestForSourceQuery.java (-23 / +11 lines)
Lines 14-23 Link Here
14
package org.netbeans.api.java.queries;
14
package org.netbeans.api.java.queries;
15
15
16
import java.net.URL;
16
import java.net.URL;
17
import java.util.ArrayList;
18
import java.util.Iterator;
19
import java.util.List;
20
import org.netbeans.spi.java.queries.UnitTestForSourceQueryImplementation;
21
import org.netbeans.spi.java.queries.MultipleRootsUnitTestForSourceQueryImplementation;
17
import org.netbeans.spi.java.queries.MultipleRootsUnitTestForSourceQueryImplementation;
22
import org.openide.filesystems.FileObject;
18
import org.openide.filesystems.FileObject;
23
import org.openide.util.Lookup;
19
import org.openide.util.Lookup;
Lines 33-42 Link Here
33
 */
29
 */
34
public class UnitTestForSourceQuery {
30
public class UnitTestForSourceQuery {
35
    
31
    
36
    private static final Lookup.Result/*<UnitTestForSourceQueryImplementation>*/ implementations =
32
    @SuppressWarnings ("deprecation")   // NOI18N
37
        Lookup.getDefault().lookup (new Lookup.Template (UnitTestForSourceQueryImplementation.class));
33
    private static final Lookup.Result<? extends org.netbeans.spi.java.queries.UnitTestForSourceQueryImplementation> implementations =
38
    private static final Lookup.Result/*<MultipleRootsUnitTestForSourceQueryImplementation>*/ mrImplementations = 
34
        Lookup.getDefault().lookupResult(org.netbeans.spi.java.queries.UnitTestForSourceQueryImplementation.class);
39
        Lookup.getDefault().lookup (new Lookup.Template (MultipleRootsUnitTestForSourceQueryImplementation.class));
35
    private static final Lookup.Result<? extends MultipleRootsUnitTestForSourceQueryImplementation> mrImplementations = 
36
        Lookup.getDefault().lookupResult(MultipleRootsUnitTestForSourceQueryImplementation.class);
40
37
41
    private UnitTestForSourceQuery() {
38
    private UnitTestForSourceQuery() {
42
    }
39
    }
Lines 65-86 Link Here
65
     *     array (but not null) when the mapping from source to unit tests is not known.
62
     *     array (but not null) when the mapping from source to unit tests is not known.
66
     * @since org.netbeans.api.java/1 1.7
63
     * @since org.netbeans.api.java/1 1.7
67
     */
64
     */
65
    @SuppressWarnings ("deprecation")   // NOI18N
68
    public static URL[] findUnitTests(FileObject source) {
66
    public static URL[] findUnitTests(FileObject source) {
69
        if (source == null) {
67
        if (source == null) {
70
            throw new IllegalArgumentException("Parameter source cannot be null"); // NOI18N
68
            throw new IllegalArgumentException("Parameter source cannot be null"); // NOI18N
71
        }
69
        }
72
        Iterator it = implementations.allInstances().iterator();
70
        for (MultipleRootsUnitTestForSourceQueryImplementation query : mrImplementations.allInstances()) {            
73
        while (it.hasNext()) {
74
            MultipleRootsUnitTestForSourceQueryImplementation query =
75
                    (MultipleRootsUnitTestForSourceQueryImplementation)it.next();
76
            URL[] urls = query.findUnitTests(source);
71
            URL[] urls = query.findUnitTests(source);
77
            if (urls != null) {
72
            if (urls != null) {
78
                return urls;
73
                return urls;
79
            }
74
            }
80
        }
75
        }
81
        it = implementations.allInstances().iterator();
76
        for (org.netbeans.spi.java.queries.UnitTestForSourceQueryImplementation query : implementations.allInstances()) {
82
        while (it.hasNext()) {
83
            UnitTestForSourceQueryImplementation query = (UnitTestForSourceQueryImplementation)it.next();
84
            URL u = query.findUnitTest(source);
77
            URL u = query.findUnitTest(source);
85
            if (u != null) {
78
            if (u != null) {
86
                return new URL[] {u};
79
                return new URL[] {u};
Lines 110-132 Link Here
110
     *     when the mapping from unit test to sources is not known.
103
     *     when the mapping from unit test to sources is not known.
111
     * @since org.netbeans.api.java/1 1.7
104
     * @since org.netbeans.api.java/1 1.7
112
     */
105
     */
106
    @SuppressWarnings ("deprecation")   // NOI18N
113
    public static URL[] findSources (FileObject unitTest) {
107
    public static URL[] findSources (FileObject unitTest) {
114
        if (unitTest == null) {
108
        if (unitTest == null) {
115
            throw new IllegalArgumentException("Parameter unitTest cannot be null"); // NOI18N
109
            throw new IllegalArgumentException("Parameter unitTest cannot be null"); // NOI18N
116
        }
110
        }
117
        Iterator it = mrImplementations.allInstances().iterator();
111
        for (MultipleRootsUnitTestForSourceQueryImplementation query : mrImplementations.allInstances()) {
118
        while (it.hasNext()) {
119
            MultipleRootsUnitTestForSourceQueryImplementation query =
120
                    (MultipleRootsUnitTestForSourceQueryImplementation)it.next();
121
            URL[] urls = query.findSources(unitTest);
112
            URL[] urls = query.findSources(unitTest);
122
            if (urls != null) {
113
            if (urls != null) {
123
                return urls;
114
                return urls;
124
            }
115
            }
125
        }
116
        }
126
        it = implementations.allInstances().iterator();
117
        for (org.netbeans.spi.java.queries.UnitTestForSourceQueryImplementation query : implementations.allInstances()) {            
127
        while (it.hasNext()) {
128
            UnitTestForSourceQueryImplementation query =
129
                    (UnitTestForSourceQueryImplementation)it.next();
130
            URL u = query.findSource(unitTest);
118
            URL u = query.findSource(unitTest);
131
            if (u != null) {
119
            if (u != null) {
132
                return new URL[] {u};
120
                return new URL[] {u};
(-)src/org/netbeans/modules/java/classpath/ProxyClassPathImplementation.java (-13 / +13 lines)
Lines 31-44 Link Here
31
public class ProxyClassPathImplementation implements ClassPathImplementation {
31
public class ProxyClassPathImplementation implements ClassPathImplementation {
32
32
33
    private ClassPathImplementation[] classPaths;
33
    private ClassPathImplementation[] classPaths;
34
    private List resourcesCache;
34
    private List<PathResourceImplementation> resourcesCache;
35
    private ArrayList listeners;
35
    private ArrayList<PropertyChangeListener> listeners;
36
    private PropertyChangeListener classPathsListener;
36
    private PropertyChangeListener classPathsListener;
37
37
38
    public ProxyClassPathImplementation (ClassPathImplementation[] classPaths) {
38
    public ProxyClassPathImplementation (ClassPathImplementation[] classPaths) {
39
        if (classPaths == null)
39
        if (classPaths == null)
40
            throw new IllegalArgumentException ();
40
            throw new IllegalArgumentException ();
41
        List impls = new ArrayList ();
41
        List<ClassPathImplementation> impls = new ArrayList<ClassPathImplementation> ();
42
        classPathsListener = new DelegatesListener ();
42
        classPathsListener = new DelegatesListener ();
43
        for (int i=0; i< classPaths.length; i++) {
43
        for (int i=0; i< classPaths.length; i++) {
44
            if (classPaths[i] == null)
44
            if (classPaths[i] == null)
Lines 46-61 Link Here
46
            classPaths[i].addPropertyChangeListener (WeakListeners.propertyChange(classPathsListener,classPaths[i]));
46
            classPaths[i].addPropertyChangeListener (WeakListeners.propertyChange(classPathsListener,classPaths[i]));
47
            impls.add (classPaths[i]);
47
            impls.add (classPaths[i]);
48
        }
48
        }
49
        this.classPaths = (ClassPathImplementation[]) impls.toArray(new ClassPathImplementation[impls.size()]);
49
        this.classPaths = impls.toArray(new ClassPathImplementation[impls.size()]);
50
    }
50
    }
51
51
52
52
53
53
54
    public synchronized List /*<PathResourceImplementation>*/ getResources() {
54
    public synchronized List <? extends PathResourceImplementation> getResources() {
55
        if (this.resourcesCache == null) {
55
        if (this.resourcesCache == null) {
56
            ArrayList result = new ArrayList (classPaths.length*10);
56
            ArrayList<PathResourceImplementation> result = new ArrayList<PathResourceImplementation> (classPaths.length*10);
57
            for (int i = 0; i < classPaths.length; i++) {
57
            for (int i = 0; i < classPaths.length; i++) {
58
                List/*<? extends PathResourceImplementation>*/ subPath = classPaths[i].getResources();
58
                List<? extends PathResourceImplementation> subPath = classPaths[i].getResources();
59
                assert subPath != null : "ClassPathImplementation.getResources() returned null. ClassPathImplementation.class: " 
59
                assert subPath != null : "ClassPathImplementation.getResources() returned null. ClassPathImplementation.class: " 
60
                       + classPaths[i].getClass().toString() + " ClassPathImplementation: " + classPaths[i].toString();
60
                       + classPaths[i].getClass().toString() + " ClassPathImplementation: " + classPaths[i].toString();
61
                result.addAll (subPath);
61
                result.addAll (subPath);
Lines 67-73 Link Here
67
67
68
    public synchronized void addPropertyChangeListener(PropertyChangeListener listener) {
68
    public synchronized void addPropertyChangeListener(PropertyChangeListener listener) {
69
        if (this.listeners == null)
69
        if (this.listeners == null)
70
            this.listeners = new ArrayList ();
70
            this.listeners = new ArrayList<PropertyChangeListener> ();
71
        this.listeners.add (listener);
71
        this.listeners.add (listener);
72
    }
72
    }
73
73
Lines 78-84 Link Here
78
    }
78
    }
79
    
79
    
80
    public String toString () {
80
    public String toString () {
81
        StringBuffer builder = new StringBuffer("[");   //NOI18N
81
        StringBuilder builder = new StringBuilder("[");   //NOI18N
82
        for (int i = 0; i< this.classPaths.length; i++) {
82
        for (int i = 0; i< this.classPaths.length; i++) {
83
            builder.append (classPaths[i].toString());
83
            builder.append (classPaths[i].toString());
84
            builder.append(", ");   //NOI18N
84
            builder.append(", ");   //NOI18N
Lines 91-106 Link Here
91
    private class DelegatesListener implements PropertyChangeListener {
91
    private class DelegatesListener implements PropertyChangeListener {
92
92
93
        public void propertyChange(PropertyChangeEvent evt) {
93
        public void propertyChange(PropertyChangeEvent evt) {
94
            Iterator it = null;
94
            PropertyChangeListener[] _listeners;
95
            synchronized (ProxyClassPathImplementation.this) {
95
            synchronized (ProxyClassPathImplementation.this) {
96
                ProxyClassPathImplementation.this.resourcesCache = null;    //Clean the cache
96
                ProxyClassPathImplementation.this.resourcesCache = null;    //Clean the cache
97
                if (ProxyClassPathImplementation.this.listeners == null)
97
                if (ProxyClassPathImplementation.this.listeners == null)
98
                    return;
98
                    return;
99
                it = ((ArrayList)ProxyClassPathImplementation.this.listeners.clone()).iterator();
99
                _listeners = ProxyClassPathImplementation.this.listeners.toArray(new PropertyChangeListener[ProxyClassPathImplementation.this.listeners.size()]);
100
            }
100
            }
101
            PropertyChangeEvent event = new PropertyChangeEvent (ProxyClassPathImplementation.this, evt.getPropertyName(),null,null);
101
            PropertyChangeEvent event = new PropertyChangeEvent (ProxyClassPathImplementation.this, evt.getPropertyName(),null,null);
102
            while (it.hasNext()) {
102
            for (PropertyChangeListener l : _listeners) {
103
                ((PropertyChangeListener)it.next()).propertyChange (event);
103
                l.propertyChange (event);
104
            }
104
            }
105
        }
105
        }
106
    }
106
    }
(-)src/org/netbeans/modules/java/classpath/SimpleClassPathImplementation.java (-7 / +6 lines)
Lines 26-42 Link Here
26
26
27
public class SimpleClassPathImplementation implements ClassPathImplementation {
27
public class SimpleClassPathImplementation implements ClassPathImplementation {
28
    
28
    
29
    List entries;
29
    List<? extends PathResourceImplementation> entries;
30
    
30
    
31
    public SimpleClassPathImplementation() {
31
    public SimpleClassPathImplementation() {
32
        this(new ArrayList());
32
        this(new ArrayList<PathResourceImplementation>());
33
    }
33
    }
34
34
35
    public SimpleClassPathImplementation(List entries) {
35
    public SimpleClassPathImplementation(List<? extends PathResourceImplementation> entries) {
36
        this.entries = entries;
36
        this.entries = entries;
37
    }
37
    }
38
    
38
    
39
    public List /*<PathResourceImplementation>*/ getResources() {
39
    public List <? extends PathResourceImplementation> getResources() {
40
        return Collections.unmodifiableList(entries);
40
        return Collections.unmodifiableList(entries);
41
    }
41
    }
42
42
Lines 49-57 Link Here
49
    }
49
    }
50
    
50
    
51
    public String toString () {
51
    public String toString () {
52
        StringBuffer builder = new StringBuffer ("SimpleClassPathImplementation["); //NOI18N
52
        StringBuilder builder = new StringBuilder ("SimpleClassPathImplementation["); //NOI18N
53
        for (Iterator it = this.entries.iterator(); it.hasNext();) {
53
        for (PathResourceImplementation impl : this.entries) {
54
            PathResourceImplementation impl = (PathResourceImplementation) it.next();
55
            URL[] roots = impl.getRoots();
54
            URL[] roots = impl.getRoots();
56
            for (int i=0; i< roots.length; i++) {
55
            for (int i=0; i< roots.length; i++) {
57
                builder.append (roots[i].toExternalForm());
56
                builder.append (roots[i].toExternalForm());
(-)src/org/netbeans/spi/java/classpath/ClassPathFactory.java (-3 / +1 lines)
Lines 14-20 Link Here
14
package org.netbeans.spi.java.classpath;
14
package org.netbeans.spi.java.classpath;
15
15
16
import java.net.URL;
16
import java.net.URL;
17
import java.util.Iterator;
18
import org.netbeans.api.java.classpath.ClassPath;
17
import org.netbeans.api.java.classpath.ClassPath;
19
import org.netbeans.modules.java.classpath.ClassPathAccessor;
18
import org.netbeans.modules.java.classpath.ClassPathAccessor;
20
import org.openide.filesystems.FileUtil;
19
import org.openide.filesystems.FileUtil;
Lines 44-51 Link Here
44
    
43
    
45
    
44
    
46
    private static boolean checkEntries (ClassPathImplementation spiClasspath) {
45
    private static boolean checkEntries (ClassPathImplementation spiClasspath) {
47
        for (Iterator it = spiClasspath.getResources().iterator(); it.hasNext (); ) {
46
        for (PathResourceImplementation impl : spiClasspath.getResources()) {
48
            PathResourceImplementation impl = (PathResourceImplementation) it.next ();
49
            URL[] roots = impl.getRoots();
47
            URL[] roots = impl.getRoots();
50
            for (int i=0; i< roots.length; i++) {
48
            for (int i=0; i< roots.length; i++) {
51
                if (FileUtil.isArchiveFile(roots[i])) {
49
                if (FileUtil.isArchiveFile(roots[i])) {
(-)src/org/netbeans/spi/java/classpath/ClassPathImplementation.java (-1 / +1 lines)
Lines 29-35 Link Here
29
     * @return List of PathResourceImplementation, never returns null
29
     * @return List of PathResourceImplementation, never returns null
30
     * it may return an empty List
30
     * it may return an empty List
31
     */
31
     */
32
    public List /*<PathResourceImplementation>*/ getResources();
32
    public List<? extends PathResourceImplementation> getResources();
33
33
34
    /**
34
    /**
35
     * Adds property change listener.
35
     * Adds property change listener.
(-)src/org/netbeans/spi/java/classpath/support/ClassPathSupport.java (-4 / +4 lines)
Lines 67-73 Link Here
67
     *     cannot be null; can be empty
67
     *     cannot be null; can be empty
68
     * @return SPI classpath
68
     * @return SPI classpath
69
     */
69
     */
70
    public static ClassPathImplementation createClassPathImplementation(List/*<PathResourceImplementation>*/ entries) {
70
    public static ClassPathImplementation createClassPathImplementation(List< ? extends PathResourceImplementation> entries) {
71
        if (entries == null) {
71
        if (entries == null) {
72
            throw new NullPointerException("Cannot pass null entries"); // NOI18N
72
            throw new NullPointerException("Cannot pass null entries"); // NOI18N
73
        }
73
        }
Lines 82-88 Link Here
82
     *     cannot be null; can be empty
82
     *     cannot be null; can be empty
83
     * @return API classpath
83
     * @return API classpath
84
     */
84
     */
85
    public static ClassPath createClassPath(List/*<PathResourceImplementation>*/ entries) {
85
    public static ClassPath createClassPath(List<? extends PathResourceImplementation> entries) {
86
        if (entries == null) {
86
        if (entries == null) {
87
            throw new NullPointerException("Cannot pass null entries"); // NOI18N
87
            throw new NullPointerException("Cannot pass null entries"); // NOI18N
88
        }
88
        }
Lines 99-105 Link Here
99
     */
99
     */
100
    public static ClassPath createClassPath (FileObject[] roots) {
100
    public static ClassPath createClassPath (FileObject[] roots) {
101
        assert roots != null;
101
        assert roots != null;
102
        List l = new ArrayList ();
102
        List<PathResourceImplementation> l = new ArrayList<PathResourceImplementation> ();
103
        for (int i =0; i < roots.length; i++) {
103
        for (int i =0; i < roots.length; i++) {
104
            if (roots[i] == null) {
104
            if (roots[i] == null) {
105
                continue;
105
                continue;
Lines 124-130 Link Here
124
     */
124
     */
125
    public static ClassPath createClassPath (URL[] roots) {
125
    public static ClassPath createClassPath (URL[] roots) {
126
        assert roots != null;
126
        assert roots != null;
127
        List l = new ArrayList ();
127
        List<PathResourceImplementation> l = new ArrayList<PathResourceImplementation> ();
128
        for (int i=0; i< roots.length; i++) {
128
        for (int i=0; i< roots.length; i++) {
129
            if (roots[i] == null)
129
            if (roots[i] == null)
130
                continue;
130
                continue;
(-)src/org/netbeans/spi/java/classpath/support/CompositePathResourceBase.java (-11 / +11 lines)
Lines 30-37 Link Here
30
public abstract class CompositePathResourceBase implements PathResourceImplementation {
30
public abstract class CompositePathResourceBase implements PathResourceImplementation {
31
31
32
    private URL[] roots;
32
    private URL[] roots;
33
	private ClassPathImplementation model;
33
    private ClassPathImplementation model;
34
    private ArrayList pListeners;
34
    private ArrayList<PropertyChangeListener> pListeners;
35
35
36
    /**
36
    /**
37
     * Returns the roots of the PathResource
37
     * Returns the roots of the PathResource
Lines 42-52 Link Here
42
            synchronized (this) {
42
            synchronized (this) {
43
                if (this.roots == null) {
43
                if (this.roots == null) {
44
                    initContent ();
44
                    initContent ();
45
                    List result = new ArrayList ();
45
                    List<URL> result = new ArrayList<URL> ();
46
                    for (Iterator it = this.model.getResources().iterator(); it.hasNext();) {
46
                    for (PathResourceImplementation pri : this.model.getResources()) {
47
                        result.addAll (Arrays.asList(((PathResourceImplementation)it.next()).getRoots()));
47
                        result.addAll (Arrays.asList(pri.getRoots()));
48
                    }
48
                    }
49
                    this.roots = (URL[])result.toArray (new URL [result.size()]);
49
                    this.roots = result.toArray (new URL [result.size()]);
50
                }
50
                }
51
            }
51
            }
52
        }
52
        }
Lines 70-76 Link Here
70
     */
70
     */
71
    public synchronized final void addPropertyChangeListener(PropertyChangeListener listener) {
71
    public synchronized final void addPropertyChangeListener(PropertyChangeListener listener) {
72
        if (this.pListeners == null)
72
        if (this.pListeners == null)
73
            this.pListeners = new ArrayList ();
73
            this.pListeners = new ArrayList<PropertyChangeListener> ();
74
        this.pListeners.add (listener);
74
        this.pListeners.add (listener);
75
    }
75
    }
76
76
Lines 91-105 Link Here
91
     * @param newValue new property value or null
91
     * @param newValue new property value or null
92
     */
92
     */
93
    protected final void firePropertyChange (String propName, Object oldValue, Object newValue) {
93
    protected final void firePropertyChange (String propName, Object oldValue, Object newValue) {
94
        Iterator it = null;
94
        PropertyChangeListener[] _listeners;
95
        synchronized (this) {
95
        synchronized (this) {
96
            if (this.pListeners == null)
96
            if (this.pListeners == null)
97
                return;
97
                return;
98
            it = ((ArrayList)this.pListeners.clone()).iterator();
98
            _listeners = this.pListeners.toArray(new PropertyChangeListener[this.pListeners.size()]);
99
        }
99
        }
100
        PropertyChangeEvent event = new PropertyChangeEvent (this, propName, oldValue, newValue);
100
        PropertyChangeEvent event = new PropertyChangeEvent (this, propName, oldValue, newValue);
101
        while (it.hasNext()) {
101
        for (PropertyChangeListener l : _listeners) {
102
            ((PropertyChangeListener)it.next ()).propertyChange (event);
102
            l.propertyChange (event);
103
        }
103
        }
104
    }
104
    }
105
105
(-)src/org/netbeans/spi/java/classpath/support/PathResourceBase.java (-6 / +6 lines)
Lines 25-31 Link Here
25
 */
25
 */
26
public abstract class PathResourceBase implements PathResourceImplementation {
26
public abstract class PathResourceBase implements PathResourceImplementation {
27
27
28
    private ArrayList pListeners;
28
    private ArrayList<PropertyChangeListener> pListeners;
29
29
30
30
31
    /**
31
    /**
Lines 35-41 Link Here
35
     */
35
     */
36
    public synchronized final void addPropertyChangeListener(PropertyChangeListener listener) {
36
    public synchronized final void addPropertyChangeListener(PropertyChangeListener listener) {
37
        if (this.pListeners == null)
37
        if (this.pListeners == null)
38
            this.pListeners = new ArrayList ();
38
            this.pListeners = new ArrayList<PropertyChangeListener> ();
39
        this.pListeners.add (listener);
39
        this.pListeners.add (listener);
40
    }
40
    }
41
41
Lines 56-70 Link Here
56
     * @param newValue new property value or null
56
     * @param newValue new property value or null
57
     */
57
     */
58
    protected final void firePropertyChange (String propName, Object oldValue, Object newValue) {
58
    protected final void firePropertyChange (String propName, Object oldValue, Object newValue) {
59
        Iterator it = null;
59
        PropertyChangeListener[] _listeners;
60
        synchronized (this) {
60
        synchronized (this) {
61
            if (this.pListeners == null)
61
            if (this.pListeners == null)
62
                return;
62
                return;
63
            it = ((ArrayList)this.pListeners.clone()).iterator();
63
            _listeners = this.pListeners.toArray(new PropertyChangeListener[this.pListeners.size()]);
64
        }
64
        }
65
        PropertyChangeEvent event = new PropertyChangeEvent (this, propName, oldValue, newValue);
65
        PropertyChangeEvent event = new PropertyChangeEvent (this, propName, oldValue, newValue);
66
        while (it.hasNext()) {
66
        for (PropertyChangeListener l : _listeners) {
67
            ((PropertyChangeListener)it.next ()).propertyChange (event);
67
            l.propertyChange (event);
68
        }
68
        }
69
    }
69
    }
70
}
70
}

Return to bug 76787