RFR: 8310905: [lw5] addressing review comments on null restricted types [v6]
Maurizio Cimadamore
mcimadamore at openjdk.org
Fri Jul 14 00:52:17 UTC 2023
On Thu, 13 Jul 2023 22:35:41 GMT, Vicente Romero <vromero at openjdk.org> wrote:
>> addressing some review comments related to PR [1]
>>
>> [1] https://github.com/openjdk/valhalla/pull/872
>
> Vicente Romero has updated the pull request incrementally with two additional commits since the last revision:
>
> - addressing additional review comments
> - dont generate warnings for literals or constructor invocations
src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java line 2899:
> 2897: owntype = clazztype;
> 2898: if (owntype.getMetadata(TypeMetadata.NullMarker.class) == null) {
> 2899: owntype = owntype.addMetadata(new TypeMetadata.NullMarker(NullMarker.NOT_NULL)); // constructor invocations are always null restricted
I note an asymmetry here: for constructor calls, we annotate the type to say it's non-null. But for constant types we don't, and we instead look as to whether there's constant metadata. Perhaps an alternative to the suggestion I gave above is to simply set the null-restricted metadata in the visitLiteral method, so that everything is explicit.
src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Gen.java line 915:
> 913: for (List<JCExpression> l = trees; l.nonEmpty(); l = l.tail) {
> 914: genExpr(l.head, pts.head).load();
> 915: if (pts.head.isNonNullable() && l.head.type.constValue() == null) {
These changes should become unnecessary if `isNonNullable` does the right thing.
-------------
PR Review Comment: https://git.openjdk.org/valhalla/pull/880#discussion_r1263168555
PR Review Comment: https://git.openjdk.org/valhalla/pull/880#discussion_r1263168856
More information about the valhalla-dev
mailing list