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() } }