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

(-)projectapi/apichanges.xml (+24 lines)
Lines 76-81 Link Here
76
76
77
    <changes>
77
    <changes>
78
78
79
        <change id="markExternal-for-file-and-URIs">
80
            <api name="general"/>
81
            <summary>The FileOwnerQuery.markExternalOwner allows registration of individal files and URIs</summary>
82
            <version major="1" minor="4"/>
83
            <date day="13" month="5" year="2005"/>
84
            <author login="jlahoda"/>
85
            <compatibility addition="yes" semantic="compatible" binary="compatible">
86
                <p>
87
                    This changes add a new method <code>FileOwnerQuery.markExternalOwner(URI, FileObject, int)</code>,
88
                    and also extends sematics of the existing
89
                    <code>FileOwnerQuery.markExternalOwner(FileObject, FileObject, int)</code> method to allow registration
90
                    of individual files.
91
                </p>
92
            </compatibility>
93
            <description>
94
                <p>
95
                    It is possible to register owner of an individual file using FileOwnerQuery.markExternalOwner.
96
                    It is possible to register owner of a folder or file using URI, so the folder or file does not
97
                    have to exist at the time of registration.
98
                </p>
99
            </description>
100
            <issue number="58313"/>
101
        </change>
102
        
79
        <change id="rel-vers-1">
103
        <change id="rel-vers-1">
80
            <api name="general"/>
104
            <api name="general"/>
81
            <summary>Switched to major release version 1</summary>
105
            <summary>Switched to major release version 1</summary>
(-)projectapi/src/org/netbeans/api/project/FileOwnerQuery.java (-7 / +40 lines)
Lines 138-146 Link Here
138
    public static final int EXTERNAL_ALGORITHM_TRANSIENT = 0;
138
    public static final int EXTERNAL_ALGORITHM_TRANSIENT = 0;
139
    
139
    
140
    /**
140
    /**
141
     * Mark an external folder as being owned by a particular project.
141
     * Mark an external folder or file as being owned by a particular project.
142
     * After this call is made, for the duration appropriate to the selected
142
     * After this call is made, for the duration appropriate to the selected
143
     * algorithm, that folder and its ancestors will be considered owned
143
     * algorithm, that folder or file and its ancestors will be considered owned
144
     * by the project (if any) matching the named project directory, except in
144
     * by the project (if any) matching the named project directory, except in
145
     * the case that a lower enclosing project directory can be found.
145
     * the case that a lower enclosing project directory can be found.
146
     * <p class="nonnormative">
146
     * <p class="nonnormative">
Lines 149-163 Link Here
149
     * algorithm is selected, or only when the project is created, if a reliable
149
     * algorithm is selected, or only when the project is created, if a reliable
150
     * persistent algorithm is selected.
150
     * persistent algorithm is selected.
151
     * </p>
151
     * </p>
152
     * @param root a folder which should be considered part of a project
152
     * @param root a folder or a file which should be considered part of a project
153
     * @param owner a project which should be considered to own that folder tree
153
     * @param owner a project which should be considered to own that folder tree
154
     *              (any prior marked external owner is overridden),
154
     *              (any prior marked external owner is overridden),
155
     *              or null to cancel external ownership for this folder root
155
     *              or null to cancel external ownership for this folder root
156
     * @param algorithm an algorithm to use for retaining this information;
156
     * @param algorithm an algorithm to use for retaining this information;
157
     *                  currently may only be {@link #EXTERNAL_ALGORITHM_TRANSIENT}
157
     *                  currently may only be {@link #EXTERNAL_ALGORITHM_TRANSIENT}
158
     * @throws IllegalArgumentException if the root or owner is null, if an unsupported
158
     * @throws IllegalArgumentException if the root or owner is null, if an unsupported
159
     *                                  algorithm is requested, if the root is not a
159
     *                                  algorithm is requested,
160
     *                                  folder, if the root is already a project directory,
160
     *                                  if the root is already a project directory,
161
     *                                  or if the root is already equal to or inside the owner's
161
     *                                  or if the root is already equal to or inside the owner's
162
     *                                  project directory (it may however be an ancestor)
162
     *                                  project directory (it may however be an ancestor)
163
     * @see <a href="@ANT/PROJECT@/org/netbeans/spi/project/support/ant/SourcesHelper.html"><code>SourcesHelper</code></a>
163
     * @see <a href="@ANT/PROJECT@/org/netbeans/spi/project/support/ant/SourcesHelper.html"><code>SourcesHelper</code></a>
Lines 173-180 Link Here
173
        }
173
        }
174
    }
174
    }
175
    
175
    
176
    // XXX may need markExternalOwner(URI root, Project, int)? in case root dir does not exist yet...
176
    /**
177
    // XXX is it useful to mark external owners for individual files?
177
     * Mark an external URI (folder or file) as being owned by a particular project.
178
     * After this call is made, for the duration appropriate to the selected
179
     * algorithm, that folder or file and its ancestors will be considered owned
180
     * by the project (if any) matching the named project directory, except in
181
     * the case that a lower enclosing project directory can be found.
182
     * <p class="nonnormative">
183
     * Typical usage would be to call this method for each external source root
184
     * of a project (if any) as soon as the project is loaded, if a transient
185
     * algorithm is selected, or only when the project is created, if a reliable
186
     * persistent algorithm is selected.
187
     * </p>
188
     * @param root an URI of a folder or a file which should be considered part of a project
189
     * @param owner a project which should be considered to own that folder tree
190
     *              (any prior marked external owner is overridden),
191
     *              or null to cancel external ownership for this folder root
192
     * @param algorithm an algorithm to use for retaining this information;
193
     *                  currently may only be {@link #EXTERNAL_ALGORITHM_TRANSIENT}
194
     * @throws IllegalArgumentException if the root or owner is null, if an unsupported
195
     *                                  algorithm is requested,
196
     *                                  if the root is already a project directory,
197
     *                                  or if the root is already equal to or inside the owner's
198
     *                                  project directory (it may however be an ancestor)
199
     * @see <a href="@ANT/PROJECT@/org/netbeans/spi/project/support/ant/SourcesHelper.html"><code>SourcesHelper</code></a>
200
     */
