gnodet commented on pull request #703:
URL: https://github.com/apache/maven/pull/703#issuecomment-1085701331


   > Don;t use `Collections.unmodifiableList(xxx)`. It is vert old style - 
before year 2004 where the constructors where not thread safe, a typical 
findings with String and final fields - therefore Java changed impl for JMM of 
field semantics, used memory bariers at the end of constructor to make fields 
coherent with main mem, see JSR 133 
https://download.oracle.com/otn-pub/jcp/memory_model-1.0-pfd-spec-oth-JSpec/memory_model-1_0-pfd-spec.pdf?AuthParam=1648805410_6b63e95379a8c30dbb165b2da54c9d0d
   
   Sorry, I don't get the point of immutable collections vs memory semantics.  
I agree we should use `List.of(xxx)` if we were to raise to JDK 17, but I'm not 
sure there's a consensus there.  What do you propose I use instead for 
immutable collections ?    Also, in case you missed the point, I'm always using 
`list != null ? Collections.unmodifiableList( new ArrayList<>( list ) ) : 
Collections.emptyList()` in order to make sure the collections are actually 
safe and immutable.
   I can re-implement a custom unmodifiable collection to avoid the double 
creation, but that's more an optimisation to me rather than an actual problem.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to