From b470867d9caba5895d1ba1e5a9845b2bb34c4976 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Fri, 6 Oct 2017 16:53:15 +0200 Subject: [PATCH] Fix error diagnostics in ClassfileParser A recent change to print the absolute path of a bad classfile caused an NPE when the classfile parser was running on an abstract file not connected to a Java file. --- .../src/dotty/tools/dotc/core/classfile/ClassfileParser.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala b/compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala index dd3a7a22737b..1e09d54c266e 100644 --- a/compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala +++ b/compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala @@ -54,7 +54,7 @@ class ClassfileParser( private def currentIsTopLevel(implicit ctx: Context) = classRoot.owner is Flags.PackageClass private def mismatchError(className: SimpleName) = - throw new IOException(s"class file '${in.file.file.getAbsolutePath}' has location not matching its contents: contains class $className") + throw new IOException(s"class file '${in.file.canonicalPath}' has location not matching its contents: contains class $className") def run()(implicit ctx: Context): Option[Embedded] = try { ctx.debuglog("[class] >> " + classRoot.fullName) @@ -65,7 +65,7 @@ class ClassfileParser( case e: RuntimeException => if (ctx.debug) e.printStackTrace() throw new IOException( - i"""class file ${classfile.file.getAbsolutePath} is broken, reading aborted with ${e.getClass} + i"""class file ${classfile.canonicalPath} is broken, reading aborted with ${e.getClass} |${Option(e.getMessage).getOrElse("")}""") }