RFR: JDK-8215482: check for cycles in type variables can provoke NPE
Vicente Romero
vicente.romero at oracle.com
Fri Jan 11 16:47:26 UTC 2019
Please review the fix for [1] at [2]. The NPE showed up in code like:
class Outer<A extends Outer.Inner, B> {
class Inner<Bc extends B> {}
}
here attribution of type variable `A` during type enter phase will
trigger attribution of class `Inner` while type variable `B` hasn't been
attributed yet and thus its bound is still set to null. A similar
problem arose a while ago see [3]. The issue provoking the current bug
is that checks for cycles in type variables are done as soon as the type
variable is attributed but in cases like the one above we can't do that
until the type variable for the outer class has been attributed too.
My first try was to create a fixup table that maps the outer type to the
list of type variables defined by it or its members that happen to be
types too, and once the compiler finish entering the outer class it
would be safe to check for cycles in all the concerning type variables.
I had a mild success here as there were some trivial cases that were
working before that started failing. I realized that it was because the
annotation processing phase was setting all the types to null, no bueno.
So I decided to clone the type variables to be stored in the fixup table
and do the cycle check on the clones which is what the current patch is
doing.
Thanks,
Vicente
[1] https://bugs.openjdk.java.net/browse/JDK-8215482
[2] http://cr.openjdk.java.net/~vromero/8215482/
[3] https://bugs.openjdk.java.net/browse/JDK-6660289
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20190111/1d8803c9/attachment.html>
More information about the compiler-dev
mailing list