Skip to content

Commit 4d3c8ea

Browse files
fix: remove isAtLeastJava9 check in CoreJrtFileSystem
Co-authored-by: Akash Yadav <akashyadav@appdevforall.org> Signed-off-by: Akash Yadav <akashyadav@appdevforall.org>
1 parent 75c4fe2 commit 4d3c8ea

9 files changed

Lines changed: 49 additions & 19 deletions
Lines changed: 41 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
From 6f5f186a640e0d4ef0bff4d18dbb36f969dc5b16 Mon Sep 17 00:00:00 2001
1+
From 64b33dba002ec2b661f1e7cc8a1a6a1667e751d8 Mon Sep 17 00:00:00 2001
22
From: Akash Yadav <akashyadav@appdevforall.org>
33
Date: Thu, 26 Mar 2026 14:12:33 +0530
44
Subject: [PATCH 1/9] fix: use application class loader to find jrt:/ file
@@ -9,24 +9,54 @@ To ensure Kotlin's CoreJrtFileSystem can find the jrt:/ file system, we need to
99
use the application class loader. This makes it possible for the consuming application
1010
to provide its own implementation of the jrt:/ file system (as we do in Code On the Go).
1111

12+
The isAtLeastJava9() branch is removed rather than kept: androidJavaVersion() reports
13+
Java 8 for SDK_INT < 31, so on API <= 30 the old code took the URLClassLoader(jrt-fs.jar)
14+
fallback, which cannot work on ART and broke LSP initialization. With the provider always
15+
resolved from the application class loader there is no version-dependent path left.
16+
17+
The jrt-fs.jar existence check in globalJrtFsCache goes away with it. The bundled JDK home
18+
always contains lib/jrt-fs.jar, so the check never failed, and isModularJdk() still guards
19+
JDK root configuration in jvmArguments.kt and JvmContentRoots.kt.
20+
21+
See https://github.com/appdevforall/CodeOnTheGo/issues/1334
22+
23+
Co-authored-by: Wadamzmail <alksndrmetwakil@gmail.com>
1224
Signed-off-by: Akash Yadav <akashyadav@appdevforall.org>
1325
---
14-
.../org/jetbrains/kotlin/cli/jvm/modules/CoreJrtFileSystem.kt | 2 +-
15-
1 file changed, 1 insertion(+), 1 deletion(-)
26+
.../jetbrains/kotlin/cli/jvm/modules/CoreJrtFileSystem.kt | 7 ++++---
27+
1 file changed, 4 insertions(+), 3 deletions(-)
1628

