Skip to content

Commit 7527979

Browse files
committed
Don't swallow Throwables while parsing bytecode. Print a warning and go on.
This has caused hours of debugging, to find out that 'package X does not have a member Y' were caused by a `NullPointerException`.
1 parent cfc0e18 commit 7527979

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,9 +1013,16 @@ abstract class ClassfileParser {
10131013
} catch {
10141014
case f: FatalError => throw f // don't eat fatal errors, they mean a class was not found
10151015
case ex: Throwable =>
1016-
debuglog("dropping annotation on " + sym + ", an error occured during parsing (e.g. annotation class not found)")
1017-
1018-
None // ignore malformed annotations ==> t1135
1016+
// We want to be robust when annotations are unavailable, so the very least
1017+
// we can do is warn the user about the exception
1018+
// There was a reference to ticket 1135, but that is outdated: a reference to a class not on
1019+
// the classpath would *not* end up here. A class not found is signaled
1020+
// with a `FatalError` exception, handled above. Here you'd end up after a NPE (for example),
1021+
// and that should never be swallowed silently.
1022+
warning("Caught: " + ex + " while parsing annotations in " + in.file)
1023+
if (settings.debug.value) ex.printStackTrace()
1024+
1025+
None // ignore malformed annotations
10191026
}
10201027

10211028
/**

0 commit comments

Comments
 (0)