Skip to content

Commit 5a1bc13

Browse files
committed
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.
1 parent d63191d commit 5a1bc13

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,12 @@ class ClassfileParser(
227227
// seal java enums
228228
if (isEnum) {
229229
val enumClass = sym.owner.linkedClass
230-
if (!(enumClass is Flags.Sealed)) enumClass.setFlag(Flags.AbstractSealed)
231-
enumClass.addAnnotation(Annotation.makeChild(sym))
230+
if (!enumClass.exists)
231+
ctx.warning(s"no linked class for java enum $sym in ${sym.owner}. A referencing class file might be missing an InnerClasses entry.")
232+
else {
233+
if (!(enumClass is Flags.Sealed)) enumClass.setFlag(Flags.AbstractSealed)
234+
enumClass.addAnnotation(Annotation.makeChild(sym))
235+
}
232236
}
233237
} finally {
234238
in.bp = oldbp

0 commit comments

Comments
 (0)