From 5329a6ce8e55b1640589d0fa34b985e850af371c Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Mon, 11 Jan 2021 12:48:58 +0300 Subject: [PATCH] [Test] Properly dispose class loader for running BB tests --- .../test/backend/handlers/JvmBoxRunner.kt | 32 +++++++++++-------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/JvmBoxRunner.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/JvmBoxRunner.kt index db87ec9a139..a7e9cd717ae 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/JvmBoxRunner.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/JvmBoxRunner.kt @@ -43,20 +43,24 @@ class JvmBoxRunner(testServices: TestServices) : JvmBinaryArtifactHandler(testSe val ktFiles = info.classFileFactory.inputFiles val reportProblems = module.targetBackend !in module.directives[CodegenTestDirectives.IGNORE_BACKEND] val classLoader = createAndVerifyClassLoader(module, info.classFileFactory, reportProblems) - for (ktFile in ktFiles) { - val className = ktFile.getFacadeFqName() ?: continue - val clazz = classLoader.getGeneratedClass(className) - val method = clazz.getBoxMethodOrNull() ?: continue - boxMethodFound = true - callBoxMethodAndCheckResultWithCleanup( - info.classFileFactory, - classLoader, - clazz, - method, - unexpectedBehaviour = false, - reportProblems = reportProblems - ) - return + try { + for (ktFile in ktFiles) { + val className = ktFile.getFacadeFqName() ?: continue + val clazz = classLoader.getGeneratedClass(className) + val method = clazz.getBoxMethodOrNull() ?: continue + boxMethodFound = true + callBoxMethodAndCheckResultWithCleanup( + info.classFileFactory, + classLoader, + clazz, + method, + unexpectedBehaviour = false, + reportProblems = reportProblems + ) + return + } + } finally { + classLoader.dispose() } }