|
15 | 15 | import io.opentelemetry.semconv.ResourceAttributes;
|
16 | 16 | import java.io.IOException;
|
17 | 17 | import java.io.InputStream;
|
18 |
| -import java.lang.reflect.Method; |
19 |
| -import java.nio.file.Files; |
20 |
| -import java.nio.file.Paths; |
21 | 18 | import java.util.Map;
|
22 | 19 | import java.util.Objects;
|
23 |
| -import java.util.Optional; |
24 | 20 | import java.util.Properties;
|
25 | 21 | import java.util.function.Function;
|
26 | 22 | import java.util.function.Supplier;
|
@@ -264,59 +260,4 @@ private String loadFromClasspath(String filename, Function<InputStream, String>
|
264 | 260 | return null;
|
265 | 261 | }
|
266 | 262 | }
|
267 |
| - |
268 |
| - // Exists for testing |
269 |
| - static class SystemHelper { |
270 |
| - private final ClassLoader classLoader; |
271 |
| - private final boolean addBootInfPrefix; |
272 |
| - |
273 |
| - SystemHelper() { |
274 |
| - ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader(); |
275 |
| - classLoader = |
276 |
| - contextClassLoader != null ? contextClassLoader : ClassLoader.getSystemClassLoader(); |
277 |
| - addBootInfPrefix = classLoader.getResource("BOOT-INF/classes/") != null; |
278 |
| - if (addBootInfPrefix) { |
279 |
| - logger.log(Level.FINER, "Detected presence of BOOT-INF/classes/"); |
280 |
| - } |
281 |
| - } |
282 |
| - |
283 |
| - String getenv(String name) { |
284 |
| - return System.getenv(name); |
285 |
| - } |
286 |
| - |
287 |
| - String getProperty(String key) { |
288 |
| - return System.getProperty(key); |
289 |
| - } |
290 |
| - |
291 |
| - InputStream openClasspathResource(String filename) { |
292 |
| - String path = addBootInfPrefix ? "BOOT-INF/classes/" + filename : filename; |
293 |
| - return classLoader.getResourceAsStream(path); |
294 |
| - } |
295 |
| - |
296 |
| - InputStream openClasspathResource(String filename, String location) { |
297 |
| - String path = location + "/" + filename; |
298 |
| - return classLoader.getResourceAsStream(path); |
299 |
| - } |
300 |
| - |
301 |
| - InputStream openFile(String filename) throws Exception { |
302 |
| - return Files.newInputStream(Paths.get(filename)); |
303 |
| - } |
304 |
| - |
305 |
| - /** |
306 |
| - * Attempts to use ProcessHandle to get the full commandline of the current process (including |
307 |
| - * the main method arguments). Will only succeed on java 9+. |
308 |
| - */ |
309 |
| - @SuppressWarnings("unchecked") |
310 |
| - String[] attemptGetCommandLineArgsViaReflection() throws Exception { |
311 |
| - Class<?> clazz = Class.forName("java.lang.ProcessHandle"); |
312 |
| - Method currentMethod = clazz.getDeclaredMethod("current"); |
313 |
| - Method infoMethod = clazz.getDeclaredMethod("info"); |
314 |
| - Object currentInstance = currentMethod.invoke(null); |
315 |
| - Object info = infoMethod.invoke(currentInstance); |
316 |
| - Class<?> infoClass = Class.forName("java.lang.ProcessHandle$Info"); |
317 |
| - Method argumentsMethod = infoClass.getMethod("arguments"); |
318 |
| - Optional<String[]> optionalArgs = (Optional<String[]>) argumentsMethod.invoke(info); |
319 |
| - return optionalArgs.orElse(new String[0]); |
320 |
| - } |
321 |
| - } |
322 | 263 | }
|
0 commit comments