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

(-)a/api.java.classpath/src/org/netbeans/api/java/classpath/ClassPath.java (-1 / +11 lines)
Lines 57-63 Link Here
57
import java.util.Arrays;
57
import java.util.Arrays;
58
import java.util.Collection;
58
import java.util.Collection;
59
import java.util.Collections;
59
import java.util.Collections;
60
import java.util.HashMap;
61
import java.util.HashSet;
60
import java.util.HashSet;
62
import java.util.List;
61
import java.util.List;
63
import java.util.Map;
62
import java.util.Map;
Lines 69-75 Link Here
69
import org.netbeans.spi.java.classpath.ClassPathImplementation;
68
import org.netbeans.spi.java.classpath.ClassPathImplementation;
70
import org.netbeans.spi.java.classpath.ClassPathProvider;
69
import org.netbeans.spi.java.classpath.ClassPathProvider;
71
import org.netbeans.spi.java.classpath.FilteringPathResourceImplementation;
70
import org.netbeans.spi.java.classpath.FilteringPathResourceImplementation;
71
import org.netbeans.spi.java.classpath.FilteringPathResourceImplementation2;
72
import org.netbeans.spi.java.classpath.PathResourceImplementation;
72
import org.netbeans.spi.java.classpath.PathResourceImplementation;
73
import org.netbeans.spi.java.classpath.support.ClassPathSupport;
73
import org.openide.filesystems.FileAttributeEvent;
74
import org.openide.filesystems.FileAttributeEvent;
74
import org.openide.filesystems.FileChangeListener;
75
import org.openide.filesystems.FileChangeListener;
75
import org.openide.filesystems.FileEvent;
76
import org.openide.filesystems.FileEvent;
Lines 739-744 Link Here
739
        }
740
        }
740
741
741
        /**
742
        /**
743
         * Returns the {@link FilteringPathResourceImplementation2#algorithm} of the filter.
744
         * @return an algorithm, or null if no algorithm is specified
745
         * @since XXX
746
         */
747
        public String includeAlgorithm() {
748
            return filter instanceof FilteringPathResourceImplementation2 ? ((FilteringPathResourceImplementation2) filter).algorithm() : null;
749
        }
750
751
        /**
742
         * Check whether a file is included in this entry.
752
         * Check whether a file is included in this entry.
743
         * @param file a URL beneath @{link #getURL}
753
         * @param file a URL beneath @{link #getURL}
744
         * @return true if it is {@link FilteringPathResourceImplementation#includes included}
754
         * @return true if it is {@link FilteringPathResourceImplementation#includes included}
(-)a/api.java.classpath/src/org/netbeans/modules/java/classpath/SimplePathResourceImplementation.java (-2 / +6 lines)
Lines 45-51 Link Here
45
import org.netbeans.spi.java.classpath.ClassPathImplementation;
45
import org.netbeans.spi.java.classpath.ClassPathImplementation;
46
46
47
import java.net.URL;
47
import java.net.URL;
48
import org.netbeans.spi.java.classpath.FilteringPathResourceImplementation;
48
import org.netbeans.spi.java.classpath.FilteringPathResourceImplementation2;
49
import org.netbeans.spi.java.classpath.support.ClassPathSupport.ResourceAcceptor;
49
import org.netbeans.spi.java.classpath.support.ClassPathSupport.ResourceAcceptor;
50
50
51
51
Lines 53-59 Link Here
53
 * Provides implementation of the single rooted PathResoruceImplementation
53
 * Provides implementation of the single rooted PathResoruceImplementation
54
 */
54
 */
