On Mon, 15 Jul 2024 22:56:23 GMT, Chen Liang <li...@openjdk.org> wrote:

>> The `@Stable` on the `index` field is incorrect, as stable only avoids 
>> inlining `0`. On a strategic view, this index field should just become final 
>> so that `Name` becomes eligible for value class migration once valhalla 
>> comes. This patch makes the `index` field final and updates the usages 
>> correspondingly.
>
> Chen Liang has updated the pull request incrementally with four additional 
> commits since the last revision:
> 
>  - Make LambdaForm.Name index final
>  - Revert "8335922: Incorrect stable usage of LambdaForm$Name.index"
>    
>    This reverts commit 7d111ba3655c4c282399a4793e2cf5d91618432f.
>  - Revert "We have sufficient space in short, use +1 offset"
>    
>    This reverts commit 0743c5f924fa07ea13f8545604f870091fa8d23a.
>  - Revert "Encapsulate offsetIndex, share computation result"
>    
>    This reverts commit db805834d7117e5752bebcbd671afa6c85ff2cf0.

src/java.base/share/classes/java/lang/invoke/LambdaForm.java line 1388:

> 1386:         Name withIndex(int i) {
> 1387:             return new Name(i, type, function, arguments, constraint);
> 1388:         }

Maybe also do what `Name​::withConstraint​(Object)` does?
Suggestion:

        Name withIndex(int i) {
            if (i == this.index) return this;
            return new Name(i, type, function, arguments, constraint);
        }

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

PR Review Comment: https://git.openjdk.org/jdk/pull/20178#discussion_r1678596068

Reply via email to