mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Add a mechanism for injecting code before application startup
Currently this is needed for Rider to start the ReSharper backend as soon as possible - even before application init and other costly tasks
This commit is contained in:
@@ -41,6 +41,7 @@ import javax.swing.*;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.lang.reflect.Method;
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.nio.channels.FileLock;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
@@ -58,6 +59,7 @@ import java.util.Random;
|
||||
*/
|
||||
public class StartupUtil {
|
||||
public static final String NO_SPLASH = "nosplash";
|
||||
public static final String IDEA_CLASS_BEFORE_APPLICATION_PROPERTY = "idea.class.before.app";
|
||||
|
||||
private static SocketLock ourSocketLock;
|
||||
|
||||
@@ -82,6 +84,19 @@ public class StartupUtil {
|
||||
default void beforeImportConfigs() {}
|
||||
}
|
||||
|
||||
private static void runPreAppClass(Logger log) {
|
||||
String classBeforeAppProperty = System.getProperty(IDEA_CLASS_BEFORE_APPLICATION_PROPERTY);
|
||||
if (classBeforeAppProperty != null) {
|
||||
try {
|
||||
Class<?> clazz = Class.forName(classBeforeAppProperty);
|
||||
Method invokeMethod = clazz.getDeclaredMethod("invoke");
|
||||
invokeMethod.invoke(null);
|
||||
} catch (Exception ex) {
|
||||
log.error("Failed pre-app class init for class " + classBeforeAppProperty, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void prepareAndStart(String[] args, AppStarter appStarter) {
|
||||
IdeaForkJoinWorkerThreadFactory.setupForkJoinCommonPool(Main.isHeadless(args));
|
||||
boolean newConfigFolder = false;
|
||||
@@ -132,6 +147,8 @@ public class StartupUtil {
|
||||
loadSystemLibraries(log);
|
||||
fixProcessEnvironment(log);
|
||||
|
||||
runPreAppClass(log);
|
||||
|
||||
if (!Main.isHeadless()) {
|
||||
UIUtil.initDefaultLAF();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user