55
55
56
public final class SimplePathResourceImplementation  extends PathResourceBase implements FilteringPathResourceImplementation {
56
public final class SimplePathResourceImplementation extends PathResourceBase implements FilteringPathResourceImplementation2 {
57
57
58
    private URL[] url;
58
    private URL[] url;
59
    private final ResourceAcceptor acceptor;
59
    private final ResourceAcceptor acceptor;
Lines 100-103 Link Here
100
    public boolean includes(URL root, String resource) {
100
    public boolean includes(URL root, String resource) {
101
        return acceptor == null || acceptor.includes(root, resource);
101
        return acceptor == null || acceptor.includes(root, resource);
102
    }
102
    }
103
104
    public String algorithm() {
105
        return acceptor != null ? acceptor.algorithm(url[0]) : null;
106
    }
103
}
107
}
(-)a/api.java.classpath/src/org/netbeans/spi/java/classpath/FilteringPathResourceImplementation.java (+1 lines)
Lines 45-50 Link Here
45
45
46
/**
46
/**
47
 * SPI interface for a classpath entry which can include or exclude particular files.
47
 * SPI interface for a classpath entry which can include or exclude particular files.
48
 * <p>Implement {@link FilteringPathResourceImplementation2} if possible.
48
 * @author Jesse Glick
49
 * @author Jesse Glick
49
 * @see "issue #49026"
50
 * @see "issue #49026"
50
 * @since org.netbeans.api.java/1 1.13
51
 * @since org.netbeans.api.java/1 1.13
(-)a/api.java.classpath/src/org/netbeans/spi/java/classpath/FilteringPathResourceImplementation2.java (+60 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
5
 *
6
 * The contents of this file are subject to the terms of either the GNU
7
 * General Public License Version 2 only ("GPL") or the Common
8
 * Development and Distribution License("CDDL") (collectively, the
9
 * "License"). You may not use this file except in compliance with the
10
 * License. You can obtain a copy of the License at
11
 * http://www.netbeans.org/cddl-gplv2.html
12
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
 * specific language governing permissions and limitations under the
14
 * License.  When distributing the software, include this License Header
15
 * Notice in each file and include the License file at
16
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
17
 * particular file as subject to the "Classpath" exception as provided
18
 * by Sun in the GPL Version 2 section of the License file that
19
 * accompanied this code. If applicable, add the following below the
20
 * License Header, with the fields enclosed by brackets [] replaced by
21
 * your own identifying information:
22
 * "Portions Copyrighted [year] [name of copyright owner]"
23
 *
24
 * If you wish your version of this file to be governed by only the CDDL
25
 * or only the GPL Version 2, indicate your decision by adding
26
 * "[Contributor] elects to include this software in this distribution
27
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
28
 * single choice of license, a recipient has the option to distribute
29
 * your version of this file under either the CDDL, the GPL Version 2 or
30
 * to extend the choice of license to its licensees as provided above.
31
 * However, if you add GPL Version 2 code and therefore, elected the GPL
32
 * Version 2 license, then the option applies only if the new code is
33
 * made subject to such option by the copyright holder.
34
 *
35
 * Contributor(s):
36
 *
37
 * Portions Copyrighted 2009 Sun Microsystems, Inc.
38
 */
39
40
package org.netbeans.spi.java.classpath;
41
42
/**
43
 * Extended path resource implementation that can be used in caches.
44
 * @since XXX
45
 */
46
public interface FilteringPathResourceImplementation2 extends FilteringPathResourceImplementation {
47
48
    /**
49
     * Used to track possible changes in includes across JVM sessions,
50
     * when {@link #PROP_INCLUDES} would not be fired.
51
     * <p>If two implementations return the same (non-null) algorithm token, they must behave
52
     * identically on identical calls to {@link #includes}. If they behave
53
     * identically, it is desirable for them to return the same token.
54
     * <p>For example, an implementation based on Ant patternsets could somehow
55
     * encode the list of include and exclude patterns into a string.
56
     * @return an arbitrary string, or null to avoid implementing
57
     */
58
    String algorithm();
59
60
}
(-)a/api.java.classpath/src/org/netbeans/spi/java/classpath/support/ClassPathSupport.java (+5 lines)
Lines 214-221 Link Here
214
        return ClassPathFactory.createClassPath (createProxyClassPathImplementation(impls));
214
        return ClassPathFactory.createClassPath (createProxyClassPathImplementation(impls));
215
    }
215
    }
216
216
217
    /**
218
     * XXX description
219
     * @since XXX
220
     */
217
    public static interface ResourceAcceptor {
221
    public static interface ResourceAcceptor {
218
        public boolean includes(URL root, String resource);
222
        public boolean includes(URL root, String resource);
223
        String algorithm(URL root);
219
    }
224
    }
