diff --git a/compiler/src/dotty/tools/dotc/coverage/Serializer.scala b/compiler/src/dotty/tools/dotc/coverage/Serializer.scala index 4bd0d89a0b84..23ab73f6d42e 100644 --- a/compiler/src/dotty/tools/dotc/coverage/Serializer.scala +++ b/compiler/src/dotty/tools/dotc/coverage/Serializer.scala @@ -31,7 +31,9 @@ object Serializer: def serialize(coverage: Coverage, writer: Writer, sourceRoot: Path): Unit = def getRelativePath(filePath: Path): String = - val relPath = sourceRoot.relativize(filePath) + // We need to normalize the path here because the relativizing paths containing '.' or '..' differs between Java versions + // https://bugs.openjdk.java.net/browse/JDK-8066943 + val relPath = sourceRoot.normalize.relativize(filePath) relPath.toString def writeHeader(writer: Writer): Unit =