201
    public static void markExternalOwner(URI root, Project owner, int algorithm) throws IllegalArgumentException {
202
        switch (algorithm) {
203
        case EXTERNAL_ALGORITHM_TRANSIENT:
204
            // XXX check args
205
            SimpleFileOwnerQueryImplementation.markExternalOwnerTransient(root, owner);
206
            break;
207
        default:
208
            throw new IllegalArgumentException("No such algorithm: " + algorithm); // NOI18N
209
        }
210
    }
178
    
211
    
179
    /* TBD whether this is necessary:
212
    /* TBD whether this is necessary:
180
    public static FileObject getMarkedExternalOwner(FileObject root) {}
213
    public static FileObject getMarkedExternalOwner(FileObject root) {}
(-)projectapi/src/org/netbeans/modules/projectapi/SimpleFileOwnerQueryImplementation.java (-22 / +58 lines)
Lines 14-24 Link Here
14
package org.netbeans.modules.projectapi;
14
package org.netbeans.modules.projectapi;
15
15
16
import java.io.IOException;
16
import java.io.IOException;
17
import java.lang.ref.WeakReference;
17
import java.net.MalformedURLException;
18
import java.net.MalformedURLException;
18
import java.net.URI;
19
import java.net.URI;
19
import java.net.URISyntaxException;
20
import java.net.URISyntaxException;
20
import java.net.URL;
21
import java.net.URL;
21
import java.util.Collections;
22
import java.util.Collections;
23
import java.util.HashMap;
22
import java.util.Map;
24
import java.util.Map;
23
import java.util.WeakHashMap;
25
import java.util.WeakHashMap;
24
import org.netbeans.api.project.Project;
26
import org.netbeans.api.project.Project;
Lines 26-31 Link Here
26
import org.netbeans.spi.project.FileOwnerQueryImplementation;
28
import org.netbeans.spi.project.FileOwnerQueryImplementation;
27
import org.openide.ErrorManager;
29
import org.openide.ErrorManager;
28
import org.openide.filesystems.FileObject;
30
import org.openide.filesystems.FileObject;
31
import org.openide.filesystems.FileStateInvalidException;
29
import org.openide.filesystems.URLMapper;
32
import org.openide.filesystems.URLMapper;
30
import org.openide.filesystems.FileUtil;
33
import org.openide.filesystems.FileUtil;
31
import org.openide.util.Utilities;
34
import org.openide.util.Utilities;
Lines 54-84 Link Here
54
    }
57
    }
55
        
58
        
56
    public Project getOwner(FileObject f) {
59
    public Project getOwner(FileObject f) {
57
        if (f.isData()) {
58
            f = f.getParent();
59
        }
60
        while (f != null) {
60
        while (f != null) {
61
            Project p;
61
            if (f.isFolder()) {
62
            try {
62
                Project p;
63
                p = ProjectManager.getDefault().findProject(f);
64
            } catch (IOException e) {
65
                // There is a project here, but we cannot load it...
66
                ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, e);
67
                return null;
68
            }
69
            if (p != null) {
70
                return p;
71
            }
72
            FileObject externalOwner = (FileObject)externalOwners.get(f);
73
            if (externalOwner != null) {
74
                try {
63
                try {
75
                    // Note: will be null if there is no such project.
64
                    p = ProjectManager.getDefault().findProject(f);
76
                    return ProjectManager.getDefault().findProject(externalOwner);
77
                } catch (IOException e) {
65
                } catch (IOException e) {
78
                    // There is a project there, but we cannot load it...
66
                    // There is a project here, but we cannot load it...
79
                    ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, e);
67
                    ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, e);
80
                    return null;
68
                    return null;
81
                }
69
                }
70
                if (p != null) {
71
                    return p;
72
                }
73
            }
74
            
75
            WeakReference/*<FileObject>*/ externalOwnersReference =
