MCPcopy Create free account
hub / github.com/google/guice / getClassPathUrls

Method getClassPathUrls

core/test/com/google/inject/Asserts.java:205–224  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

203 /** Returns the URLs in the system class path. */
204 // TODO(user): Use a common API once that's available.
205 public static URL[] getClassPathUrls() {
206 if (Asserts.class.getClassLoader() instanceof URLClassLoader) {
207 return ((URLClassLoader) Asserts.class.getClassLoader()).getURLs();
208 }
209 ImmutableList.Builder<URL> urls = ImmutableList.builder();
210 for (String entry : Splitter.on(PATH_SEPARATOR.value()).split(JAVA_CLASS_PATH.value())) {
211 try {
212 try {
213 urls.add(new File(entry).toURI().toURL());
214 } catch (SecurityException e) { // File.toURI checks to see if the file is a directory
215 urls.add(new URL("file", null, new File(entry).getAbsolutePath()));
216 }
217 } catch (MalformedURLException e) {
218 AssertionError error = new AssertionError("malformed class path entry: " + entry);
219 error.initCause(e);
220 throw error;
221 }
222 }
223 return urls.build().toArray(new URL[0]);
224 }
225}

Callers 3

copyClassMethod · 0.80

Calls 4

buildMethod · 0.65
builderMethod · 0.45
valueMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected