diff --git a/java/java-backend/resources/META-INF/JavaPlugin.xml b/java/java-backend/resources/META-INF/JavaPlugin.xml
index e62023397a89..742001bf87a0 100644
--- a/java/java-backend/resources/META-INF/JavaPlugin.xml
+++ b/java/java-backend/resources/META-INF/JavaPlugin.xml
@@ -41,8 +41,8 @@
-
+
diff --git a/java/java-impl/src/com/intellij/openapi/roots/impl/ModulePackageIndexFactoryImpl.kt b/java/java-impl/src/com/intellij/openapi/roots/impl/ModulePackageIndexFactoryImpl.kt
new file mode 100644
index 000000000000..014c280f2f81
--- /dev/null
+++ b/java/java-impl/src/com/intellij/openapi/roots/impl/ModulePackageIndexFactoryImpl.kt
@@ -0,0 +1,12 @@
+// 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.openapi.roots.impl
+
+import com.intellij.openapi.module.Module
+import com.intellij.openapi.roots.ModulePackageIndex
+import com.intellij.openapi.roots.ModulePackageIndexFactory
+
+internal class ModulePackageIndexFactoryImpl: ModulePackageIndexFactory {
+ override fun getService(module: Module): ModulePackageIndex {
+ return ModulePackageIndexImpl(module)
+ }
+}
\ No newline at end of file
diff --git a/java/java-indexing-api/src/com/intellij/openapi/roots/ModulePackageIndex.java b/java/java-indexing-api/src/com/intellij/openapi/roots/ModulePackageIndex.java
index 3e11fee5c316..87ccc16a7946 100644
--- a/java/java-indexing-api/src/com/intellij/openapi/roots/ModulePackageIndex.java
+++ b/java/java-indexing-api/src/com/intellij/openapi/roots/ModulePackageIndex.java
@@ -5,6 +5,6 @@ import com.intellij.openapi.module.Module;
public abstract class ModulePackageIndex extends PackageIndex {
public static ModulePackageIndex getInstance(Module module) {
- return module.getService(ModulePackageIndex.class);
+ return module.getProject().getService(ModulePackageIndexFactory.class).getService(module);
}
}
diff --git a/java/java-indexing-api/src/com/intellij/openapi/roots/ModulePackageIndexFactory.kt b/java/java-indexing-api/src/com/intellij/openapi/roots/ModulePackageIndexFactory.kt
new file mode 100644
index 000000000000..88879fb84fbd
--- /dev/null
+++ b/java/java-indexing-api/src/com/intellij/openapi/roots/ModulePackageIndexFactory.kt
@@ -0,0 +1,10 @@
+// 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.openapi.roots
+
+import com.intellij.openapi.module.Module
+import org.jetbrains.annotations.ApiStatus
+
+@ApiStatus.Internal
+interface ModulePackageIndexFactory {
+ fun getService(module: Module): ModulePackageIndex
+}
\ No newline at end of file