There exist two final record rules in Java, as follows:
a write to final field in constructor
and the constructed instance reference is assigned to variable afterwards
can not be reorderedread a instance reference
and read the final field in the instance afterwards
can not be reorderedCan we treat above rules as happen-before rules?
a write to final field in constructor
happens-before the constructed instance reference is assigned to variable afterwards
read a instance reference
happens-before read the final field in the instance afterwards
I think happens-before rule is stronger semantic.
In my understanding finally,the semantic guarantee of final keyword and happens-before rule belong to separate categories.The above derivation is wrong and unnecessary.