@@ -75,18 +75,14 @@ abstract class ClassfileParser {
7575
7676 private def handleMissing (e : MissingRequirementError ) = {
7777 if (settings.debug) e.printStackTrace
78- throw new IOException (" Missing dependency '" + e.req + " ', required by " + in.file)
78+ throw new IOException (s " Missing dependency ' ${ e.req} ', required by ${ in.file} " )
7979 }
8080 private def handleError (e : Exception ) = {
8181 if (settings.debug) e.printStackTrace()
82- throw new IOException (" class file '%s' is broken\n (%s/%s)" .format(
83- in.file,
84- e.getClass,
85- if (e.getMessage eq null ) " " else e.getMessage)
86- )
82+ throw new IOException (s " class file ' ${in.file}' is broken \n ( ${e.getClass}/ ${e.getMessage}) " )
8783 }
8884 private def mismatchError (c : Symbol ) = {
89- throw new IOException (" class file '%s ' has location not matching its contents: contains " .format(in.file) + c )
85+ throw new IOException (s " class file ' ${in.file} ' has location not matching its contents: contains $c " )
9086 }
9187
9288 private def parseErrorHandler [T ]: PartialFunction [Throwable , T ] = {
@@ -95,8 +91,8 @@ abstract class ClassfileParser {
9591 }
9692 @ inline private def pushBusy [T ](sym : Symbol )(body : => T ): T = {
9793 busy match {
98- case Some (`sym`) => throw new IOException (" unsatisfiable cyclic dependency in '%s' " .format(sym) )
99- case Some (sym1) => throw new IOException (" illegal class file dependency between '%s ' and '%s' " .format(sym, sym1) )
94+ case Some (`sym`) => throw new IOException (s " unsatisfiable cyclic dependency in ' $sym ' " )
95+ case Some (sym1) => throw new IOException (s " illegal class file dependency between ' $sym ' and ' $sym1 ' " )
10096 case _ => ()
10197 }
10298
@@ -242,8 +238,6 @@ abstract class ClassfileParser {
242238
243239 forceMangledName(tpe0.typeSymbol.name, module = false )
244240 val (name, tpe) = getNameAndType(in.getChar(start + 3 ), ownerTpe)
245- // println("new tpe: " + tpe + " at phase: " + phase)
246-
247241 if (name == nme.MODULE_INSTANCE_FIELD ) {
248242 val index = in.getChar(start + 1 )
249243 val name = getExternalName(in.getChar(starts(index) + 1 ))
@@ -254,14 +248,12 @@ abstract class ClassfileParser {
254248 } else {
255249 val origName = nme.unexpandedName(name)
256250 val owner = if (static) ownerTpe.typeSymbol.linkedClassOfClass else ownerTpe.typeSymbol
257- // println("\t" + owner.info.member(name).tpe.widen + " =:= " + tpe)
258251 f = owner.info.findMember(origName, 0 , 0 , stableOnly = false ).suchThat(_.tpe.widen =:= tpe)
259252 if (f == NoSymbol )
260253 f = owner.info.findMember(newTermName(origName + nme.LOCAL_SUFFIX_STRING ), 0 , 0 , stableOnly = false ).suchThat(_.tpe =:= tpe)
261254 if (f == NoSymbol ) {
262255 // if it's an impl class, try to find it's static member inside the class
263256 if (ownerTpe.typeSymbol.isImplClass) {
264- // println("impl class, member: " + owner.tpe.member(origName) + ": " + owner.tpe.member(origName).tpe)
265257 f = ownerTpe.findMember(origName, 0 , 0 , stableOnly = false ).suchThat(_.tpe =:= tpe)
266258 } else {
267259 log(" Couldn't find " + name + " : " + tpe + " inside: \n " + ownerTpe)
@@ -272,11 +264,13 @@ abstract class ClassfileParser {
272264 f setInfo tpe
273265 log(" created fake member " + f.fullName)
274266 }
275- // println("\townerTpe.decls: " + ownerTpe.decls)
276- // println("Looking for: " + name + ": " + tpe + " inside: " + ownerTpe.typeSymbol + "\n\tand found: " + ownerTpe.members)
277267 }
278268 }
279- assert(f != NoSymbol , " could not find\n " + name + " : " + tpe + " \n inside:\n " + ownerTpe.members.mkString(" , " ))
269+ assert(f != NoSymbol ,
270+ s " could not find $name: $tpe in $ownerTpe" + (
271+ if (settings.debug.value) ownerTpe.members.mkString(" , members are:\n " , " \n " , " " ) else " "
272+ )
273+ )
280274 values(index) = f
281275 }
282276 f
@@ -560,11 +554,9 @@ abstract class ClassfileParser {
560554 def addEnclosingTParams (clazz : Symbol ) {
561555 var sym = clazz.owner
562556 while (sym.isClass && ! sym.isModuleClass) {
563- // println("adding tparams of " + sym)
564- for (t <- sym.tpe.typeArgs) {
565- // println("\tadding " + (t.typeSymbol.name + "->" + t.typeSymbol))
557+ for (t <- sym.tpe.typeArgs)
566558 classTParams = classTParams + (t.typeSymbol.name -> t.typeSymbol)
567- }
559+
568560 sym = sym.owner
569561 }
570562 }
@@ -838,8 +830,6 @@ abstract class ClassfileParser {
838830 val sig = pool.getExternalName(u2)
839831 val newType = sigToType(sym, sig)
840832 sym.setInfo(newType)
841- if (settings.debug && settings.verbose)
842- println(" " + sym + " ; signature = " + sig + " type = " + newType)
843833 }
844834 else in.skip(attrLen)
845835 case tpnme.SyntheticATTR =>
@@ -856,10 +846,10 @@ abstract class ClassfileParser {
856846 val c = pool.getConstant(u2)
857847 val c1 = convertTo(c, symtype)
858848 if (c1 ne null ) sym.setInfo(ConstantType (c1))
859- else println( " failure to convert " + c + " to " + symtype); // debug
849+ else debugwarn( s " failure to convert $c to $ symtype" )
860850 case tpnme.ScalaSignatureATTR =>
861851 if (! isScalaAnnot) {
862- debuglog( " warning: symbol " + sym.fullName + " has pickled signature in attribute" )
852+ debugwarn( s " symbol ${ sym.fullName} has pickled signature in attribute " )
863853 unpickler.unpickle(in.buf, in.bp, clazz, staticModule, in.file.name)
864854 }
865855 in.skip(attrLen)
@@ -904,6 +894,12 @@ abstract class ClassfileParser {
904894 case pkg => pkg.fullName(File .separatorChar)+ File .separator+ srcfileLeaf
905895 }
906896 srcfile0 = settings.outputDirs.srcFilesFor(in.file, srcpath).find(_.exists)
897+ case tpnme.CodeATTR =>
898+ if (sym.owner.isInterface) {
899+ sym setFlag DEFAULTMETHOD
900+ log(s " $sym in ${sym.owner} is a java8+ default method. " )
901+ }
902+ in.skip(attrLen)
907903 case _ =>
908904 in.skip(attrLen)
909905 }
@@ -991,16 +987,18 @@ abstract class ClassfileParser {
991987 }
992988 if (hasError) None
993989 else Some (AnnotationInfo (attrType, List (), nvpairs.toList))
994- } catch {
995- case f : FatalError => throw f // don't eat fatal errors, they mean a class was not found
996- case ex : Throwable =>
990+ }
991+ catch {
992+ case f : FatalError => throw f // don't eat fatal errors, they mean a class was not found
993+ case ex : java.lang.Error => throw ex
994+ case ex : Throwable =>
997995 // We want to be robust when annotations are unavailable, so the very least
998996 // we can do is warn the user about the exception
999997 // There was a reference to ticket 1135, but that is outdated: a reference to a class not on
1000998 // the classpath would *not* end up here. A class not found is signaled
1001999 // with a `FatalError` exception, handled above. Here you'd end up after a NPE (for example),
10021000 // and that should never be swallowed silently.
1003- warning(" Caught: " + ex + " while parsing annotations in " + in.file)
1001+ warning(s " Caught: $ ex while parsing annotations in ${ in.file} " )
10041002 if (settings.debug) ex.printStackTrace()
10051003
10061004 None // ignore malformed annotations
0 commit comments