diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/inference/ContractInferenceGist.kt b/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/inference/ContractInferenceGist.kt
new file mode 100644
index 000000000000..51b71d4ac911
--- /dev/null
+++ b/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/inference/ContractInferenceGist.kt
@@ -0,0 +1,38 @@
+// Copyright 2000-2026 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
+package com.intellij.codeInspection.dataFlow.inference
+
+import com.intellij.openapi.application.ApplicationManager
+import com.intellij.openapi.components.Service
+import com.intellij.util.gist.GistManager
+import com.intellij.util.gist.PsiFileGist
+
+private const val VERSION = 14
+
+/**
+ * Holds the [PsiFileGist] for caching contract inference results.
+ *
+ * This is a separate service to avoid accessing [GistManager] during static class initialization of [InferenceVisitor],
+ * which violates platform rules (class initialization must not depend on services).
+ * See LSP-407 to learn more.
+ */
+@Service
+internal class ContractInferenceGist {
+ val gist: PsiFileGist