220
225
221
}
226
}
(-)a/apisupport.project/src/org/netbeans/modules/apisupport/project/ManifestManager.java (-1 / +1 lines)
Lines 421-427 Link Here
421
        }
421
        }
422
        
422
        
423
        public @Override String toString() {
423
        public @Override String toString() {
424
            return "PackageExport[" + pkg + (recursive ? "/**" : "") + "]"; // NOI18N
424
            return pkg + (recursive ? ".**" : ".*"); // NOI18N
425
        }
425
        }
426
    }
426
    }
427
    
427
    
(-)a/apisupport.project/src/org/netbeans/modules/apisupport/project/queries/ClassPathProviderImpl.java (-8 / +58 lines)
Lines 47-55 Link Here
47
import java.io.File;
47
import java.io.File;
48
import java.net.URL;
48
import java.net.URL;
49
import java.util.ArrayList;
49
import java.util.ArrayList;
50
import java.util.Arrays;
50
import java.util.HashMap;
51
import java.util.HashMap;
51
import java.util.HashSet;
52
import java.util.HashSet;
52
import java.util.LinkedList;
53
import java.util.List;
53
import java.util.List;
54
import java.util.Map;
54
import java.util.Map;
55
import java.util.Set;
55
import java.util.Set;
Lines 59-64 Link Here
59
import java.util.regex.Pattern;
59
import java.util.regex.Pattern;
60
import org.netbeans.api.java.classpath.ClassPath;
60
import org.netbeans.api.java.classpath.ClassPath;
61
import org.netbeans.api.java.classpath.JavaClassPathConstants;
61
import org.netbeans.api.java.classpath.JavaClassPathConstants;
62
import org.netbeans.modules.apisupport.project.ManifestManager;
62
import org.netbeans.spi.java.classpath.ClassPathFactory;
63
import org.netbeans.spi.java.classpath.ClassPathFactory;
63
import org.netbeans.spi.java.classpath.ClassPathImplementation;
64
import org.netbeans.spi.java.classpath.ClassPathImplementation;
64
import org.netbeans.spi.java.classpath.ClassPathProvider;
65
import org.netbeans.spi.java.classpath.ClassPathProvider;
Lines 66-72 Link Here
66
import org.netbeans.modules.apisupport.project.NbModuleProject;
67
import org.netbeans.modules.apisupport.project.NbModuleProject;
67
import org.netbeans.modules.apisupport.project.NbModuleProjectType;
68
import org.netbeans.modules.apisupport.project.NbModuleProjectType;
68
import org.netbeans.modules.apisupport.project.Util;
69
import org.netbeans.modules.apisupport.project.Util;
69
import org.netbeans.spi.java.classpath.FilteringPathResourceImplementation;
70
import org.netbeans.modules.apisupport.project.universe.ModuleEntry;
71
import org.netbeans.modules.apisupport.project.universe.ModuleList;
70
import org.netbeans.spi.java.classpath.PathResourceImplementation;
72
import org.netbeans.spi.java.classpath.PathResourceImplementation;
71
import org.netbeans.spi.java.classpath.support.ClassPathSupport.ResourceAcceptor;
73
import org.netbeans.spi.java.classpath.support.ClassPathSupport.ResourceAcceptor;
72
import org.netbeans.spi.java.project.classpath.support.ProjectClassPathSupport;
74
import org.netbeans.spi.java.project.classpath.support.ProjectClassPathSupport;
Lines 264-276 Link Here
264
        }
266
        }