1729
diff --git a/compiler/cli/cli-base/src/org/jetbrains/kotlin/cli/jvm/modules/CoreJrtFileSystem.kt b/compiler/cli/cli-base/src/org/jetbrains/kotlin/cli/jvm/modules/CoreJrtFileSystem.kt
18-
index 335a4db84c47..c399ca5bca10 100644
30+
index 335a4db84c47..566e30e2b793 100644
1931
--- a/compiler/cli/cli-base/src/org/jetbrains/kotlin/cli/jvm/modules/CoreJrtFileSystem.kt
2032
+++ b/compiler/cli/cli-base/src/org/jetbrains/kotlin/cli/jvm/modules/CoreJrtFileSystem.kt
21-
@@ -83,7 +83,7 @@ class CoreJrtFileSystem : DeprecatedVirtualFileSystem() {
22-
if (isAtLeastJava9()) {
33+
@@ -73,14 +73,14 @@ class CoreJrtFileSystem : DeprecatedVirtualFileSystem() {
34+
35+
private val globalJrtFsCache = ConcurrentFactoryMap.createMap<String, FileSystem?> { jdkHomePath ->
36+
val jdkHome = File(jdkHomePath)
37+
- val jrtFsJar = loadJrtFsJar(jdkHome) ?: return@createMap null
38+
+ /*val jrtFsJar = loadJrtFsJar(jdkHome) ?: return@createMap null*/
39+
val rootUri = URI.create(StandardFileSystems.JRT_PROTOCOL + ":/")
40+
/*
41+
The ClassLoader, that was used to load JRT FS Provider actually lives as long as current thread due to ThreadLocal leak in jrt-fs,
42+
See https://bugs.openjdk.java.net/browse/JDK-8260621
43+
So that cache allows us to avoid creating too many classloaders for same JDK and reduce severity of that leak
44+
*/
45+
- if (isAtLeastJava9()) {
46+
+ /*if (isAtLeastJava9()) {
2347
// If the runtime JDK is set to 9+ it has JrtFileSystemProvider,
2448
// but to load proper jrt-fs (one that is pointed by jdkHome) we should provide "java.home" path
25-
- FileSystems.newFileSystem(rootUri, mapOf("java.home" to jdkHome.absolutePath))
26-
+ FileSystems.newFileSystem(rootUri, mapOf("java.home" to jdkHome.absolutePath), CoreJrtFileSystem::class.java.classLoader)
27-
} else {
28-
val classLoader = URLClassLoader(arrayOf(jrtFsJar.toURI().toURL()), null)
29-
// If the runtime JDK is set to <9, there are no JrtFileSystemProvider,
49+
FileSystems.newFileSystem(rootUri, mapOf("java.home" to jdkHome.absolutePath))
50+
@@ -90,7 +90,8 @@ class CoreJrtFileSystem : DeprecatedVirtualFileSystem() {
51+
// we should create classloader with jrt-fs.jar, and DO NOT NEED to pass "java.home" path,
52+
// as otherwise it will incur additional classloader creation
53+
FileSystems.newFileSystem(rootUri, emptyMap<String, Nothing>(), classLoader)
54+
- }
55+
+ }*/
56+
+ FileSystems.newFileSystem(rootUri, mapOf("java.home" to jdkHome.absolutePath), CoreJrtFileSystem::class.java.classLoader)
57+
}
58+
}
59+
}
3060
--
3161
2.54.0
3262

‎patches/0002-fix-replace-usage-of-JavaVersion.current-with-androi.patch‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
From 098e5d16e7a537e90db7a84c7cb9f97495340162 Mon Sep 17 00:00:00 2001
1+
From 98638de0a88b8bcef765b1db7b98147faabaa3fa Mon Sep 17 00:00:00 2001
22
From: Akash Yadav <akashyadav@appdevforall.org>
33
Date: Thu, 26 Mar 2026 14:17:23 +0530
44
Subject: [PATCH 2/9] fix: replace usage of JavaVersion.current() with

‎patches/0003-fix-add-ability-to-provide-custom-CompilerConfigurat.patch‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
From f3f37dd26a82b0c265c9b13db64f1fdb98f08892 Mon Sep 17 00:00:00 2001
1+
From 789d56ec898ed1c2623435421641a45f83e584b0 Mon Sep 17 00:00:00 2001
22
From: Akash Yadav <akashyadav@appdevforall.org>
33
Date: Thu, 26 Mar 2026 14:22:09 +0530
44
Subject: [PATCH 3/9] fix: add ability to provide custom CompilerConfiguration

‎patches/0004-fix-make-LLFlightRecorder-no-op-on-Android.patch‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
From fe62ad87066ffb1715a54832967520bd8718e4b3 Mon Sep 17 00:00:00 2001
1+
From b2d4e332f45bbfa6c5cee04430af6d9134c849ae Mon Sep 17 00:00:00 2001
22
From: Akash Yadav <akashyadav@appdevforall.org>
33
Date: Thu, 26 Mar 2026 14:24:37 +0530
44
Subject: [PATCH 4/9] fix: make LLFlightRecorder no-op on Android

‎patches/0005-feat-add-analysis-api-standalone-embeddable-for-ide-.patch‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
From b184fdea99daeab7cb37e8c0ab090ab5b5b89a2c Mon Sep 17 00:00:00 2001
1+
From 666aeba80a3d7878978015e65b0b52e29fe0684d Mon Sep 17 00:00:00 2001
22
From: Akash Yadav <akashyadav@appdevforall.org>
33
Date: Thu, 26 Mar 2026 14:33:40 +0530
44
Subject: [PATCH 5/9] feat: add analysis-api-standalone-embeddable-for-ide

‎patches/0006-feat-add-android-shims-module.patch‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
From d612115d8d9d9fe4fed45ef3bc094188b0b33b2d Mon Sep 17 00:00:00 2001
1+
From 288ba66a7f9880428573ebaa6f9eea5729120129 Mon Sep 17 00:00:00 2001
22
From: Akash Yadav <akashyadav@appdevforall.org>
33
Date: Thu, 26 Mar 2026 14:35:40 +0530
44
Subject: [PATCH 6/9] feat: add android-shims module

‎patches/0007-fix-use-shimmed-SwingUtilities-directly-to-check-for.patch‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
From f2ca7bf7378d8e9e27bcce9809167a971fa8d9de Mon Sep 17 00:00:00 2001
1+
From efc5328c08b7084933c06007e37e5fefdcd3ee09 Mon Sep 17 00:00:00 2001
22
From: Akash Yadav <akashyadav@appdevforall.org>
33
Date: Thu, 26 Mar 2026 14:37:27 +0530
44
Subject: [PATCH 7/9] fix: use shimmed SwingUtilities directly to check for

‎patches/0008-fix-add-util-diff-dependency.patch‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
From fab5c00072d482253d8540d5ed73836e38f95942 Mon Sep 17 00:00:00 2001
1+
From aad0bfb9d48557218eb300ae57ac1f674cee42db Mon Sep 17 00:00:00 2001
22
From: Akash Yadav <akashyadav@appdevforall.org>
33
Date: Tue, 14 Apr 2026 01:04:17 +0530
44
Subject: [PATCH 8/9] fix: add util-diff dependency

‎patches/0009-fix-make-KaResolutionProvider-and-impl-inheritable.patch‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
From d3715a01087dc1113ff2c5d5df399e988145db72 Mon Sep 17 00:00:00 2001
1+
From 1734cc9ecaa31efa22cfc7256325b823443cbfb3 Mon Sep 17 00:00:00 2001
22
From: Akash Yadav <akashyadav@appdevforall.org>
33
Date: Mon, 4 May 2026 14:24:33 +0530
44
Subject: [PATCH 9/9] fix: make KaResolutionProvider and impl inheritable

0 commit comments

Comments
 (0)