sandbox/java.hints/spi.java.hints/test/unit/src/org/netbeans/modules/java/hints/spiimpl/batch/BatchSearchTest.java
1.1 --- a/sandbox/java.hints/spi.java.hints/test/unit/src/org/netbeans/modules/java/hints/spiimpl/batch/BatchSearchTest.java Mon Dec 19 11:37:36 2016 +0100
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,458 +0,0 @@
1.4 -/*
1.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
1.6 - *
1.7 - * Copyright 2009-2011 Oracle and/or its affiliates. All rights reserved.
1.8 - *
1.9 - * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
1.10 - * Other names may be trademarks of their respective owners.
1.11 - *
1.12 - * The contents of this file are subject to the terms of either the GNU
1.13 - * General Public License Version 2 only ("GPL") or the Common
1.14 - * Development and Distribution License("CDDL") (collectively, the
1.15 - * "License"). You may not use this file except in compliance with the
1.16 - * License. You can obtain a copy of the License at
1.17 - * http://www.netbeans.org/cddl-gplv2.html
1.18 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
1.19 - * specific language governing permissions and limitations under the
1.20 - * License. When distributing the software, include this License Header
1.21 - * Notice in each file and include the License file at
1.22 - * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
1.23 - * particular file as subject to the "Classpath" exception as provided
1.24 - * by Oracle in the GPL Version 2 section of the License file that
1.25 - * accompanied this code. If applicable, add the following below the
1.26 - * License Header, with the fields enclosed by brackets [] replaced by
1.27 - * your own identifying information:
1.28 - * "Portions Copyrighted [year] [name of copyright owner]"
1.29 - *
1.30 - * If you wish your version of this file to be governed by only the CDDL
1.31 - * or only the GPL Version 2, indicate your decision by adding
1.32 - * "[Contributor] elects to include this software in this distribution
1.33 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
1.34 - * single choice of license, a recipient has the option to distribute
1.35 - * your version of this file under either the CDDL, the GPL Version 2 or
1.36 - * to extend the choice of license to its licensees as provided above.
1.37 - * However, if you add GPL Version 2 code and therefore, elected the GPL
1.38 - * Version 2 license, then the option applies only if the new code is
1.39 - * made subject to such option by the copyright holder.
1.40 - *
1.41 - * Contributor(s):
1.42 - *
1.43 - * Portions Copyrighted 2009-2011 Sun Microsystems, Inc.
1.44 - */
1.45 -package org.netbeans.modules.java.hints.spiimpl.batch;
1.46 -
1.47 -import org.netbeans.modules.java.hints.spiimpl.batch.TestUtils.File;
1.48 -import org.netbeans.modules.java.hints.spiimpl.MessageImpl;
1.49 -import org.netbeans.modules.java.hints.providers.spi.HintDescription;
1.50 -import java.net.URL;
1.51 -import java.util.ArrayList;
1.52 -import java.util.Arrays;
1.53 -import java.util.Collection;
1.54 -import java.util.Collections;
1.55 -import java.util.HashMap;
1.56 -import java.util.HashSet;
1.57 -import java.util.Iterator;
1.58 -import java.util.LinkedList;
1.59 -import java.util.List;
1.60 -import java.util.Map;
1.61 -import java.util.Map.Entry;
1.62 -import java.util.Set;
1.63 -import java.util.concurrent.atomic.AtomicBoolean;
1.64 -import java.util.regex.Pattern;
1.65 -import junit.framework.TestSuite;
1.66 -import org.netbeans.api.java.classpath.ClassPath;
1.67 -import org.netbeans.api.java.classpath.GlobalPathRegistry;
1.68 -import org.netbeans.api.java.classpath.GlobalPathRegistryEvent;
1.69 -import org.netbeans.api.java.classpath.GlobalPathRegistryListener;
1.70 -import org.netbeans.api.java.source.CompilationController;
1.71 -import org.netbeans.api.java.source.SourceUtilsTestUtil;
1.72 -import org.netbeans.core.startup.Main;
1.73 -import org.netbeans.junit.NbTestCase;
1.74 -import org.netbeans.junit.NbTestSuite;
1.75 -import org.netbeans.junit.RandomlyFails;
1.76 -import org.netbeans.modules.java.hints.spiimpl.batch.BatchSearch.BatchResult;
1.77 -import org.netbeans.modules.java.hints.spiimpl.batch.BatchSearch.Folder;
1.78 -import org.netbeans.modules.java.hints.spiimpl.batch.BatchSearch.Resource;
1.79 -import org.netbeans.modules.parsing.impl.indexing.CacheFolder;
1.80 -import org.netbeans.modules.parsing.impl.indexing.MimeTypes;
1.81 -import org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater;
1.82 -import org.netbeans.spi.editor.hints.ErrorDescription;
1.83 -import org.netbeans.spi.java.classpath.ClassPathProvider;
1.84 -import org.netbeans.spi.java.classpath.support.ClassPathSupport;
1.85 -import org.openide.filesystems.FileObject;
1.86 -import org.openide.filesystems.FileStateInvalidException;
1.87 -import org.openide.filesystems.FileUtil;
1.88 -
1.89 -import org.openide.util.Exceptions;
1.90 -import org.openide.util.lookup.ServiceProvider;
1.91 -import static org.netbeans.modules.java.hints.spiimpl.batch.TestUtils.writeFilesAndWaitForScan;
1.92 -import static org.netbeans.modules.java.hints.spiimpl.batch.TestUtils.prepareHints;
1.93 -
1.94 -/**
1.95 - *
1.96 - * @author lahvac
1.97 - */
1.98 -public class BatchSearchTest extends NbTestCase {
1.99 -
1.100 - public BatchSearchTest(String name) {
1.101 - super(name);
1.102 - }
1.103 -
1.104 - public static TestSuite suite() {
1.105 - TestSuite result = new NbTestSuite();
1.106 -
1.107 - result.addTestSuite(BatchSearchTest.class);
1.108 -// result.addTest(new BatchSearchTest("testBatchSearchFolderRemoteIndex"));
1.109 -
1.110 - return result;
1.111 - }
1.112 -
1.113 - //XXX: copied from CustomIndexerImplTest:
1.114 - @Override
1.115 - protected void setUp() throws Exception {
1.116 - SourceUtilsTestUtil.prepareTest(new String[0], new Object[0]);
1.117 - Main.initializeURLFactory();
1.118 - org.netbeans.api.project.ui.OpenProjects.getDefault().getOpenProjects();
1.119 - prepareTest();
1.120 - MimeTypes.setAllMimeTypes(Collections.singleton("text/x-java"));
1.121 - sourceCP = ClassPathSupport.createClassPath(src1, src2);
1.122 - GlobalPathRegistry.getDefault().register(ClassPath.SOURCE, new ClassPath[] {sourceCP});
1.123 - RepositoryUpdater.getDefault().start(true);
1.124 - super.setUp();
1.125 - }
1.126 -
1.127 - @Override
1.128 - protected void tearDown() throws Exception {
1.129 - super.tearDown();
1.130 - GlobalPathRegistry.getDefault().unregister(ClassPath.SOURCE, new ClassPath[] {sourceCP});
1.131 - }
1.132 -
1.133 - public void testBatchSearch1() throws Exception {
1.134 - writeFilesAndWaitForScan(src1,
1.135 - new File("test/Test1.java", "package test; public class Test1 { private void test() { java.io.File f = null; f.isDirectory(); } }"),
1.136 - new File("test/Test2.java", "package test; public class Test2 { private void test() { new javax.swing.ImageIcon(null); } }"));
1.137 - writeFilesAndWaitForScan(src2,
1.138 - new File("test/Test1.java", "package test; public class Test1 { private void test() { java.io.File f = null; f.isDirectory(); } }"),
1.139 - new File("test/Test2.java", "package test; public class Test2 { private void test() { new javax.swing.ImageIcon(null); } }"));
1.140 -
1.141 - Iterable<? extends HintDescription> hints = prepareHints("$1.isDirectory()");
1.142 - BatchResult result = BatchSearch.findOccurrences(hints, Scopes.allOpenedProjectsScope());
1.143 - Map<String, Iterable<String>> output = new HashMap<String, Iterable<String>>();
1.144 -
1.145 - for (Entry<FileObject, Collection<? extends Resource>> e : result.getResourcesWithRoots().entrySet()) {
1.146 - Collection<String> resourcesRepr = new LinkedList<String>();
1.147 -
1.148 - for (Resource r : e.getValue()) {
1.149 - resourcesRepr.add(r.getRelativePath());
1.150 - }
1.151 -
1.152 - output.put(e.getKey().getURL().toExternalForm(), resourcesRepr);
1.153 - }
1.154 -
1.155 - Map<String, Iterable<String>> golden = new HashMap<String, Iterable<String>>();
1.156 -
1.157 - golden.put(src1.getURL().toExternalForm(), Arrays.asList("test/Test1.java"));
1.158 - golden.put(src2.getURL().toExternalForm(), Arrays.asList("test/Test1.java"));
1.159 -
1.160 - assertEquals(golden, output);
1.161 - }
1.162 -
1.163 - public void testBatchSearchSpan() throws Exception {
1.164 - String code = "package test;\n" +
1.165 - "public class Test {\n" +
1.166 - " private void m() {\n" +
1.167 - " a(c.i().getFileObject());\n" +
1.168 - " if (span != null && span[0] != (-1) && span[1] != (-1));\n" +
1.169 - " c.i().getFileObject(\"\");\n" +
1.170 - " }\n" +
1.171 - "}\n";
1.172 -
1.173 - writeFilesAndWaitForScan(src1, new File("test/Test.java", code));
1.174 -
1.175 - Iterable<? extends HintDescription> hints = prepareHints("$0.getFileObject($1)");
1.176 - BatchResult result = BatchSearch.findOccurrences(hints, Scopes.allOpenedProjectsScope());
1.177 -
1.178 - assertEquals(1, result.getResources().size());
1.179 - Iterator<? extends Resource> resources = result.getResources().iterator().next().iterator();
1.180 - Resource r = resources.next();
1.181 -
1.182 - assertFalse(resources.hasNext());
1.183 -
1.184 - Set<String> snipets = new HashSet<String>();
1.185 -
1.186 - for (int[] span : r.getCandidateSpans()) {
1.187 - snipets.add(code.substring(span[0], span[1]));
1.188 - }
1.189 -
1.190 - Set<String> golden = new HashSet<String>(Arrays.asList("c.i().getFileObject(\"\")"));
1.191 - assertEquals(golden, snipets);
1.192 - }
1.193 -
1.194 - @RandomlyFails
1.195 - public void testBatchSearchNotIndexed() throws Exception {
1.196 - writeFilesAndWaitForScan(src1,
1.197 - new File("test/Test1.java", "package test; public class Test1 { private void test() { java.io.File f = null; f.isDirectory(); } }"),
1.198 - new File("test/Test2.java", "package test; public class Test2 { private void test() { new javax.swing.ImageIcon(null); } }"));
1.199 - writeFilesAndWaitForScan(src3,
1.200 - new File("test/Test1.java", "package test; public class Test1 { private void test() { Test2 f = null; f.isDirectory(); } }"),
1.201 - new File("test/Test2.java", "package test; public class Test2 { public boolean isDirectory() {return false} }"));
1.202 -
1.203 - Iterable<? extends HintDescription> hints = prepareHints("$1.isDirectory()", "$1", "test.Test2");
1.204 - BatchResult result = BatchSearch.findOccurrences(hints, Scopes.specifiedFoldersScope(Folder.convert(src1, src3, empty)));
1.205 - Map<String, Iterable<String>> output = new HashMap<String, Iterable<String>>();
1.206 -
1.207 - for (Entry<FileObject, Collection<? extends Resource>> e : result.getResourcesWithRoots().entrySet()) {
1.208 - Collection<String> resourcesRepr = new LinkedList<String>();
1.209 -
1.210 - for (Resource r : e.getValue()) {
1.211 - resourcesRepr.add(r.getRelativePath());
1.212 - }
1.213 -
1.214 - output.put(e.getKey().getURL().toExternalForm(), resourcesRepr);
1.215 - }
1.216 -
1.217 - Map<String, Iterable<String>> golden = new HashMap<String, Iterable<String>>();
1.218 -
1.219 - golden.put(src1.getURL().toExternalForm(), Arrays.asList("test/Test1.java"));
1.220 - golden.put(src3.getURL().toExternalForm(), Arrays.asList("test/Test1.java"));
1.221 -
1.222 - assertEquals(golden, output);
1.223 -
1.224 - //check verification:
1.225 - Map<String, Map<String, Iterable<String>>> verifiedOutput = verifiedSpans(result, false);
1.226 - Map<String, Map<String, Iterable<String>>> verifiedGolden = new HashMap<String, Map<String, Iterable<String>>>();
1.227 -
1.228 - verifiedGolden.put(src1.getURL().toExternalForm(), Collections.<String, Iterable<String>>singletonMap("test/Test1.java", Arrays.<String>asList()));
1.229 - verifiedGolden.put(src3.getURL().toExternalForm(), Collections.<String, Iterable<String>>singletonMap("test/Test1.java", Arrays.asList("0:75-0:86:verifier:")));
1.230 -
1.231 - assertEquals(verifiedGolden, verifiedOutput);
1.232 - }
1.233 -
1.234 - public void testBatchSearchForceIndexingOfProperDirectory() throws Exception {
1.235 - FileObject data = FileUtil.createFolder(workdir, "data");
1.236 - FileObject dataSrc1 = FileUtil.createFolder(data, "src1");
1.237 - FileObject dataSrc2 = FileUtil.createFolder(data, "src2");
1.238 - writeFilesAndWaitForScan(dataSrc1,
1.239 - new File("test/Test1.java", "package test; public class Test1 { private void test() { java.io.File f = null; f.isDirectory(); } }"),
1.240 - new File("test/Test2.java", "package test; public class Test2 { private void test() { new javax.swing.ImageIcon(null); } }"));
1.241 - writeFilesAndWaitForScan(dataSrc2,
1.242 - new File("test/Test1.java", "package test; public class Test1 { private void test() { Test2 f = null; f.isDirectory(); } }"),
1.243 - new File("test/Test2.java", "package test; public class Test2 { public boolean isDirectory() {return false} }"));
1.244 -
1.245 - ClassPathProviderImpl.setSourceRoots(Arrays.asList(dataSrc1, dataSrc2));
1.246 -
1.247 - Iterable<? extends HintDescription> hints = prepareHints("$1.isDirectory()", "$1", "test.Test2");
1.248 - BatchResult result = BatchSearch.findOccurrences(hints, Scopes.specifiedFoldersScope(Folder.convert(data)));
1.249 - Map<String, Iterable<String>> output = new HashMap<String, Iterable<String>>();
1.250 -
1.251 - for (Entry<FileObject, Collection<? extends Resource>> e : result.getResourcesWithRoots().entrySet()) {
1.252 - Collection<String> resourcesRepr = new HashSet<String>();
1.253 -
1.254 - for (Resource r : e.getValue()) {
1.255 - resourcesRepr.add(r.getRelativePath());
1.256 - }
1.257 -
1.258 - output.put(e.getKey().getURL().toExternalForm(), resourcesRepr);
1.259 - }
1.260 -
1.261 - Map<String, Iterable<String>> golden = new HashMap<String, Iterable<String>>();
1.262 -
1.263 - golden.put(data.getURL().toExternalForm(), new HashSet<String>(Arrays.asList("src1/test/Test1.java", "src2/test/Test1.java")));
1.264 -
1.265 - assertEquals(golden, output);
1.266 -
1.267 - //check verification:
1.268 - final Set<FileObject> added = new HashSet<FileObject>();
1.269 - final Set<FileObject> removed = new HashSet<FileObject>();
1.270 -
1.271 - GlobalPathRegistry.getDefault().addGlobalPathRegistryListener(new GlobalPathRegistryListener() {
1.272 - public void pathsAdded(GlobalPathRegistryEvent event) {
1.273 - for (ClassPath cp : event.getChangedPaths()) {
1.274 - added.addAll(Arrays.asList(cp.getRoots()));
1.275 - }
1.276 - }
1.277 - public void pathsRemoved(GlobalPathRegistryEvent event) {
1.278 - for (ClassPath cp : event.getChangedPaths()) {
1.279 - removed.addAll(Arrays.asList(cp.getRoots()));
1.280 - }
1.281 - }
1.282 - });
1.283 -
1.284 -// verifiedGolden.put(data.getURL().toExternalForm(), Arrays.asList("0:75-0:86:verifier:TODO: No display name"));
1.285 - Map<String, Map<String, Iterable<String>>> verifiedOutput = verifiedSpans(result, false);
1.286 - Map<String, Map<String, Iterable<String>>> verifiedGolden = new HashMap<String, Map<String, Iterable<String>>>();
1.287 -
1.288 - Map<String, Iterable<String>> verifiedGoldenPart = new HashMap<String, Iterable<String>>();
1.289 -
1.290 - verifiedGoldenPart.put("src1/test/Test1.java", Arrays.<String>asList());
1.291 - verifiedGoldenPart.put("src2/test/Test1.java", Arrays.<String>asList("0:75-0:86:verifier:"));
1.292 -
1.293 - verifiedGolden.put(data.getURL().toExternalForm(), verifiedGoldenPart);
1.294 -
1.295 - assertEquals(verifiedGolden, verifiedOutput);
1.296 - assertEquals(new HashSet<FileObject>(Arrays.asList(dataSrc1, dataSrc2)), added);
1.297 - assertEquals(new HashSet<FileObject>(Arrays.asList(dataSrc1, dataSrc2)), removed);
1.298 - }
1.299 -
1.300 - public void testBatchSearchFolderNoIndex() throws Exception {
1.301 - FileObject data = FileUtil.createFolder(workdir, "data");
1.302 - FileObject dataSrc1 = FileUtil.createFolder(data, "src1");
1.303 - FileObject dataSrc2 = FileUtil.createFolder(data, "src2");
1.304 - writeFilesAndWaitForScan(dataSrc1,
1.305 - new File("test/Test1.java", "package test; public class Test1 { private void test() { java.io.File f = null; f.isDirectory(); } }"),
1.306 - new File("test/Test2.java", "package test; public class Test2 { private void test() { new javax.swing.ImageIcon(null); } }"));
1.307 - writeFilesAndWaitForScan(dataSrc2,
1.308 - new File("test/Test1.java", "package test; public class Test1 { private void test() { Test2 f = null; f.isDirectory(); } }"),
1.309 - new File("test/Test2.java", "package test; public class Test2 { public boolean isDirectory() {return false} }"));
1.310 -
1.311 - Iterable<? extends HintDescription> hints = prepareHints("$1.isDirectory()");
1.312 - BatchResult result = BatchSearch.findOccurrences(hints, Scopes.specifiedFoldersScope(Folder.convert(Collections.singleton(data)))); //XXX: should be a no-index variant!
1.313 - Map<String, Iterable<String>> output = toDebugOutput(result);
1.314 - Map<String, Iterable<String>> golden = new HashMap<String, Iterable<String>>();
1.315 -
1.316 - golden.put(data.getURL().toExternalForm(), new HashSet<String>(Arrays.asList("src1/test/Test1.java", "src2/test/Test1.java")));
1.317 -
1.318 - assertEquals(golden, output);
1.319 - }
1.320 -
1.321 - private FileObject workdir;
1.322 - private FileObject src1;
1.323 - private FileObject src2;
1.324 - private FileObject src3;
1.325 - private FileObject empty;
1.326 - private ClassPath sourceCP;
1.327 -
1.328 - private void prepareTest() throws Exception {
1.329 - workdir = SourceUtilsTestUtil.makeScratchDir(this);
1.330 -
1.331 - src1 = FileUtil.createFolder(workdir, "src1");
1.332 - src2 = FileUtil.createFolder(workdir, "src2");
1.333 - src3 = FileUtil.createFolder(workdir, "src3");
1.334 - empty = FileUtil.createFolder(workdir, "empty");
1.335 -
1.336 - ClassPathProviderImpl.setSourceRoots(Arrays.asList(src1, src2, src3));
1.337 -
1.338 - FileObject cache = FileUtil.createFolder(workdir, "cache");
1.339 -
1.340 - CacheFolder.setCacheFolder(cache);
1.341 - }
1.342 -
1.343 - private Map<String, Iterable<String>> toDebugOutput(BatchResult result) throws Exception {
1.344 - Map<String, Iterable<String>> output = new HashMap<String, Iterable<String>>();
1.345 -
1.346 - for (Entry<FileObject, Collection<? extends Resource>> e : result.getResourcesWithRoots().entrySet()) {
1.347 - Collection<String> resourcesRepr = new HashSet<String>();
1.348 -
1.349 - for (Resource r : e.getValue()) {
1.350 - resourcesRepr.add(r.getRelativePath());
1.351 - }
1.352 -
1.353 - output.put(e.getKey().getURL().toExternalForm(), resourcesRepr);
1.354 - }
1.355 -
1.356 - return output;
1.357 - }
1.358 -
1.359 - private Map<String, Map<String, Iterable<String>>> verifiedSpans(BatchResult candidates, boolean doNotRegisterClassPath) throws Exception {
1.360 - final Map<String, Map<String, Iterable<String>>> result = new HashMap<String, Map<String, Iterable<String>>>();
1.361 - List<MessageImpl> errors = new LinkedList<MessageImpl>();
1.362 - BatchSearch.getVerifiedSpans(candidates, new ProgressHandleWrapper(1), new BatchSearch.VerifiedSpansCallBack() {
1.363 - public void groupStarted() {}
1.364 - public boolean spansVerified(CompilationController wc, Resource r, Collection<? extends ErrorDescription> hints) throws Exception {
1.365 - Map<String, Iterable<String>> files = result.get(r.getRoot().getURL().toExternalForm());
1.366 -
1.367 - if (files == null) {
1.368 - result.put(r.getRoot().getURL().toExternalForm(), files = new HashMap<String, Iterable<String>>());
1.369 - }
1.370 -
1.371 - Collection<String> currentHints = new LinkedList<String>();
1.372 -
1.373 - for (ErrorDescription ed : hints) {
1.374 - currentHints.add(ed.toString());
1.375 - }
1.376 -
1.377 - files.put(r.getRelativePath(), currentHints);
1.378 -
1.379 - return true;
1.380 - }
1.381 - public void groupFinished() {}
1.382 - public void cannotVerifySpan(Resource r) {
1.383 - fail("Cannot verify: " +r.getRelativePath());
1.384 - }
1.385 - }, doNotRegisterClassPath, errors, new AtomicBoolean());
1.386 -
1.387 - return result;
1.388 - }
1.389 -
1.390 - @ServiceProvider(service=ClassPathProvider.class)
1.391 - public static final class ClassPathProviderImpl implements ClassPathProvider {
1.392 -
1.393 - private static Collection<FileObject> sourceRoots;
1.394 -
1.395 - public synchronized static void setSourceRoots(Collection<FileObject> sourceRoots) {
1.396 - ClassPathProviderImpl.sourceRoots = sourceRoots;
1.397 - }
1.398 -
1.399 - public synchronized static Collection<FileObject> getSourceRoots() {
1.400 - return sourceRoots;
1.401 - }
1.402 -
1.403 - public synchronized ClassPath findClassPath(FileObject file, String type) {
1.404 - if (ClassPath.BOOT.equals(type)) {
1.405 - return ClassPathSupport.createClassPath(getBootClassPath().toArray(new URL[0]));
1.406 - }
1.407 -
1.408 - if (ClassPath.COMPILE.equals(type)) {
1.409 - return ClassPathSupport.createClassPath(new URL[0]);
1.410 - }
1.411 -
1.412 - if (ClassPath.SOURCE.equals(type) && sourceRoots != null) {
1.413 - for (FileObject sr : sourceRoots) {
1.414 - if (file.equals(sr) || FileUtil.isParentOf(sr, file)) {
1.415 - return ClassPathSupport.createClassPath(sr);
1.416 - }
1.417 - }
1.418 - }
1.419 -
1.420 - return null;
1.421 - }
1.422 -
1.423 - }
1.424 -
1.425 - //TODO: copied from SourceUtilsTestUtil:
1.426 - private static List<URL> bootClassPath;
1.427 -
1.428 - public static synchronized List<URL> getBootClassPath() {
1.429 - if (bootClassPath == null) {
1.430 - try {
1.431 - String cp = System.getProperty("sun.boot.class.path");
1.432 - List<URL> urls = new ArrayList<URL>();
1.433 - String[] paths = cp.split(Pattern.quote(System.getProperty("path.separator")));
1.434 -
1.435 - for (String path : paths) {
1.436 - java.io.File f = new java.io.File(path);
1.437 -
1.438 - if (!f.canRead())
1.439 - continue;
1.440 -
1.441 - FileObject fo = FileUtil.toFileObject(f);
1.442 -
1.443 - if (FileUtil.isArchiveFile(fo)) {
1.444 - fo = FileUtil.getArchiveRoot(fo);
1.445 - }
1.446 -
1.447 - if (fo != null) {
1.448 - urls.add(fo.getURL());
1.449 - }
1.450 - }
1.451 -
1.452 - bootClassPath = urls;
1.453 - } catch (FileStateInvalidException e) {
1.454 - Exceptions.printStackTrace(e);
1.455 - }
1.456 - }
1.457 -
1.458 - return bootClassPath;
1.459 - }
1.460 -
1.461 -}