76
                    (WeakReference/*<FileObject>*/) externalOwners.get(fileObject2URI(f));
77
            
78
            if (externalOwnersReference != null) {
79
                FileObject externalOwner = (FileObject) externalOwnersReference.get();
80
                
81
                if (externalOwner != null) {
82
                    try {
83
                        // Note: will be null if there is no such project.
84
                        return ProjectManager.getDefault().findProject(externalOwner);
85
                    } catch (IOException e) {
86
                        // There is a project there, but we cannot load it...
87
                        ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, e);
88
                        return null;
89
                    }
90
                }
82
            }
91
            }
83
            f = f.getParent();
92
            f = f.getParent();
84
        }
93
        }
Lines 88-94 Link Here
88
    /**
97
    /**
89
     * Map from external source roots to the owning project directories.
98
     * Map from external source roots to the owning project directories.
90
     */
99
     */
91
    private static final Map/*<FileObject,FileObject>*/ externalOwners =
100
    private static final Map/*<URI,WeakReference<FileObject>>*/ externalOwners =
101
        Collections.synchronizedMap(new WeakHashMap());
102
    private static final Map/*<FileObject, URI>*/ project2External =
92
        Collections.synchronizedMap(new WeakHashMap());
103
        Collections.synchronizedMap(new WeakHashMap());
93
    
104
    
94
    /** @see FileOwnerQuery#reset */
105
    /** @see FileOwnerQuery#reset */
Lines 96-107 Link Here
96
        externalOwners.clear();
107
        externalOwners.clear();
97
    }
108
    }
98
    
109
    
110
    private static URI fileObject2URI(FileObject f) {
111
        try {
112
            return URI.create(f.getURL().toString());
113
        } catch (FileStateInvalidException e) {
114
            IllegalArgumentException iae = new IllegalArgumentException(e.getMessage());
115
            
116
            ErrorManager.getDefault().annotate(iae, e);
117
            throw iae;
118
        }
119
    }
120
    
99
    /** @see FileOwnerQuery#markExternalOwner */
121
    /** @see FileOwnerQuery#markExternalOwner */
100
    public static void markExternalOwnerTransient(FileObject root, Project owner) {
122
    public static void markExternalOwnerTransient(FileObject root, Project owner) {
123
        markExternalOwnerTransient(fileObject2URI(root), owner);
124
    }
125
    
126
    /** @see FileOwnerQuery#markExternalOwner */
127
    public static void markExternalOwnerTransient(URI root, Project owner) {
101
        if (owner != null) {
128
        if (owner != null) {
102
            externalOwners.put(root, owner.getProjectDirectory());
129
            externalOwners.put(root, new WeakReference(owner.getProjectDirectory()));
130
            project2External.put(owner.getProjectDirectory(), root);
103
        } else {
131
        } else {
104
            externalOwners.remove(root);
132
            WeakReference/*<FileObject>*/ ownerReference = (WeakReference/*<FileObject>*/) externalOwners.remove(root);
133
            
134
            if (ownerReference != null) {
135
                FileObject ownerFO = (FileObject) ownerReference.get();
136
                
137
                if (ownerFO != null) {
138
                    project2External.remove(ownerFO);
139
                }
140
            }
105
        }
141
        }
106
    }
142
    }
