-
-
Notifications
You must be signed in to change notification settings - Fork 1k
#3113 Add java LinkedHashSet, LinkedHashSet new factory methods for java >= 19 #3593
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#3113 Add java LinkedHashSet, LinkedHashSet new factory methods for java >= 19 #3593
Conversation
|
Basic implementation of the feature has been done. However, now 30 tests fail with errors similar to @filiphr Could you please conduct a review and help me to understand how to fix those tests? |
filiphr
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added some comments. We need a bit of cleanup before we get this on main.
Also for the failing tests, seems like we'll need to adjust our testing fixtures to be able to pick up different fails based on the java version we are testing with.
processor/src/main/resources/org/mapstruct/ap/internal/model/IterableCreation.ftl
Outdated
Show resolved
Hide resolved
|
Thanks a lot @Obolrom. Looks way way cleaner now. I'll have a look for the fixtures to work on multiple java version |
|
@filiphr @Obolrom Sorry for the late reply. I have been working on the review too. My main concern about the provided code is that, in my opinion, it actually doesn't deal with the actual problem. Please, let me trying explaining myself. The problem the new factory methods trying addressing is the following. Let's say you need to allocate When you create an The JVM will ensure that enough room for the In contrast, if you do the same with a and you actually need Addressing this issue is the reason behind the new factory methods. Please, see the actual code implementation. In other words, I think the important point here is the actual initial capacity and not the load factor, as the implementation proposed suggests, as the implementation is focused on. What do you think? |
|
@jccampanero, sorry but I don't think that I understand your comment. The fact that The current implementation looks like: Map<String,Object> map = new HashMap<>( Math.max( (int) ( N / .75f ) + 1, 16 );The goal of this PR is to generate code (on Java 19 or later) that looks like: Map<String,Object> map = HashMap.newHashMap( N );With this PR, based on the java version of the code we would either use the load factor or the new factory method. |
processor/src/main/java/org/mapstruct/ap/internal/model/common/ImplementationType.java
Outdated
Show resolved
Hide resolved
processor/src/main/java/org/mapstruct/ap/internal/model/common/TypeFactory.java
Show resolved
Hide resolved
processor/src/main/java/org/mapstruct/ap/internal/model/common/TypeFactory.java
Show resolved
Hide resolved
processor/src/main/java/org/mapstruct/ap/internal/model/common/TypeFactory.java
Outdated
Show resolved
Hide resolved
|
Hi @filiphr, thank you very much for your feedback. I absolutely agree with you. I was merely trying to provide some context, but I understand the purpose of the PR. I apologize if I didn't explain myself clearly earlier. First, I want to say that the provided implementation is quite good. Thank you, @Obolrom. However, I believe it is very focused on the load factor when we should be concentrating more on the factory method itself. I have performed a code review which I hope clarifies my point. Thank you very much for your patience, @filiphr, and great job, @Obolrom. |
jccampanero
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job @Obolrom.
@filiphr any updates about supporting fixtures for multiple java versions? |
|
@jccampanero I understood your comments now. @Obolrom I did some polishing from the feedback provided by @jccampanero. Let me know if you are OK with this. I also gave it a go to have java 21 based fixtures. I'm not super happy with the solution and it doesn't work well with the current version of the eclipse plugin for some reason. |
|
@filiphr code looks a little bit cleaner now. |
|
@filiphr, I did the fix for the Eclipse plugin. Please, share your thoughts how we can improve this solution. |
jccampanero
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
@filiphr could you please conduct a code review? It seems we are close to merge this PR 😊 |
52db9da to
deb1b91
Compare
|
@filiphr, I have rebased the branch and fixed a test |
I'm sorry, I'm on holiday at the moment. Maybe I can make it in about 2 weeks if Filip hasn't had a look yet. |
|
@filiphr , it seems the PR in status 'changes requested'. However, those changes are outdated. |
…t new factory methods for java >= 19
c7d00b4 to
bf29109
Compare
|
@filiphr @thunderhook |
|
Thanks @Obolrom. I'll try to review it it this week during my holidays. |
|
@filiphr thank you a lot |

Fixes #3113