265
        ClassPathImplementation result = ProjectClassPathSupport.createPropertyBasedClassPathImplementation(
267
        ClassPathImplementation result = ProjectClassPathSupport.createPropertyBasedClassPathImplementation(
266
            project.getProjectDirectoryFile(), project.evaluator(), new String[] {prop}, new ResourceAcceptor() {
268
            project.getProjectDirectoryFile(), project.evaluator(), new String[] {prop}, new ResourceAcceptor() {
267
269
            // XXX cache some of this for performance (need to listen to project.xml changes)
268
            public boolean includes(URL root, String resource) {
270
            public boolean includes(URL root, String resource) {
269
                    boolean result= resource.contains("/api/") || resource.contains("/spi/");
271
                File jar = FileUtil.archiveOrDirForURL(root);
270
272
                if (jar != null) {
271
                    System.err.println(resource + "=" + result);
273
                    for (ModuleEntry entry : ModuleList.getKnownEntries(jar)) {
272
274
                        // Comes from a foreign module; check for public package status.
273
                    return result;
275
                        int idx = resource.lastIndexOf('/');
276
                        if (idx == -1) {
277
                            // Default package never accessible.
278
                            return false;
279
                        }
280
                        String pkg = resource.substring(0, idx).replace('/', '.');
281
                        for (ManifestManager.PackageExport export : entry.getPublicPackages()) {
282
                            String expPkg = export.getPackage();
283
                            if (pkg.equals(expPkg) || export.isRecursive() && pkg.startsWith(expPkg + ".")) {
284
                                return true;
285
                            }
286
                        }
287
                        return haveImplDepOn(entry);
288
                    }
289
                }
290
                return true;
291
            }
292
            public String algorithm(URL root) {
293
                File jar = FileUtil.archiveOrDirForURL(root);
294
                if (jar != null) {
295
                    for (ModuleEntry entry : ModuleList.getKnownEntries(jar)) {
296
                        return haveImplDepOn(entry) ? "impl" : Arrays.toString(entry.getPublicPackages()); // NOI18N
297
                    }
298
                }
299
                return null;
300
            }
301
            private boolean haveImplDepOn(ModuleEntry entry) {
302
                Element data = project.getPrimaryConfigurationData();
303
                Element moduleDependencies = Util.findElement(data,
304
                        "module-dependencies", NbModuleProjectType.NAMESPACE_SHARED); // NOI18N
305
                for (Element dep : Util.findSubElements(moduleDependencies)) {
306
                    Element cnbEl = Util.findElement(dep, "code-name-base", // NOI18N
307
                            NbModuleProjectType.NAMESPACE_SHARED);
308
                    String cnb = Util.findText(cnbEl);
309
                    if (!cnb.equals(entry.getCodeNameBase())) {
310
                        continue;
311
                    }
312
                    Element runDep = Util.findElement(dep, "run-dependency", // NOI18N
313
                            NbModuleProjectType.NAMESPACE_SHARED);
314
                    if (runDep == null) {
315
                        return true; // ???
316
                    }
317
                    if (Util.findElement(runDep, "implementation-version",
318
                            NbModuleProjectType.NAMESPACE_SHARED) != null) { // NOI18N
319
                        return true;
320
                    }
321
                    return false;
322
                }
323
                return false; // not found?
274
            }
324
            }
275
        });
325
        });
