Parenthesized "this" and final fields
Tagir Valeev
amaembo at gmail.com
Thu Jun 7 10:58:10 UTC 2018
Hello!
I've found this issue:
https://bugs.openjdk.java.net/browse/JDK-8156180
In Java 8 "(this)" expression was not specially handled as qualifier with
respect to DA/DU analysis. This issue says to fix the problem. However to
me it seems that the problem was fixed only partially. E.g. the following
code still compiles in Java 10:
class Unassigned {
final int x = (this).y + 1;
final int y = (this).x + 1;
}
While removing parentheses make it failing of course. Also the following
code fails:
class Unassigned {
final int x;
Unassigned() {
(this).x = 1;
}
}
While removing parentheses make it working. I expect that either
parentheses should be allowed everywhere or disallowed everywhere. It was
consistent in Java 8 (disallowed everywhere), and now it looks confusing.
What do you think? Does this behavior follow the spec?
With best regards,
Tagir Valeev.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20180607/bc0f5bbb/attachment.html>
More information about the compiler-dev
mailing list