107
    
143
    
(-)projectapi/test/unit/src/org/netbeans/api/project/FileOwnerQueryTest.java (-2 / +124 lines)
Lines 12-28 Link Here
12
 */
12
 */
13
13
14
package org.netbeans.api.project;
14
package org.netbeans.api.project;
15
16
import java.io.OutputStream;
15
import java.io.OutputStream;
16
import java.lang.ref.WeakReference;
17
import java.net.URI;
17
import java.net.URI;
18
import java.util.zip.CRC32;
18
import java.util.zip.CRC32;
19
import java.util.zip.ZipEntry;
19
import java.util.zip.ZipEntry;
20
import java.util.zip.ZipOutputStream;
20
import java.util.zip.ZipOutputStream;
21
import org.netbeans.junit.NbTestCase;
21
import org.netbeans.junit.NbTestCase;
22
import org.netbeans.modules.projectapi.TimedWeakReference;
22
import org.openide.filesystems.FileLock;
23
import org.openide.filesystems.FileLock;
23
import org.openide.filesystems.FileObject;
24
import org.openide.filesystems.FileObject;
24
import org.openide.filesystems.FileUtil;
25
import org.openide.filesystems.FileUtil;
25
import org.openide.util.Lookup;
26
26
27
/**
27
/**
28
 * Test functionality of FileOwnerQuery.
28
 * Test functionality of FileOwnerQuery.
Lines 34-39 Link Here
34
        super(name);
34
        super(name);
35
    }
35
    }
36
    
36
    
37
    static {
38
        TimedWeakReference.TIMEOUT = 0;
39
    }
40
    
37
    private FileObject scratch;
41
    private FileObject scratch;
38
    private FileObject projdir;
42
    private FileObject projdir;
39
    private FileObject randomfile;
43
    private FileObject randomfile;
Lines 156-161 Link Here
156
        assertEquals("but subprojects are not part of it", ProjectManager.getDefault().findProject(ext3subproj), p3);
160
        assertEquals("but subprojects are not part of it", ProjectManager.getDefault().findProject(ext3subproj), p3);
157
        FileOwnerQuery.markExternalOwner(ext3, null, FileOwnerQuery.EXTERNAL_ALGORITHM_TRANSIENT);
161
        FileOwnerQuery.markExternalOwner(ext3, null, FileOwnerQuery.EXTERNAL_ALGORITHM_TRANSIENT);
158
        assertEquals("unmarking an owner works", null, FileOwnerQuery.getOwner(ext3));
162
        assertEquals("unmarking an owner works", null, FileOwnerQuery.getOwner(ext3));
163
    }
164
165
    public void testExternalOwnerFile() throws Exception {
166
        FileObject ext1 = scratch.getFileObject("external1");
167
        FileObject extfile1 = ext1.getFileObject("subdir/file");
168
        assertEquals("no owner yet", null, FileOwnerQuery.getOwner(extfile1));
169
        FileOwnerQuery.markExternalOwner(extfile1, p, FileOwnerQuery.EXTERNAL_ALGORITHM_TRANSIENT);
170
        assertEquals("now have an owner", p, FileOwnerQuery.getOwner(extfile1));
171
        assertEquals("not for the projdir", null, FileOwnerQuery.getOwner(ext1));
172
        assertEquals("and not for something else", null, FileOwnerQuery.getOwner(scratch));
173
        FileObject ext2 = scratch.getFileObject("external2");
174
        FileObject extfile2 = ext2.getFileObject("subdir/file");
175
        assertEquals("no owner yet", null, FileOwnerQuery.getOwner(extfile2));
176
        Project p2 = ProjectManager.getDefault().findProject(subprojdir);
177
        FileOwnerQuery.markExternalOwner(extfile2, p2, FileOwnerQuery.EXTERNAL_ALGORITHM_TRANSIENT);
178
        assertEquals("now have an owner", p2, FileOwnerQuery.getOwner(extfile2));
179
        assertEquals("not for the projdir", null, FileOwnerQuery.getOwner(ext2));
180
        assertEquals("and not for something else", null, FileOwnerQuery.getOwner(scratch));
181
        assertEquals("still correct for first proj", p, FileOwnerQuery.getOwner(extfile1));
182
        
183
        //XXX: unmarking files.
184
    }
185
    
186
    public void testExternalOwnerURI() throws Exception {
187
        FileObject ext1 = scratch.getFileObject("external1");
188
        FileObject extfile1 = ext1.getFileObject("subdir/file");
189
        assertEquals("no owner yet through FileObjects", null, FileOwnerQuery.getOwner(extfile1));
190
        assertEquals("no owner yet through URI", null, FileOwnerQuery.getOwner(extfile1));
191
        FileOwnerQuery.markExternalOwner(fileObject2URI(ext1), p, FileOwnerQuery.EXTERNAL_ALGORITHM_TRANSIENT);
192
        assertEquals("now have an owner through FileObjects", p, FileOwnerQuery.getOwner(extfile1));
193
        assertEquals("now have an owner through URI", p, FileOwnerQuery.getOwner(fileObject2URI(extfile1)));
194
        assertEquals("even for the projdir throught FileObjects", p, FileOwnerQuery.getOwner(ext1));
195
        assertEquals("even for the projdir throught URI", p, FileOwnerQuery.getOwner(fileObject2URI(ext1)));
196
        assertEquals("but not for something else throught FileObjects", null, FileOwnerQuery.getOwner(scratch));
197
        assertEquals("but not for something else throught URI", null, FileOwnerQuery.getOwner(fileObject2URI(scratch)));
198
        FileObject ext2 = scratch.getFileObject("external2");
199
        FileObject extfile2 = ext2.getFileObject("subdir/file");
200
        assertEquals("no owner yet through FileObjects", null, FileOwnerQuery.getOwner(extfile2));
201
        assertEquals("no owner yet through URI", null, FileOwnerQuery.getOwner(fileObject2URI(extfile2)));
202
        Project p2 = ProjectManager.getDefault().findProject(subprojdir);
203
        FileOwnerQuery.markExternalOwner(fileObject2URI(ext2), p2, FileOwnerQuery.EXTERNAL_ALGORITHM_TRANSIENT);
204
        assertEquals("now have an owner through FileObjects", p2, FileOwnerQuery.getOwner(extfile2));
205
        assertEquals("now have an owner through URI", p2, FileOwnerQuery.getOwner(fileObject2URI(extfile2)));
206
        assertEquals("even for the projdir through FileObjects", p2, FileOwnerQuery.getOwner(ext2));
207
        assertEquals("even for the projdir through URI", p2, FileOwnerQuery.getOwner(ext2));
208
        assertEquals("but not for something else through FileObjects", null, FileOwnerQuery.getOwner(scratch));
209
        assertEquals("but not for something else through URI", null, FileOwnerQuery.getOwner(fileObject2URI(scratch)));
210
        assertEquals("still correct for first proj through FileObjects", p, FileOwnerQuery.getOwner(extfile1));
211
        assertEquals("still correct for first proj through URI", p, FileOwnerQuery.getOwner(fileObject2URI(extfile1)));
212
        FileObject ext3 = scratch.getFileObject("external3");
213
        assertEquals("no owner yet through FileObjects", null, FileOwnerQuery.getOwner(ext3));
214
        assertEquals("no owner yet through URI", null, FileOwnerQuery.getOwner(fileObject2URI(ext3)));
215
        FileOwnerQuery.markExternalOwner(fileObject2URI(ext3), p, FileOwnerQuery.EXTERNAL_ALGORITHM_TRANSIENT);
216
        assertEquals("now have an owner through FileObjects", p, FileOwnerQuery.getOwner(ext3));
217
        assertEquals("now have an owner through URI", p, FileOwnerQuery.getOwner(fileObject2URI(ext3)));
218
        FileObject ext3subproj = ext3.getFileObject("subproject");
219
        Project p3 = FileOwnerQuery.getOwner(ext3subproj);
220
        assertNotSame("different project", p, p3);
221
        assertEquals("but subprojects are not part of it", ProjectManager.getDefault().findProject(ext3subproj), p3);
222
        FileOwnerQuery.markExternalOwner(fileObject2URI(ext3), null, FileOwnerQuery.EXTERNAL_ALGORITHM_TRANSIENT);
223
        assertEquals("unmarking an owner works through FileObjects", null, FileOwnerQuery.getOwner(ext3));
224
        assertEquals("unmarking an owner works through URI", null, FileOwnerQuery.getOwner(fileObject2URI(ext3)));
225
    }
226
    
227
    public void testExternalOwnerFileURI() throws Exception {
228
        FileObject ext1 = scratch.getFileObject("external1");
229
        FileObject extfile1 = ext1.getFileObject("subdir/file");
230
        assertEquals("no owner yet through FileObjects", null, FileOwnerQuery.getOwner(extfile1));
231
        assertEquals("no owner yet through URI", null, FileOwnerQuery.getOwner(fileObject2URI(extfile1)));
232
        FileOwnerQuery.markExternalOwner(fileObject2URI(extfile1), p, FileOwnerQuery.EXTERNAL_ALGORITHM_TRANSIENT);
233
        assertEquals("now have an owner through FileObjects", p, FileOwnerQuery.getOwner(extfile1));
234
        assertEquals("now have an owner through URI", p, FileOwnerQuery.getOwner(fileObject2URI(extfile1)));
235
        assertEquals("not for the projdir through FileObjects", null, FileOwnerQuery.getOwner(ext1));
236
        assertEquals("not for the projdir through URI", null, FileOwnerQuery.getOwner(fileObject2URI(ext1)));
237
        assertEquals("and not for something else through FileObjects", null, FileOwnerQuery.getOwner(scratch));
238
        assertEquals("and not for something else through URI", null, FileOwnerQuery.getOwner(fileObject2URI(scratch)));
239
        FileObject ext2 = scratch.getFileObject("external2");
240
        FileObject extfile2 = ext2.getFileObject("subdir/file");
241
        assertEquals("no owner yet through FileObjects", null, FileOwnerQuery.getOwner(extfile2));
242
        assertEquals("no owner yet through URI", null, FileOwnerQuery.getOwner(fileObject2URI(extfile2)));
243
        Project p2 = ProjectManager.getDefault().findProject(subprojdir);
244
        FileOwnerQuery.markExternalOwner(fileObject2URI(extfile2), p2, FileOwnerQuery.EXTERNAL_ALGORITHM_TRANSIENT);
245
        assertEquals("now have an owner through FileObjects", p2, FileOwnerQuery.getOwner(extfile2));
246
        assertEquals("now have an owner through URI", p2, FileOwnerQuery.getOwner(fileObject2URI(extfile2)));
247
        assertEquals("not for the projdir through FileObjects", null, FileOwnerQuery.getOwner(ext2));
248
        assertEquals("not for the projdir through URI", null, FileOwnerQuery.getOwner(fileObject2URI(ext2)));
249
        assertEquals("and not for something else through FileObjects", null, FileOwnerQuery.getOwner(scratch));
250
        assertEquals("and not for something else through URI", null, FileOwnerQuery.getOwner(fileObject2URI(scratch)));
251
        assertEquals("still correct for first proj through FileObjects", p, FileOwnerQuery.getOwner(extfile1));
252
        assertEquals("still correct for first proj through URI", p, FileOwnerQuery.getOwner(fileObject2URI(extfile1)));
253
        
254
        //XXX: unmarking files.
255
    }
256
    
257
    public void testIsProjectDirCollectable() throws Exception {
258
        Project p2 = ProjectManager.getDefault().findProject(subprojdir);
259
        FileObject root = p2.getProjectDirectory();
260
        FileObject ext2 = scratch.getFileObject("external2");
261
        FileObject extfile2 = ext2.getFileObject("subdir/file");
262
        
263
        FileOwnerQuery.markExternalOwner(fileObject2URI(extfile2), p2, FileOwnerQuery.EXTERNAL_ALGORITHM_TRANSIENT);
264
        
265
        WeakReference p2WR = new WeakReference(p2);
266
        WeakReference rootWR = new WeakReference(root);
267
        
268
        p2 = null;
269
        root = null;
270
        ext2 = null;
271
        extfile2 = null;
272
        subprojdir = null;
273
        subprojfile = null;
274
        
275
        assertGC("project 2 collected", p2WR);
276
        assertGC("project 2's project dir collected", rootWR);
277
    }
278
    
279
    private static URI fileObject2URI(FileObject f) throws Exception {
280
        return URI.create(f.getURL().toString());
159
    }
281
    }
160
    
282
    
161
    // XXX test URI usage of external owner
283
    // XXX test URI usage of external owner

Return to bug 58313