Inceptum/src/main/java/io/gitlab/jfronny/inceptum/cli/JvmStateCommand.java
2021-10-30 22:05:24 +02:00

29 lines
898 B
Java

package io.gitlab.jfronny.inceptum.cli;
import java.net.URLClassLoader;
import java.util.Arrays;
public class JvmStateCommand extends Command {
public JvmStateCommand() {
super("Displays information about the JVM state. For debugging", "jvmstate");
}
@Override
public void invoke(String[] args) {
System.out.println(System.getProperty("java.class.path"));
dumpClasspath(JvmStateCommand.class.getClassLoader());
}
private static void dumpClasspath(ClassLoader loader) {
System.out.println("Classloader " + loader + ":");
if (loader instanceof URLClassLoader uc)
System.out.println("\t" + Arrays.toString(uc.getURLs()));
else
System.out.println("\t(cannot display components as not a URLClassLoader)");
if (loader.getParent() != null)
dumpClasspath(loader.getParent());
}
}