[GitHub] [maven] Tibor17 edited a comment on pull request #703: New API with immutable model

2022-04-01 Thread GitBox


Tibor17 edited a comment on pull request #703:
URL: https://github.com/apache/maven/pull/703#issuecomment-1085676136


   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


-- 
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: issues-unsubscr...@maven.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [maven] Tibor17 edited a comment on pull request #703: New API with immutable model

2022-04-01 Thread GitBox


Tibor17 edited a comment on pull request #703:
URL: https://github.com/apache/maven/pull/703#issuecomment-1085676136


   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, 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


-- 
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: issues-unsubscr...@maven.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [maven] Tibor17 edited a comment on pull request #703: New API with immutable model

2022-04-01 Thread GitBox


Tibor17 edited a comment on pull request #703:
URL: https://github.com/apache/maven/pull/703#issuecomment-1085568686


   If we want to use immutable objects, we should use Java Records. We still do 
not have Valhalla ready.
   The developers often do not understand Java Memory Model and there is no 
guarantee that they would not make a mistake when they update any immutable 
object. The developers usually would not understand why ConcurrentLinkedQueue 
is preferable over ArrayList and `List.copyOf()` is ideal 
https://docs.oracle.com/javase/10/docs/api/java/util/List.html#copyOf(java.util.Collection),
 and so we should use `List.copyOf()` which means that we should switch the 
project to Java 10 - bad luck! Nobody would accept Java 10, I guess.
   
   The immutable object should be fetched with data via a builder in 
constructor.
   `MavenProject and MavenProjectBuilder composition`
   
   
   ```
   public record MavenProject(MavenProjectBuilder builder) {

   MavenProject {
   dependencies = List.copyOf(builder.getDependencies());
   ...
   ...
   ...
   }
   }
   ```


-- 
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: issues-unsubscr...@maven.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [maven] Tibor17 edited a comment on pull request #703: New API with immutable model

2022-04-01 Thread GitBox


Tibor17 edited a comment on pull request #703:
URL: https://github.com/apache/maven/pull/703#issuecomment-1085568686


   If we want to use immutable objects, we should use Java Records. We still do 
not have Valhalla ready.
   The developers often do not understand Java Memory Model and there is no 
guarantee that they would not make a mistake when they update any immutable 
object. The developers usually would not understand why ConcurrentLinkedQueue 
is preferable over ArrayList and `List.copyOf()` is ideal 
https://docs.oracle.com/javase/10/docs/api/java/util/List.html#copyOf(java.util.Collection),
 and so we should use `List.copyOf()` which means that we should switch the 
project to Java 10 - bad luck! Nobody would accept Java 10, I guess.
   
   The immutable object should be fetched with data in constructor via a 
builder.
   `MavenProject and MavenProjectBuilder composition`
   
   
   ```
   public record MavenProject(MavenProjectBuilder builder) {

   MavenProject {
   dependencies = List.copyOf(builder.getDependencies());
   ...
   ...
   ...
   }
   }
   ```


-- 
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: issues-unsubscr...@maven.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [maven] Tibor17 edited a comment on pull request #703: New API with immutable model

2022-04-01 Thread GitBox


Tibor17 edited a comment on pull request #703:
URL: https://github.com/apache/maven/pull/703#issuecomment-1085568686


   If we want to use immutable objects, we should use Java Records. We still do 
not have Valhalla ready.
   The developers often do not understand Java Memory Model and there is no 
guarantee that they would not make a mistake when they update any immutable 
object. The developers usually would not understand why ConcurrentLinkedQueue 
is preferable over ArrayList and `List.copyOf()` is ideal 
https://docs.oracle.com/javase/10/docs/api/java/util/List.html#copyOf(java.util.Collection),
 and so we should use `List.copyOf()` which means that we should switch the 
project to Java 10 - bad luck! Nobody would accept Java 10, I guess.
   
   The immutable object should be fetched with data in constructor via a 
builder.
   `MavenProject and MavenProjectBuilder composition`
   
   
   ```
   public record MavenProject(MavenProjectBuilder builder) {

   public MavenProject {
   dependencies = List.copyOf(builder.getDependencies());
   ...
   ...
   ...
   }
   }
   ```


-- 
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: issues-unsubscr...@maven.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org