diff --git a/build.gradle.kts b/build.gradle.kts index e9e53b9..694affc 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -46,7 +46,6 @@ xomrk { dependencies { compileOnly("org.jetbrains:annotations:26.0.2") compileOnly("com.intellij:annotations:9.0.4") - compileOnly("com.intellij:annotations:9.0.4") implementation("it.unimi.dsi:fastutil:6.3") implementation("ru.landgrafhomyak.utility:highlevel-try-finally:0.4") implementation("ru.landgrafhomyak.utility:reference-counter:0.1") diff --git a/sandbox/build.gradle.kts b/sandbox/build.gradle.kts new file mode 100644 index 0000000..1d434c2 --- /dev/null +++ b/sandbox/build.gradle.kts @@ -0,0 +1,21 @@ +import ru.landgrafhomyak.kotlin.kmp_gradle_build_helper.plugin.xomrk + +repositories { + mavenCentral() + maven("https://maven.landgrafhomyak.ru/") +} + +xomrk { + kotlin { + jvm {} + + sourceSets { + jvmMain { + dependencies { + implementation(project(":")) + implementation("org.xerial:sqlite-jdbc:3.49.1.0") + } + } + } + } +} \ No newline at end of file diff --git a/sandbox/src/commonMain/kotlin/main.kt b/sandbox/src/commonMain/kotlin/main.kt new file mode 100644 index 0000000..6bacc5d --- /dev/null +++ b/sandbox/src/commonMain/kotlin/main.kt @@ -0,0 +1,19 @@ +import java.sql.DriverManager +import ru.langrafhomyak.db.jdbc_resources_manager.PreparedStatementsCompilationPhantomCache + +val someStmt = PreparedStatementsCompilationPhantomCache("SELECT * FROM sqlite_master") + +fun main() { + for (i in 0..10) { + DriverManager.getConnection("jdbc:sqlite::memory:").use { connection -> + someStmt.preparedStatementForConnection(connection).use { ps -> + ps.executeQuery().use { rs -> + while (rs.next()) { + println(rs.getString(0)) + } + } + } + } + System.gc() + } +} \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts index f179ae0..732ef58 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,4 +1,3 @@ -plugins { - id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.0" -} -rootProject.name = "jdbc-resources-manager" \ No newline at end of file +rootProject.name = "jdbc-resources-manager" + +include(":sandbox") \ No newline at end of file diff --git a/src/jvmMain/java/ru/langrafhomyak/db/jdbc_resources_manager/PreparedStatementsCompilationPhantomCache.java b/src/jvmMain/java/ru/langrafhomyak/db/jdbc_resources_manager/PreparedStatementsCompilationPhantomCache.java index e36bd4f..dc4c832 100644 --- a/src/jvmMain/java/ru/langrafhomyak/db/jdbc_resources_manager/PreparedStatementsCompilationPhantomCache.java +++ b/src/jvmMain/java/ru/langrafhomyak/db/jdbc_resources_manager/PreparedStatementsCompilationPhantomCache.java @@ -23,7 +23,7 @@ public class PreparedStatementsCompilationPhantomCache /*implements ReadOnlyProp } @NotNull - PreparedStatement preparedStatementForConnection(@NotNull Connection connection) throws SQLException { + public PreparedStatement preparedStatementForConnection(@NotNull Connection connection) throws SQLException { final int key = identityHashCode(connection); ConnectionsMapNode node = this._map.get(key, connection); if (node == null) { diff --git a/src/jvmMain/kotlin/ru/langrafhomyak/db/jdbc_resources_manager/_PhantomCacheCleanup.kt b/src/jvmMain/kotlin/ru/langrafhomyak/db/jdbc_resources_manager/_PhantomCacheCleanup.kt index dfe1942..e3fb003 100644 --- a/src/jvmMain/kotlin/ru/langrafhomyak/db/jdbc_resources_manager/_PhantomCacheCleanup.kt +++ b/src/jvmMain/kotlin/ru/langrafhomyak/db/jdbc_resources_manager/_PhantomCacheCleanup.kt @@ -10,6 +10,9 @@ internal object _PhantomCacheCleanup { private val _virtualThreadProperty = "ru.langrafhomyak.db.jdbc_resources_manager._PhantomCacheCleanup.USE_VIRTUAL_THREAD" private val _referenceQueue = ReferenceQueue() + @Suppress("MAY_BE_CONST") + private val _threadName = "ru.langrafhomyak.db.jdbc_resources_manager._PhantomCacheCleanup" + init { if (this._isVirtualThreadsSupported() && System.getProperty(this._virtualThreadProperty)?.lowercase() != "false") @@ -27,9 +30,6 @@ internal object _PhantomCacheCleanup { } } - @Suppress("MAY_BE_CONST") - private val _threadName = "ru.langrafhomyak.db.jdbc_resources_manager._PhantomCacheCleanup" - private fun _startSystemThreadBeforeJ21(): Thread { val t = Thread( null,