IJPL-219 don't use deprecated componentsInitialized

GitOrigin-RevId: 4c91c49794534019130b1e6f2c2157f294979cc2
This commit is contained in:
Vladimir Krivosheev
2023-08-27 10:16:32 +03:00
committed by intellij-monorepo-bot
parent 35b0c3ee60
commit 8e68c3d352
2 changed files with 29 additions and 14 deletions

View File

@@ -15,15 +15,30 @@ import org.jetbrains.annotations.ApiStatus
@ApiStatus.Internal
interface ApplicationInitializedListener {
/**
* Invoked when all application level components are initialized.
* Write actions and time-consuming activities are not recommended because directly affects application start time.
* Invoked when application level is nearly initialized.
* Write actions and time-consuming activities are forbidden because it directly affects application start time.
*/
suspend fun execute(asyncScope: CoroutineScope): Unit = blockingContext {
@Suppress("DEPRECATION")
componentsInitialized()
suspend fun execute(asyncScope: CoroutineScope) {
blockingContext {
@Suppress("DEPRECATION")
componentsInitialized()
}
}
@Deprecated("Use {@link #execute()}", ReplaceWith("execute()"))
fun componentsInitialized() {
@Deprecated("Use {@link #execute()}", ReplaceWith("execute()"))
fun componentsInitialized() {
}
}
@Deprecated("Consider avoiding using of ApplicationInitializedListener")
abstract class ApplicationInitializedListenerJavaShim : ApplicationInitializedListener {
final override suspend fun execute(asyncScope: CoroutineScope) {
blockingContext {
@Suppress("DEPRECATION")
componentsInitialized()
}
}
@Suppress("OVERRIDE_DEPRECATION")
abstract override fun componentsInitialized()
}

View File

@@ -2,13 +2,13 @@
package com.intellij.openapi.application.impl;
import com.intellij.execution.process.OSProcessUtil;
import com.intellij.ide.ApplicationInitializedListener;
import com.intellij.ide.ApplicationInitializedListenerJavaShim;
import com.intellij.ide.PowerSaveMode;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.ex.ApplicationManagerEx;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.util.text.Strings;
import com.sun.tools.attach.VirtualMachine;
import org.jetbrains.annotations.NonNls;
import sun.tools.attach.HotSpotVirtualMachine;
@@ -16,14 +16,14 @@ import sun.tools.attach.HotSpotVirtualMachine;
import java.io.File;
// NOTE: compile with --add-exports jdk.attach/sun.tools.attach=ALL-UNNAMED in module-aware jdk
final class JitSuppressor implements ApplicationInitializedListener {
final class JitSuppressor extends ApplicationInitializedListenerJavaShim {
private static final Logger LOG = Logger.getInstance(JitSuppressor.class);
private static final String SELF_ATTACH_PROP = "jdk.attach.allowAttachSelf";
private static final String EXCLUDE_ALL_FROM_C2_CLAUSE = "{ match : [\"*.*\"], c2 : { Exclude : true }}";
// Limit C2 compilation to the given packages only. The package set was computed by test performance analysis:
// it's supposed to make performance tests (not all yet) timing comparable with full C2
// and at same time the IDE does not load CPU heavily with this limitation.
// it's supposed to make performance tests (not all yet) timing comparable with full C2, and at the same time,
// the IDE does not load CPU heavily with this limitation.
private static final @NonNls String[] C2_WHITELIST = {
"com/intellij/openapi/application/*.*",
"com/intellij/openapi/editor/*.*",
@@ -136,9 +136,9 @@ final class JitSuppressor implements ApplicationInitializedListener {
}
if (ourBlacklistMode) {
return StringUtil.join(C2_BLACKLIST, mask -> "{ match: [\"" + mask + "\"], c2: { Exclude: true, }, },", "");
return Strings.join(C2_BLACKLIST, mask -> "{ match: [\"" + mask + "\"], c2: { Exclude: true, }, },", "");
}
return StringUtil.join(C2_WHITELIST, mask -> "{ match: [\"" + mask + "\"], c2: { Exclude: false, }, },", "") +
return Strings.join(C2_WHITELIST, mask -> "{ match: [\"" + mask + "\"], c2: { Exclude: false, }, },", "") +
EXCLUDE_ALL_FROM_C2_CLAUSE;
}
}