2022-01-04 17:48:01 +01:00
|
|
|
package io.gitlab.jfronny.inceptum.cli.commands;
|
|
|
|
|
|
|
|
import io.gitlab.jfronny.inceptum.cli.Command;
|
|
|
|
import io.gitlab.jfronny.inceptum.cli.CommandArgs;
|
2021-10-30 22:05:24 +02:00
|
|
|
|
|
|
|
import java.net.URLClassLoader;
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
|
|
|
public class JvmStateCommand extends Command {
|
|
|
|
public JvmStateCommand() {
|
2022-01-04 20:49:57 +01:00
|
|
|
super("Displays information about the JVM state. For debugging", "", "jvmstate");
|
2021-10-30 22:05:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2022-01-04 17:48:01 +01:00
|
|
|
protected void invoke(CommandArgs args) {
|
2021-10-30 22:05:24 +02:00
|
|
|
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());
|
|
|
|
}
|
|
|
|
}
|