276
326
(-)a/java.api.common/src/org/netbeans/modules/java/api/common/classpath/SourcePathImplementation.java (-1 / +6 lines)
Lines 57-62 Link Here
57
import org.netbeans.modules.java.api.common.project.ProjectProperties;
57
import org.netbeans.modules.java.api.common.project.ProjectProperties;
58
import org.netbeans.spi.java.classpath.ClassPathImplementation;
58
import org.netbeans.spi.java.classpath.ClassPathImplementation;
59
import org.netbeans.spi.java.classpath.FilteringPathResourceImplementation;
59
import org.netbeans.spi.java.classpath.FilteringPathResourceImplementation;
60
import org.netbeans.spi.java.classpath.FilteringPathResourceImplementation2;
60
import org.netbeans.spi.java.classpath.PathResourceImplementation;
61
import org.netbeans.spi.java.classpath.PathResourceImplementation;
61
import org.netbeans.spi.java.classpath.support.ClassPathSupport;
62
import org.netbeans.spi.java.classpath.support.ClassPathSupport;
62
import org.netbeans.spi.project.support.ant.AntProjectHelper;
63
import org.netbeans.spi.project.support.ant.AntProjectHelper;
Lines 161-167 Link Here
161
            if (this.resources == null) {
162
            if (this.resources == null) {
162
                List<PathResourceImplementation> result = new ArrayList<PathResourceImplementation>(roots.length);
163
                List<PathResourceImplementation> result = new ArrayList<PathResourceImplementation>(roots.length);
163
                for (final URL root : roots) {
164
                for (final URL root : roots) {
164
                    class PRI implements FilteringPathResourceImplementation, PropertyChangeListener {
165
                    class PRI implements FilteringPathResourceImplementation2, PropertyChangeListener {
165
166
166
                        PropertyChangeSupport pcs = new PropertyChangeSupport(this);
167
                        PropertyChangeSupport pcs = new PropertyChangeSupport(this);
167
                        PathMatcher matcher;
168
                        PathMatcher matcher;
Lines 184-189 Link Here
184
                            return matcher.matches(resource, true);
185
                            return matcher.matches(resource, true);
185
                        }
186
                        }
186
187
188
                        public String algorithm() {
189
                            return evaluator.evaluate("+ ${" + ProjectProperties.INCLUDES + "} - ${" + ProjectProperties.EXCLUDES + "}"); // NOI18N
190
                        }
191
187
                        public ClassPathImplementation getContent() {
192
                        public ClassPathImplementation getContent() {
188
                            return null;
193
                            return null;
189
                        }
194
                        }
(-)a/java.project/src/org/netbeans/spi/java/project/support/ClassPathProviderMerger.java (-1 / +13 lines)
Lines 52-57 Link Here
52
import org.netbeans.spi.java.classpath.ClassPathImplementation;
52
import org.netbeans.spi.java.classpath.ClassPathImplementation;
53
import org.netbeans.spi.java.classpath.ClassPathProvider;
53
import org.netbeans.spi.java.classpath.ClassPathProvider;
54
import org.netbeans.spi.java.classpath.FilteringPathResourceImplementation;
54
import org.netbeans.spi.java.classpath.FilteringPathResourceImplementation;
55
import org.netbeans.spi.java.classpath.FilteringPathResourceImplementation2;
55
import org.netbeans.spi.java.classpath.PathResourceImplementation;
56
import org.netbeans.spi.java.classpath.PathResourceImplementation;
56
import org.netbeans.spi.project.LookupMerger;
57
import org.netbeans.spi.project.LookupMerger;
57
import org.openide.filesystems.FileObject;
58
import org.openide.filesystems.FileObject;
Lines 257-263 Link Here
257
        return new ProxyFilteringCPI(path);
258
        return new ProxyFilteringCPI(path);
258
    }
259
    }
259
    
260
    
260
    private static class ProxyFilteringCPI implements FilteringPathResourceImplementation, PropertyChangeListener {
261
    private static class ProxyFilteringCPI implements FilteringPathResourceImplementation2, PropertyChangeListener {
261
        private final ClassPath classpath;
262
        private final ClassPath classpath;
262
        private final PropertyChangeSupport changeSupport;
263
        private final PropertyChangeSupport changeSupport;
263
264
Lines 307-312 Link Here
307
                this.changeSupport.firePropertyChange(PROP_INCLUDES, null, null);
308
                this.changeSupport.firePropertyChange(PROP_INCLUDES, null, null);
308
            }
309
            }
309
        }
310
        }
311
312
        public String algorithm() {
313
            if (classpath.entries().size() == 1) {
314
                return classpath.entries().get(0).includeAlgorithm();
315
            }
316
            StringBuilder b = new StringBuilder("[");
317
            for (ClassPath.Entry ent : classpath.entries()) {
318
                b.append(ent.includeAlgorithm()).append(";");
319
            }
320
            return b.append("]").toString();
321
        }
310
        
322
        
311
    }
323
    }
312
            
324
            
(-)a/java.source/src/org/netbeans/modules/java/source/classpath/CacheClassPath.java (+3 lines)
Lines 124-129 Link Here
124
                public boolean includes(URL root, String resource) {
124
                public boolean includes(URL root, String resource) {
125
                    return entry.includes(resource);
125
                    return entry.includes(resource);
126
                }
126
                }
127
                public String algorithm(URL root) {
128
                    return entry.includeAlgorithm();
129
                }
127
            };
130
            };
128
            URL url = entry.getURL();
131
            URL url = entry.getURL();
129
            URL[] sourceUrls;
132
            URL[] sourceUrls;

Return to bug 170231