Launcher/libLauncher/src/main/java/ru/gravit/launcher/LauncherAgent.java

37 lines
967 B
Java
Raw Normal View History

2018-09-17 10:07:32 +03:00
package ru.gravit.launcher;
import java.io.IOException;
import java.lang.instrument.Instrumentation;
import java.util.jar.JarFile;
import ru.gravit.utils.helper.LogHelper;
2018-09-17 10:07:32 +03:00
@LauncherAPI
public class LauncherAgent {
2018-09-22 17:33:00 +03:00
private static boolean isAgentStarted = false;
2018-09-17 10:07:32 +03:00
public static Instrumentation inst;
2018-09-22 17:33:00 +03:00
2018-09-17 10:07:32 +03:00
public static void addJVMClassPath(String path) throws IOException {
LogHelper.debug("Launcher Agent addJVMClassPath");
inst.appendToSystemClassLoaderSearch(new JarFile(path));
}
2018-09-22 17:33:00 +03:00
public boolean isAgentStarted() {
return isAgentStarted;
}
2018-09-17 10:07:32 +03:00
public static long getObjSize(Object obj) {
2018-09-22 17:33:00 +03:00
return inst.getObjectSize(obj);
2018-09-17 10:07:32 +03:00
}
2018-09-22 17:33:00 +03:00
2018-09-17 10:07:32 +03:00
public static void premain(String agentArgument, Instrumentation instrumentation) {
System.out.println("Launcher Agent");
inst = instrumentation;
isAgentStarted = true;
2018-09-17 10:07:32 +03:00
}
2018-11-08 15:30:16 +03:00
public static boolean isStarted() {
return isAgentStarted;
}
2018-09-17 10:07:32 +03:00
}