aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume Martres <smarter@ubuntu.com>2017-04-11 18:44:37 +0200
committerGuillaume Martres <smarter@ubuntu.com>2017-04-11 19:25:55 +0200
commit5a1bc13634ceea8fe1f120919293083045479cf9 (patch)
tree459469c17a963f51031bfea81ef5efab666d6b3b
parentd63191d1d68a7de0bc622356b5af1599b25cbf25 (diff)
downloaddotty-5a1bc13634ceea8fe1f120919293083045479cf9.tar.gz
dotty-5a1bc13634ceea8fe1f120919293083045479cf9.tar.bz2
dotty-5a1bc13634ceea8fe1f120919293083045479cf9.zip
SI-2464 Resiliance against missing InnerClass attributes
Adapted from scalac commit 2a19cd56258884e25f26565d7b865cc2ec931b23 by Jason Zaugg, but without the testing infrastructure added: A classfile in the wild related to Vaadin lacked the InnerClasses attribute. As such, our class file parser treated a nested enum class as top-level, which led to a crash when trying to find its linked module. More details of the investigation are available in the JIRA comments. The test introduces a new facility to rewrite classfiles. This commit turns this situation into a logged warning, rather than crashing. Code by paulp, test by yours truly.
-rw-r--r--compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala8
1 files changed, 6 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 26c823f97..e7306f956 100644
--- a/compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala
+++ b/compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala
@@ -227,8 +227,12 @@ class ClassfileParser(
// seal java enums
if (isEnum) {
val enumClass = sym.owner.linkedClass
- if (!(enumClass is Flags.Sealed)) enumClass.setFlag(Flags.AbstractSealed)
- enumClass.addAnnotation(Annotation.makeChild(sym))
+ if (!enumClass.exists)
+ ctx.warning(s"no linked class for java enum $sym in ${sym.owner}. A referencing class file might be missing an InnerClasses entry.")
+ else {
+ if (!(enumClass is Flags.Sealed)) enumClass.setFlag(Flags.AbstractSealed)
+ enumClass.addAnnotation(Annotation.makeChild(sym))
+ }
}
} finally {
in.bp = oldbp