Loosening requirements for super() invocation
Brian Goetz
brian.goetz at oracle.com
Wed Jan 4 19:23:53 UTC 2023
Another consideration regarding @apiNote is how likely the problem really is. For example, several warnings come from code like this:
private PropertyChangeSupport support = new PropertyChangeSupport(this);
Yes, it's possible in theory that PropertyChangeSupport could someday be modified to invoke some method of 'this', but in reality we know all it does is stash 'this' in a field and return and that's not likely to change anytime soon. Not much to be gained from including an @apiNote warning in those cases.
Yeah, this is a mess. The set of conditions that one would have to check to prove this safe is large, and spans both the behavior of PCS and the client. If we are convinced that _specific uses_ of this are OK, then that’s a reasonable place to use @SW without further note, but for things like the ArrayList constructors that call add, this is fundamentally dangerous and probably wants a note.
FYI, I used @implNote instead of @apiNote because this seemed like more of an implementation issue than an API issue (but please correct me if I'm wrong).
It’s on the fence….
Also, since the last post I found and fixed a few bugs, which revealed more 'this' escapes. Here are the new numbers, which have gone up a bit:
Are there interesting examples of the new form that we didn’t detect before, that would be educational to share?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/amber-dev/attachments/20230104/eddc52d5/attachment.htm>
More information about the amber-dev
mailing list