There exist two final record rules in Java, as follows:
a write to final field in constructorandthe constructed instance reference is assigned to variable afterwardscan not be reorderedread a instance referenceandread the final field in the instance afterwardscan not be reordered
Can we treat above rules as happen-before rules?
a write to final field in constructorhappens-beforethe constructed instance reference is assigned to variable afterwardsread a instance referencehappens-beforeread 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.