From e037e9de39a4b16c46c28609c1cc59bb818fc9a2 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Tue, 14 Mar 2017 13:05:56 +0100 Subject: [PATCH] Do not cache contents in VFS when reading contents of .jar files This follows the standard IDEA policy of caching file contents. --- .../kotlin/idea/caches/resolve/ClsJavaStubByVirtualFileCache.kt | 2 +- .../kotlin/idea/decompiler/common/KotlinMetadataDecompiler.kt | 2 +- .../kotlin/idea/debugger/NoStrataPositionManagerHelper.kt | 2 +- .../kotlin/idea/internal/KotlinDecompilerServiceImpl.kt | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/ClsJavaStubByVirtualFileCache.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/ClsJavaStubByVirtualFileCache.kt index 67311efcd59..4bd4cc9765d 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/ClsJavaStubByVirtualFileCache.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/ClsJavaStubByVirtualFileCache.kt @@ -48,7 +48,7 @@ class ClsJavaStubByVirtualFileCache { if (file.fileType !== JavaClassFileType.INSTANCE) return null try { - return ClsFileImpl.buildFileStub(file, file.contentsToByteArray()) + return ClsFileImpl.buildFileStub(file, file.contentsToByteArray(false)) } catch (e: ClsFormatException) { LOG.error("Failed to build java cls class for " + file.canonicalPath!!, e) diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/common/KotlinMetadataDecompiler.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/common/KotlinMetadataDecompiler.kt index 64d6e0b1c2e..04e2428c62d 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/common/KotlinMetadataDecompiler.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/common/KotlinMetadataDecompiler.kt @@ -72,7 +72,7 @@ abstract class KotlinMetadataDecompiler( if (!file.isValid) return null return try { - readFile(file.contentsToByteArray(), file) + readFile(file.contentsToByteArray(false), file) } catch (e: IOException) { // This is needed because sometimes we're given VirtualFile instances that point to non-existent .jar entries. diff --git a/idea/src/org/jetbrains/kotlin/idea/debugger/NoStrataPositionManagerHelper.kt b/idea/src/org/jetbrains/kotlin/idea/debugger/NoStrataPositionManagerHelper.kt index f900bd7baa7..52c671495f1 100644 --- a/idea/src/org/jetbrains/kotlin/idea/debugger/NoStrataPositionManagerHelper.kt +++ b/idea/src/org/jetbrains/kotlin/idea/debugger/NoStrataPositionManagerHelper.kt @@ -141,7 +141,7 @@ private fun readClassFileImpl(project: Project, val fileFinder = VirtualFileFinder.getInstance(project) val classFile = fileFinder.findVirtualFileWithHeader(classId) ?: return null - return classFile.contentsToByteArray() + return classFile.contentsToByteArray(false) } fun readFromOutput(isForTestClasses: Boolean): ByteArray? { diff --git a/idea/src/org/jetbrains/kotlin/idea/internal/KotlinDecompilerServiceImpl.kt b/idea/src/org/jetbrains/kotlin/idea/internal/KotlinDecompilerServiceImpl.kt index b2e4ea42f6b..b95b08ff0cb 100644 --- a/idea/src/org/jetbrains/kotlin/idea/internal/KotlinDecompilerServiceImpl.kt +++ b/idea/src/org/jetbrains/kotlin/idea/internal/KotlinDecompilerServiceImpl.kt @@ -69,7 +69,7 @@ class KotlinDecompilerServiceImpl : KotlinDecompilerService { }.map { it.path to it } return files.entries.associate { - Pair(File(it.key), { it.value.contentsToByteArray() }) + Pair(File(it.key), { it.value.contentsToByteArray(false) }) } }