RFR: 8292671: Hotspot Style Guide should allow covariant returns

Kim Barrett kbarrett at openjdk.org
Mon Aug 22 05:06:28 UTC 2022


On Fri, 19 Aug 2022 14:12:05 GMT, Roland Westrelin <roland at openjdk.org> wrote:

> The style guide explicitly lists covariant returns as a disallowed
> feature of c++. I propose we allow that feature.
> 
> This came up on the c2 side where, with JDK-8275201, I introduced some
> uses of covariant returns at a number of locations in the c2 code
> because I felt the code was cleaner that way. I wasn't aware it was
> mentioned on the style guide. This was noticed by another openjdk
> contributor and I prepared a change to revert the use of covariant
> returns I had introduced:
> 
> https://github.com/openjdk/jdk/pull/9237
> 
> But it feels that change actually makes the code less clear and
> comments on the PR indicates some other contributors feel the same
> way.
> 
> It's unclear to me why covariant returns are disallowed in the first
> place and the (few) contributors I asked don't seem to know either. So
> I propose simply allowing covariant returns.

Marked as reviewed by kbarrett (Reviewer).

doc/hotspot-style.md line 1073:

> 1071: ([n2544](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2544.pdf))
> 1072: 
> 1073: * Covariant return types

Covariant return types are a C++03 feature, so are covered by the blanket
permission for such here:
https://github.com/openjdk/jdk/blame/master/doc/hotspot-style.md#L385-L386

So the exclusion could be just deleted, rather than changing to explicit
permission.  Though an argument for explicit permission is to make the removal
of the long-standing exclusion more obvious.  I'm fine with either, but
thought it was worth mentioning.

-------------

PR: https://git.openjdk.org/jdk/pull/9941


More information about the hotspot-dev mailing list