|
1 | 1 | package datadog.trace.agent.test; |
2 | 2 |
|
3 | | -import static com.google.common.base.StandardSystemProperty.JAVA_CLASS_PATH; |
4 | | -import static com.google.common.base.StandardSystemProperty.PATH_SEPARATOR; |
| 3 | +import static java.io.File.pathSeparator; |
5 | 4 |
|
6 | | -import com.google.common.base.Splitter; |
7 | | -import com.google.common.collect.ImmutableList; |
8 | 5 | import com.google.common.reflect.ClassPath; |
9 | 6 | import datadog.trace.agent.test.utils.ClasspathUtils; |
10 | 7 | import datadog.trace.bootstrap.BootstrapProxy; |
|
14 | 11 | import java.net.MalformedURLException; |
15 | 12 | import java.net.URL; |
16 | 13 | import java.net.URLClassLoader; |
| 14 | +import java.util.ArrayList; |
17 | 15 | import java.util.Arrays; |
18 | 16 | import java.util.HashMap; |
19 | 17 | import java.util.HashSet; |
| 18 | +import java.util.List; |
20 | 19 | import java.util.Map; |
21 | 20 | import java.util.Set; |
22 | 21 | import java.util.TreeSet; |
@@ -111,26 +110,28 @@ private static ClassPath computeTestClasspath() { |
111 | 110 | */ |
112 | 111 | @SuppressForbidden |
113 | 112 | private static ClassLoader buildJavaClassPathClassLoader() { |
114 | | - final ImmutableList.Builder<URL> urls = ImmutableList.builder(); |
115 | | - for (final String entry : Splitter.on(PATH_SEPARATOR.value()).split(JAVA_CLASS_PATH.value())) { |
| 113 | + List<URL> urls = new ArrayList<>(); |
| 114 | + String classPath = System.getProperty("java.class.path", ""); |
| 115 | + for (String entry : classPath.split(pathSeparator)) { |
116 | 116 | try { |
| 117 | + File pathEntry = new File(entry); |
117 | 118 | try { |
118 | | - urls.add(new File(entry).toURI().toURL()); |
119 | | - } catch (final SecurityException e) { // File.toURI checks to see if the file is a directory |
120 | | - urls.add(new URL("file", null, new File(entry).getAbsolutePath())); |
| 119 | + urls.add(pathEntry.toURI().toURL()); |
| 120 | + } catch (final SecurityException e) { |
| 121 | + urls.add(new URL("file", null, pathEntry.getAbsolutePath())); |
121 | 122 | } |
122 | 123 | } catch (final MalformedURLException e) { |
123 | 124 | System.err.printf( |
124 | 125 | "Error injecting bootstrap jar: Malformed classpath entry: %s. %s%n", entry, e); |
125 | 126 | } |
126 | 127 | } |
127 | | - return new URLClassLoader(urls.build().toArray(new URL[0]), null); |
| 128 | + return new URLClassLoader(urls.toArray(new URL[0]), null); |
128 | 129 | } |
129 | 130 |
|
130 | 131 | private static void setupBootstrapClasspath() { |
131 | 132 | // Ensure there weren't any bootstrap classes loaded prematurely. |
132 | 133 | Set<String> prematureBootstrapClasses = new TreeSet<>(); |
133 | | - for (Class clazz : ByteBuddyAgent.getInstrumentation().getAllLoadedClasses()) { |
| 134 | + for (Class<?> clazz : ByteBuddyAgent.getInstrumentation().getAllLoadedClasses()) { |
134 | 135 | if (isBootstrapClass(clazz) |
135 | 136 | && clazz.getClassLoader() != null |
136 | 137 | && !clazz.getName().equals("datadog.trace.api.DisableTestTrace") |
|
0 commit comments